在IIS Express上运行的OpenCover for ASP.Net Core应用程序 [英] OpenCover for ASP.Net Core application running on IIS Express

查看:188
本文介绍了在IIS Express上运行的OpenCover for ASP.Net Core应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用OpenCover在IIS Express上运行的Asp.Net Core应用程序(DebugType-Full)获得代码覆盖率.

I'm trying to get Code Coverage for a Asp.Net Core application(DebugType - Full) running on IIS Express using OpenCover.

按照指定的

As specified here I tried setting the environment variable and then run the OpenConsole. Only difference being that I'm trying to open using iisexpress.exe instead of VSIISExeLauncher.exe

set LAUNCHER_ARGS=-p "C:\Program Files\dotnet\dotnet.exe" -a "exec \"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0\CoreWebApp.dll\"" -pidFile $([System.IO.Path]::GetTempFileName()) -wd "C:\CoreWebApp\CoreWebApp"
set LAUNCHER_PATH=C:\Program Files\IIS Express\iisexpress.exe

OpenCover.Console.exe -target:"C:\Program Files\IIS Express\iisexpress.exe" -targetargs:"/config:""C:\CoreWebApp\.vs\config\applicationhost.config"" /site:CoreWebApp" -output:"Coverage.results.xml" -register:user –targetdir:"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0"

当我在应用程序中单击任何URL时,出现"HTTP错误502.5-进程失败".

I get 'HTTP Error 502.5 - Process Failure' when I hit any URL in the application.

或者,如果我尝试直接如下运行应用程序.当我按 CTRL + C 停止服务器时,OpenCover也会停止.

Alternatively, if I try to run the application directly as below. When I press CTRL+C to stop the server, the OpenCover also stops.

OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"C:\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0\CoreWebApp.dll" -output:"Coverage.results.xml" -register:user -oldStyle

有人知道如何将OpenCover与Asp.Net Core应用程序一起使用吗?

Any idea how to use OpenCover with a Asp.Net Core application?

推荐答案

以下内容有效.

设置环境变量.

set LAUNCHER_ARGS=-p "C:\Program Files\dotnet\dotnet.exe" -a "exec ""C:\Users\baga\source\repos\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0\CoreWebApp.dll"""
set LAUNCHER_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Microsoft\Web Tools\ProjectSystem\VSIISExeLauncher.exe

如果只想在IIS express中运行点网核心应用程序,则可以使用以下命令.

Below command can be used if you want to just run the dot net core application in IIS express.

"C:\Program Files\IIS Express\iisexpress.exe" /config:"C:\Users\baga\source\repos\CoreWebApp\.vs\config\applicationhost.config" /site:"CoreWebApp"

要使用OpenCover获得代码覆盖,

To get code coverage using OpenCover,

 OpenCover.Console.exe -target:"C:\Program Files\IIS Express\iisexpress.exe" -targetargs:"/config:""C:\Users\baga\source\repos\CoreWebApp\.vs\config\applicationhost.config"" /site:CoreWebApp" -output:"c:\baga\Coverage.results.xml" -register:user –targetdir:"C:\Users\baga\source\repos\CoreWebApp\CoreWebApp\bin\Debug\netcoreapp2.0" -oldStyle

生成html报告

ReportGenerator.exe -reports:"c:\baga\Coverage.*.xml" -targetdir:"Coveragehtml"

这篇关于在IIS Express上运行的OpenCover for ASP.Net Core应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆