Reputation: 2378
I have a windows application developed in Visual Studio 2015 professional, Framework - 4.6.1 .I have written unit test cases for this windows service using MStest. If I build this application locally on my machine, the build is successful (build is done by Visual Studio -> Build-> Build Solution and through MSBuild).
Now I have a VM where visual studio 2015 is not installed.But has VS2017 installed on it. Now I'm trying to build my application by MSBuild through Bamboo. It gives the following errors on it .
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]
The errors are quite confusing because I have referenced to Microsoft.VisualStudio.QualityTools.UnitTestFramework
, but still showing these error.
The reason for these errors which I feel is as follows (which can be completely wrong).
There is no Visual Studio 2015 on my build environment which is causing this problem. or
When I look at the properties for this particular reference in my code, the path for this is displayed as "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
". But there is no folder with name Microsoft Visual Studio 14.0
in my VM where I'm building the code. How do I get this. Is it by installing Visual Studio 2015?
Can anyone help me in solving this as I'm stuck here.
Upvotes: 1
Views: 2384
Reputation: 2378
I have solved this problem by changing reference from Microsoft.VisualStudio.QualityTools.UnitTestFramework
to MSTest.TestFramework
in Test project.
Upvotes: 1
Reputation: 76690
Having troubles building my solution with MSBuild on Bamboo
Just like what have you found that the unit test project still use the old particular reference from Visual Studio 2015. To resolve this issue, you can open the the unit test project with Visual Studio 2017 and remove the old reference Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
, then add it from Visual Studio 2017 installation folder:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Besides, MsTest has been released as a new NuGet package solution that is no longer tightly coupled to the Visual Studio version. The new projects are using MsTest 2.0 in Visual Studio 2017 by default. It use Microsoft.VisualStudio.TestPlatform.TestFramework
instead of Microsoft.VisualStudio.QualityTools.UnitTestFramework
. So you can also try to create a new UnitTest project from within VS2017. Maybe changing assembly references for the old test project would have worked as well. With the new reference VS2017 did discover those unit tests.
For more details see: Announcing MsTest 2.0
Upvotes: 0