I am trying to build a dotnet solution using the below command but getting error
CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' using MSBuild.exe
Command:
bat "\"${tool 'MSBuild'}\" Test.sln /t:Rebuild /p:Configuration=Release /p:VisualStudioVersion=14.0 /p:NoWarn=7035 /p:Platform=\"Any CPU\" "
The code is present in Bitbucket and I am triggering the build from Jenkins. The code is running in windows server.
bat "\"${tool 'MSBuild'}\" Test.sln /t:Rebuild /p:Configuration=Release /p:VisualStudioVersion=14.0 /p:NoWarn=7035 /p:Platform=\"Any CPU\" "
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'TestInitialize' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
I ran into the same problem and found that it was caused by the unit test project being created in an older version of Visual Studio which used
Microsoft.VisualStudio.QualityTools.UnitTestFramework. This should be changed to use useMicrosoft.VisualStudio.TestPlatform.TestFramework, which is the default used in later unit-test projects. Steps to fix:Microsoft.VisualStudio.QualityTools.UnitTestFramework:MSTest.TestFrameworkpackage.