|
| 1 | +# Updating coverage tool zips procedure |
| 2 | + |
| 3 | +FCC uses 3 coverage providers, these are zip files included in the VSIX. |
| 4 | +These get extracted to AppData\Local\FineCodeCoverage |
| 5 | + |
| 6 | +You need to debug FCC to ensure updates to these zips work. This will override the existing. |
| 7 | + |
| 8 | +## All updated zips will need to follow this procedure. |
| 9 | + |
| 10 | +1. Add to \FineCodeCoverage\Shared Files\ZippedTools directory |
| 11 | +2. Add as a linked file to the FineCodeCoverage and FineCodeCoverage2022 projects |
| 12 | + |
| 13 | +Expand the project in solution explorer |
| 14 | +Right click on the ZippedTools directory |
| 15 | +Add -> Existing Item |
| 16 | +Navigate to \FineCodeCoverage\Shared Files\ZippedTools |
| 17 | +In the browser dialog select All files to see the zips |
| 18 | +Select the zip you want to add |
| 19 | +Click the drop down arrow on the Add button and select Add as Link |
| 20 | + |
| 21 | +3. Set the Build properties in the properties window |
| 22 | + |
| 23 | +Select the file |
| 24 | +Set Build Action to Content |
| 25 | +Set Include in VSIX to True |
| 26 | + |
| 27 | +4. Remove the previous zip in solution explorer |
| 28 | + |
| 29 | +5. For all updated zips debug an appropriate project ( details follow ) and if coverage is provided the old zip can be deleted from \FineCodeCoverage\Shared Files\ZippedTools |
| 30 | + |
| 31 | +## How to update the zips |
| 32 | + |
| 33 | +### msCodeCoverage |
| 34 | + |
| 35 | +1. [Download the nuget package](https://www.nuget.org/packages/Microsoft.CodeCoverage/). |
| 36 | +2. Change the file extension to zip |
| 37 | +3. Check to see if the zip is compatible |
| 38 | + |
| 39 | +The name should be of the form microsoft.codecoverage.VERSION.zip |
| 40 | +It needs to be compatible with MsCodeCoverageRunSettingsService |
| 41 | + |
| 42 | +```csharp |
| 43 | +public void Initialize(string appDataFolder, IFCCEngine fccEngine, CancellationToken cancellationToken) |
| 44 | +{ |
| 45 | + this.fccEngine = fccEngine; |
| 46 | + var zipDestination = toolUnzipper.EnsureUnzipped(appDataFolder, zipDirectoryName,zipPrefix, cancellationToken); |
| 47 | + fccMsTestAdapterPath = Path.Combine(zipDestination, "build", "netstandard2.0"); |
| 48 | + shimPath = Path.Combine(zipDestination, "build", "netstandard2.0", "CodeCoverage", "coreclr", "Microsoft.VisualStudio.CodeCoverage.Shim.dll"); |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +The fccMsTestAdapterPath needs to be a directory that contains a ...collector.dll which is currently called Microsoft.VisualStudio.TraceDataCollector.dll. |
| 53 | +The shimPath needs to exist. |
| 54 | + |
| 55 | +4. Add the zip to the solution - see instruction at the top of this page. |
| 56 | +5. Debug |
| 57 | + |
| 58 | +Debug a project with the option MsCodeCoverage Yes |
| 59 | + |
| 60 | +### coverletCollector |
| 61 | + |
| 62 | +1. [Download the nuget package](https://www.nuget.org/packages/coverlet.collector/). |
| 63 | +2. Change the file extension to zip |
| 64 | +3. Check to see if the zip is compatible |
| 65 | + The name should be of the form coverlet.collector.VERSION.zip |
| 66 | + It needs to be compatible with CoverletDataCollectorUtil |
| 67 | + |
| 68 | +```csharp |
| 69 | +public void Initialize(string appDataFolder,CancellationToken cancellationToken) |
| 70 | +{ |
| 71 | + var zipDestination = toolUnzipper.EnsureUnzipped(appDataFolder, zipDirectoryName, zipPrefix, cancellationToken); |
| 72 | + var testAdapterPath = Path.Combine(zipDestination, "build", "netstandard2.0"); |
| 73 | + TestAdapterPathArg = $@"""{testAdapterPath}"""; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +Given that it is a data collector like msCodeCoverage the testAdapterPath needs to be a directory that contains a ...collector.dll which is currently called coverlet.collector.dll. 4. Add the zip to the solution - see instruction at the top of this page. 5. Debug |
| 78 | + |
| 79 | +Debug an SDK style project with RunMsCodeCoverage No and with the test project having an MSBuild property `<UseDataCollector/>` |
| 80 | + |
| 81 | +### coverlet |
| 82 | + |
| 83 | +1. dotnet tool install --global coverlet.console |
| 84 | + |
| 85 | +This will create or update installation in username/.dotnet/tools directory |
| 86 | + |
| 87 | +2. Create a directory - coverlet.console.VERSION |
| 88 | +3. Create a sub directory - .store |
| 89 | + |
| 90 | +Copy the following from within username/.dotnet/tools |
| 91 | +coverlet.exe into coverlet.console.VERSION |
| 92 | +coverlet.console dirctory into .store. |
| 93 | + |
| 94 | +4. Add the zip to the solution - see instruction at the top of this page. |
| 95 | +5. Debug |
| 96 | + |
| 97 | +Debug an SDK style project with RunMsCodeCoverage No and with the test project **not** having an MSBuild property `<UseDataCollector/>` |
0 commit comments