gpt4 book ai didi

c# - CI 构建引用 Microsoft.VisualStudio.QualityTools.UnitTestFramework

转载 作者:IT王子 更新时间:2023-10-29 04:19:42 29 4
gpt4 key购买 nike

我已经在 VS2015 RC 中创建了一个 C# 测试项目。它在本地构建,但是当我尝试在我们的 CI 构建服务器 (TeamCity) 上构建时,它失败并出现错误:

UnitTest1.cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [... .Tests.csproj] UnitTest1.cs(9,10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [... .Tests.csproj]

很明显,这是因为包含这些命名空间的程序集 (Microsoft.VisualStudio.QualityTools.UnitTestFramework) 不在构建服务器上;在我的本地机器上,它位于 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

我可以将程序集复制到我的解决方案中,使其成为代码库的一部分,但手动移动文件感觉有点不雅。我在 nuget 上四处搜索,发现 http://www.nuget.org/packages/Microsoft.VisualStudio.QualityTools.UnitTestFramework/我认为这可以解决问题,但是安装该软件包失败了:

Install-Package : Could not install package 'Microsoft.VisualStudio.QualityTools.UnitTestFramework 11.0.50727.1'. You are trying to install this package into a project that targets '.NETFramework, Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework

解决这个问题的最佳选择是什么?我很惊讶在 VS2015 中创建一个测试项目不会自动包含我需要的所有依赖项,尽管我可能太天真了(我是一个初出茅庐的 dot netter)。

最佳答案

答案类似于 eng.augusto's answer 中的选项 1 .
Microsoft 不为最新版本的 Microsoft.VisualStudio.QualityTools.UnitTestFramework 提供 NuGet 而是将其作为 Visual Studio 的一部分提供( normally at C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

我创建了文件夹 Microsoft.VisualStudio.QualityTools 作为我的解决方案的子文件夹并复制:

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dllMicrosoft.VisualStudio.QualityTools.UnitTestFramework.xml

文件应该添加到源代码管理(即使通常忽略 DLL)。
然后我更改了 Test.csproj 中的引用以引用新位置。

关于c# - CI 构建引用 Microsoft.VisualStudio.QualityTools.UnitTestFramework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30595283/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com