Skip to content

Commit

Permalink
Merge pull request #135 from jakubch1/main
Browse files Browse the repository at this point in the history
Added new scenario for IIS
  • Loading branch information
jakubch1 authored Sep 9, 2024
2 parents 115316f + 8042bbe commit d18c406
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions samples/VisualStudio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
5. [**Scenario 05** Search](scenarios/scenario05/README.md)
6. [**Scenario 06** C++ code coverage in Visual Studio](scenarios/scenario06/README.md)
7. [**Scenario 07** C++ code coverage in Visual Studio ARM64](scenarios/scenario07/README.md)
8. [**Scenario 08** Static code coverage for ASP.NET Core Web App (Razor Pages) in IIS](scenarios/scenario08/README.md)
59 changes: 59 additions & 0 deletions samples/VisualStudio/scenarios/scenario08/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Scenario Description

Static code coverage for ASP.NET Core Web App (Razor Pages) in IIS.

## Collect code coverage from IIS

1. Generate ASP.NET Core Web App (Razor Pages) project in console
```console
dotnet new webapp --output aspnetcoreapp --no-https
```
![alt text](create.png "Create ASP.NET Core Web App (Razor Pages) Project.")

2. Publish ASP.NET Core Web App (Razor Pages).
```console
dotnet publish -r win-x64
```
![alt text](publish.png "Publish ASP.NET Core Web App (Razor Pages) Project.")

3. Instrument `aspnetcoreapp.dll` in Developer PowerShell for VS Enterprise.
```console
Microsoft.CodeCoverage.Console.exe instrument aspnetcoreapp.dll -id iisdoc
```
![alt text](instrument.png "Instrument ASP.NET Core Web App (Razor Pages)")
> **_NOTE:_** For more complicated projects you will need to instrument more libraries.
4. Create new website in IIS Manager. Use publish directory as **Physical path**. Use `AspNetCoreExample` as site name. Do not start website yet.

![alt text](createwebsite.png "Create new website in IIS Manager")

5. Create code coverage configuration file `aspnet.config` with `AspNetCoreExample` in `AllowedUsers`.

```xml
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<CodeCoverage>
<AllowedUsers>
<User>IIS APPPOOL\AspNetCoreExample</User>
</AllowedUsers>
</CodeCoverage>
</Configuration>
```

6. Start code coverage collection in Admin mode Developer Powershell for VS Enterprise. It is also required to have `SeCreateGlobalPrivilege` privilage to correctly pass coverage data to collector.
```console
Microsoft.CodeCoverage.Console.exe collect -sv -id iisdoc -s D:\configs\aspnet.config
```
![alt text](startcollection.png "Start code coverage collection.")

7. Start and browse website.
![alt text](startandbrowse.png "Start code coverage collection.")

8. Stop website.
![alt text](stopwebsite.png "Start code coverage collection.")

9. Stop code coverage collection using **Ctrl+C**.
![alt text](stopcollection.png "Stop code coverage collection.")

9. Open `output.coverage` file in Visual Studio Enterprise.
![alt text](results.png "Code coverage results.")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d18c406

Please sign in to comment.