Get Visual Studio Test to work on a Jenkins server - visual-studio

I have a Jenkins server setup to build a mixed C++/C# application. I've got Visual Studio Test Agent 2017 and Visual Studio Build Tools 2017 installed but I can't build the Visual Studio test projects. The error I get is:
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'
It looks as though the appropriate assemblies are not available.
I'm using this SDK to install tools for Visual Studio 2015 which is possible with the 2017 SDK and that part works fine - I can build VS 2015 projects. Except for test projects.
Is there some extra package I need to install in order to make this work? My alternative is to install NUnit but that means rewriting the unit tests.

My solution was to use NUnit, since I was unable to find the right SDK to install VS Test without Visual Studio itself.
NUnit required changes to Resharper, file handling and changing the attributes on the test.

Related

Question - Why TFS is taking Msbuild 10.0 Instead of Version 14.0? [duplicate]

My project need to be run with MSbuild 14.0(visual studio 2015) but this is taking only Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe .
I have installed visual studio community 2017,VS 2015 web and Desktop express on my Build Agent.
Capabilities of build agent-
Task Configuration -
This configuration giving me the warning -
[warning]Visual Studio version '14.0' not found. Falling back to version '15.0'.
How can I use MSBuild 14.0 with Visual Studio build task .?? This is running with MSbuild task..
Thanks in Advance ..!!
[warning]Visual Studio version '14.0' not found. Falling back to version '15.0'
Since I do not install Visual Studio 2015 Express for Desktop and Web on my build agent, I am not sure whether Visual Studio 2015 Express for Desktop and Web is compatible with build agent.
But I found a thread about it, you can check the comment on the accepted answer:
That's it! For some reason VS2015 Express does not install the ShellFolder or InstallDir keys! I was worried that the agent script recognised it but refused to register it because we are not allowed to use it for automated builds. I feel more comfortable with it now.
It turns out that is not the full story. When I add the "Visual Studio
Build" task to the process, it now executes, but if I look more
closely at the log, I can see the following message:
"##[warning]Visual Studio was not found. Try installing a supported
version of Visual Studio. See the task definition for a list of
supported versions." And then it falls back to building with MSBuild.
It works because I am building a .sln; let's just hope I don't have to
build a .proj.
So, it seems that Visual Studio 2015 Express is not compatible with build agent. you can try to install the Visual Studio community 2015 instead of it, which I can build it without any issue.
Again, you can check if there is a parameter about Visual Studio on your Capabilities of build agent when you use Visual Studio 2015 Express:
if not, build agent will throw that error.
Hope this helps.

The same msbulid.exe shows different version on different machines

I am trying to replicate my development environment into my build server in order to debug an error that occurs only in the build server, The same solution is compiled with msbuild that is located in C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe in both machines.
In the development machine, the solution is getting compiled successfully while in the build server it fails.
Reading the outputs from msbuild I noticed that in both machines the build is done with different versions of Microsoft build engine
dev machine: 14.0.25420.1
build server:14.0.23107.0
In order to rule out that this error relates to the version
I tried to pass the msbuild from the dev machine to the build server and ran it there which output the build server version.
How can the same msbuild yield different version on a different machine?
How can I update the build engine?
How can the same msbuild yield different version on a different machine?
According to the official blog MSBuild is now part of Visual Studio!:
Starting with Visual Studio 2013, the 2013 version of MSBuild will
ship as a part of Visual Studio instead of the .NET Framework.
So at this moment, MSBuild.exe have the same version of Visual Studio 2015, you can check the version of Visual Studio 2015:
So update the version of Visual Studio on the build server to have the same version MSBuild.exe.
Update for comment:
Is it possible to update msbuild without installing visual studio?
The answer is yes, you can download the Microsoft Build Tools 2015, install it to update msbuild.exe without installing Visual Studio.
Please refer to the document MSBuild is now part of Visual Studio! for details:
The New Microsoft® Build Tools Package
MSBuild is now a component of Visual Studio and will ship with all
SKUs of Visual Studio, including Team Build so if you use Visual
Studio all of your build needs should be covered. We understand that
there are a great number of reasons that you may want to use MSBuild
and other build tools without needing to install Visual Studio so we
are making the tools available as a new standalone package called
Microsoft® Build Tools. The package includes MSBuild and the VB/C#
compilers. The new package can be acquired here on the MSDN Download
Center.
This standalone package is great for build servers requiring fine
grain control of their build process. With this new approach to
evolving MSBuild, you have more control over build behavior and are
not impacted by .NET Framework versions.
Hope this helps.

Running .webtest tests results in ".webtest is not a valid extension"

I'm using VS2017 - is there any way to get webtests working without installing VS2017 Enterprise? All I need is mstest.exe - not the GUI or IDE.
No, for unit test you can install Agents For Visual Studio 2017.
But for Web Load & Performance Testing, it is only supported in Visual Studio Enterprise 2017, So you need to install Visual Studio Enterprise 2017 with Web Performance and Load testing tools.
More information about VS 2017 supported features, you can refer to: Compare Visual Studio 2017 IDEs
Reference below threads:
Getting error: File extension specified '.webtest' is not a valid test extension
Can I use mstest.exe without installing Visual Studio?

Visual Studio 2017 Build Tools - Architecture and analysis tools

I'm encountering an issue when trying to build .modelproj projects using msbuild via Visual Studio 2017 Build Tools.
This is the error I see:
...[ProjectName].modelproj error MSB4057: The target "Rebuild" does
not exist in the project.
I have found this thread relating to some issues opening .modelproj files via the IDE in VS2017 - Visual Studio 2017 not opening .modelproj - however is there a way to get this fix onto just Build Tools rather than the full IDE? Ideally we'd like to avoid having to install the full IDE when all we require are the Build Tools on the server.
however is there a way to get this fix onto just Build Tools rather than the full IDE? Ideally we'd like to avoid having to install the full IDE when all we require are the Build Tools on the server.
You can not build Modeling projects using msbuild via Visual Studio 2017 Build Tools. Because starting with Visual Studio 2017, the UML Designers have been removed from Visual Studio, If you are a significant user of the UML designers, you can continue to use Visual Studio 2015 or earlier versions.
You can get the detail information from Port, Migrate, and Upgrade Visual Studio Projects and Microsoft Application Lifecycle Management:

TeamCity Visual Studio Build Runner Requirement

We're running TeamCity 9.0.3 and have had Visual Studio 2010, 2012 & 2013 full install on our build server for years now.
I know for a fact that we need certain Visual Studio targets in order to deploy our applications but I'm convinced we don't need to have a full Visual Studio installation in order to use the Visual Studio (sln) build runner but can't find any documentation to say whether or not we do need it.
Can anyone show me documentation or verify from their own experience whether or not a full Visual Studio install is needed for this build runner to work?
Edit: I have seen this question:
Does MSbuild require Visual Studio to be installed on the build server?
And mine is not the same question, it's a different topic. That question is asking whether or not Visual Studio is needed to as a prerequisite for the MSBuild build runner. My question pertains to the Visual Studio build runner
Roughly speaking, by installing Windows SDKs you get what's required to build applications.
Windows 7 SDK
Windows 8.1 SDK
Windows 10 SDK
Multi targeting packs are also required if you use that.
Starting from Visual Studio 2013, you also need to install the separate MSBuild 2013. And MSBuild 2015.
C++ might require you to install other bits.
So you will have to go through lots of trials. Most people simply give up and install full VS.
You don't need full Visual Studio Installed for running the build, all you need are the build tools.
In the "Step" you create to build your solution, the dropdown allows you to select which version of Microsoft builds you want to use where you can specify whether you use MSBuild12 or the latest MSBuild14 for VS2015 projects.
All you have to do is make sure that you install the required Microsoft Build tools in this instance:
Build tools for 2010, 2012 and 2013. The TC build step should then try detecting this install by default in C:/Program Files (x86)/MS Build/Build Tool Number/MSBuild.exe
Note: You will have to restart your agent after you install these tools on the Agent Machine for TeamCity to detect the tools.
The Visual Studio (sln) build runner requires the proper version of Microsoft Visual Studio installed on the build agent.
Reference: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74847254

Resources