Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure DevOps 2019服务器在执行代码覆盖率测试时失败 当前情况:_C#_Msbuild_Azure Devops_Automated Tests_Code Coverage - Fatal编程技术网

C# Azure DevOps 2019服务器在执行代码覆盖率测试时失败 当前情况:

C# Azure DevOps 2019服务器在执行代码覆盖率测试时失败 当前情况:,c#,msbuild,azure-devops,automated-tests,code-coverage,C#,Msbuild,Azure Devops,Automated Tests,Code Coverage,为了使我们的Azure DevOps 2019服务器(代理)能够构建ASP.NET Core 3和我们在其上安装的.NET Core 3应用程序(Visual Studio 2019的扩展工具)。这不是最佳实践,但Azure DevOps 2019服务器和代理安装在同一台机器上 除了收集编码器的覆盖范围外,一切都像预期的那样工作。构建应用程序并提供工件。我们可以确认,发布后的所有工件都正常工作。 正如前面提到的,除了代码覆盖之外,一切都很好 要构建的应用程序是一个.NET Framework 4

为了使我们的Azure DevOps 2019服务器(代理)能够构建ASP.NET Core 3我们在其上安装的.NET Core 3应用程序(Visual Studio 2019的扩展工具)。这不是最佳实践,但Azure DevOps 2019服务器和代理安装在同一台机器上

除了收集编码器的覆盖范围外,一切都像预期的那样工作。构建应用程序并提供工件。我们可以确认,发布后的所有工件都正常工作。
正如前面提到的,除了代码覆盖之外,一切都很好

要构建的应用程序是一个.NET Framework 4.6.2应用程序,是在VS 2019 build tools安装之前构建的,VS 2017 Enterprise已成功安装在代理上

对于测试,我们在
visualstudio构建
任务之后,在构建管道中使用MSTest和
visualstudio测试。测试任务的配置如下所示:

variables:
  SolutionRootDirectory: 'MySolutionRoot'
  SettingsFilePath: ''
  BuildPlatform: 'Any CPU'
  BuildConfiguration: 'Release'

steps:
- task: VSTest@2
  displayName: 'Test Assemblies: $(BuildConfiguration)'
  inputs:
    testAssemblyVer2: |
     **/*Test?(s).dll
     !**/obj/**
    searchFolder: '$(SolutionRootDirectory)'
    runSettingsFile: '$(SettingsFilePath)'
    codeCoverageEnabled: true
    testRunTitle: 'Test run: $(SolutionRootDirectory)\*.sln'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    diagnosticsEnabled: true
    collectDumpOn: always
    rerunFailedTests: false
所有测试均已成功执行,但任务失败,并显示以下消息:

##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\Extensions\TestPlatform\vstest.console.exe' failed with exit code 1
Publishing test results to test run '11901'
Test results remaining: 260. Test run id: 11901
##[error]VsTest task failed.
在检查整个日志后,我发现以下消息:

Data collector 'Code Coverage' message: Data collector 'Code Coverage' failed to provide initialization information. Error: System.TypeInitializationException: The type initializer for 'Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop' threw an exception. ---> Microsoft.VisualStudio.Diagnostics.Common.InvariantException: Failed to load IntelliTrace Profiler binary or failed to locate functions.
…下面有几行:

 ---> System.ComponentModel.Win32Exception: The system cannot find the path specified
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Diagnostics.Common.Check.Throw[XT](String message, Func`1 innerEx)
   at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.ThrowInvariantExceptionOnZeroPtr(IntPtr ptr, String message)
   at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.InitInterop()
   at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Diagnostics.Logging.ProfilerInterop.get_InteropInterface()
   at Microsoft.VisualStudio.Diagnostics.Logging.LoggingConfig.Publish()
   at Microsoft.VisualStudio.TraceCollector.CommonDataCollector.InitiateCollection()
   at Microsoft.VisualStudio.TraceCollector.CommonDataCollector.GetEnvironmentVariables()
   at Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector.GetEnvironmentVariables()
   at Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectorInformation.SetTestExecutionEnvironmentVariables()
   at Microsoft.VisualStudio.TestPlatform.Common.DataCollector.DataCollectionManager.GetEnvironmentVariables(Boolean& unloadedAnyCollector).
问题: 有人知道问题可能是什么吗?
我想,也许我们必须安装(VisualStudio2019的扩展工具),但我不确定这是否是正确的方法。此外,我找不到任何有意义的信息,我们必须使用哪个安装包-
Agent
Controller

在过去,大多数情况下,完全安装VisualStudio Enterprise是为了实现代理的完整功能集。但我希望采用更干净的方法,只安装所需的软件包,避免使用企业许可证作为构建代理

我们非常欢迎各种想法、方法和最佳做法。 非常感谢您的帮助。

应用解决方案 好的,在对最佳实践进行了大量研究和阅读之后,最实用、最面向目标的解决方案是在
构建代理上安装
Visual Studio 2019 Enterprise
。这是我的第一种方法,但提出了寻找另一种解决方案的问题,以避免在构建代理上安装整个VS2019 Enterprise

它包含所有需要的程序集,代码覆盖率仅是Enterprise edition的一部分

我更喜欢该解决方案,因为不需要修改构建管道。否则,必须修改所有现有的构建管道以匹配其他建议的解决方案。
如果可以编辑现有管道,以下列出了其他建议的解决方案

所有建议的解决办法:
  • 通过NuGet将()安装到测试项目中并导入其结果(可能与
  • 安装
    测试代理/控制器
    并在生成管道的MSTest任务中引用其
    vstest.console.exe
  • 将所需的二进制文件复制到生成代理上的相关目录

  • 感谢您的建议和投入的时间。

    IIRC您需要安装VS Enterprise以获得代码覆盖率。代码覆盖率收集器未包含在生成工具中。感谢您的评论。正如我所写,这是一种可能的解决方案,但我认为它不是干净的解决方案。我找不到Microsoft th的文章或类似内容at正在介绍如何在不安装Visual Studio 2019 Enterprise的情况下安装具有VS2019版本和代码覆盖率的生成代理。VS2019 Enterprise安装是否需要生成代理的许可证?我想应该需要,但找不到有关它的内容。@ChW我可以推荐您使用和的安装程序。它工作正常,可以免费使用。安装m如何来自的icrosoft.intellitrace.profiler.dll?请参阅本文中列出的2个解决方案。感谢这些方法。@MarTin是的,我过去已经在其他项目中使用了
    coverlet
    。它运行良好,但我认为我必须根据我的条件更新我的问题。我认为Microsoft有一个类似vs2019构建工具的软件包,或者有可能让它们像VS2019 Enterprise那样包含代码覆盖率。@MerlinLiang MSFT复制程序集似乎更像是一种黑客行为,而不是最佳实践解决方案。遗憾的是,您的第二个URL与第一个相同。