Static code coverage for ASP.NET Core Web App (Razor Pages) in IIS.
-
Generate ASP.NET Core Web App (Razor Pages) project in console
dotnet new webapp --output aspnetcoreapp --no-https -
Publish ASP.NET Core Web App (Razor Pages).
dotnet publish -r win-x64 -
Instrument
aspnetcoreapp.dllin Developer PowerShell for VS Enterprise.Microsoft.CodeCoverage.Console.exe instrument aspnetcoreapp.dll -id iisdocNOTE: For more complicated projects you will need to instrument more libraries.
-
Create new website in IIS Manager. Use publish directory as Physical path. Use
AspNetCoreExampleas site name. Do not start website yet.
-
Create code coverage configuration file
aspnet.configwithAspNetCoreExampleinAllowedUsers.<?xml version="1.0" encoding="utf-8"?> <Configuration> <CodeCoverage> <AllowedUsers> <User>IIS APPPOOL\AspNetCoreExample</User> </AllowedUsers> </CodeCoverage> </Configuration>
-
Start code coverage collection in Admin mode Developer Powershell for VS Enterprise. It is also required to have
SeCreateGlobalPrivilegeprivilege to correctly pass coverage data to collector.Microsoft.CodeCoverage.Console.exe collect -sv -id iisdoc -s D:\configs\aspnet.config







