【发布时间】:2018-07-26 13:04:28
【问题描述】:
我有一个在 Visual Studio 2015 专业版 Framework - 4.6.1 中开发的 windows 应用程序。我已经使用 MStest 为这个 windows 服务编写了单元测试用例。如果我在我的机器上本地构建此应用程序,则构建成功(构建由 Visual Studio -> Build-> Build Solution 和 MSBuild 完成)。
现在我有一个没有安装 Visual Studio 2015 的虚拟机,但上面安装了 VS2017。现在我正在尝试通过 Bamboo 通过 MSBuild 构建我的应用程序。它给出了以下错误。
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?)
[C:\Users\Administrator\bamboo-home\xml-data\build-dir\GUI-DEV-JOB1\UnitTestGUI\UnitTestGUI.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?)
[C:\Users\Administrator\bamboo-home\xml-data\build-dir\GUI-DEV-JOB1\UnitTestGUI\UnitTestGUI.csproj]
UnitTest1.cs(9,10): error CS0246: The type or namespace
name 'TestMethodAttribute' could not be found (are you missing a using
directive or an assembly reference?)
[C:\Users\Administrator\bamboo-home\xml-data\build-dir\GUI-DEV-JOB1\UnitTestGUI\UnitTestGUI.csproj]
UnitTest1.cs(6,6): error CS0246: The type or namespace
name 'TestClass' could not be found (are you missing a using directive
or an assembly reference?)
[C:\Users\Administrator\bamboo-home\xml-data\build-dir\GUI-DEV-JOB1\UnitTestGUI\UnitTestGUI.csproj]
UnitTest1.cs(6,6): error CS0246: The type or namespace
name 'TestClassAttribute' could not be found (are you missing a using
directive or an assembly reference?)
[C:\Users\Administrator\bamboo-home\xml-data\build-dir\GUI-DEV-JOB1\UnitTestGUI\UnitTestGUI.csproj]
这些错误非常令人困惑,因为我引用了Microsoft.VisualStudio.QualityTools.UnitTestFramework,但仍然显示这些错误。
我觉得这些错误的原因如下(可能完全错误)。
我的构建环境中没有导致此问题的 Visual Studio 2015。或
当我在我的代码中查看此特定引用的属性时,其路径显示为“
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll”。但是在我构建代码的虚拟机中没有名称为Microsoft Visual Studio 14.0的文件夹。我怎么得到这个。是通过安装 Visual Studio 2015 吗?
谁能帮我解决这个问题,因为我被困在这里了。
【问题讨论】:
-
看起来您在项目中使用了 MSTest(命名空间:
Microsoft.VisualStudio.TestTools)这是一个类似的问题:stackoverflow.com/questions/3402899/…
标签: c# visual-studio-2015 msbuild bamboo vs-unit-testing-framework