Run tests after build not showing in test explorer - visual-studio

According to this Microsoft article on VS2015 there should be a "Run tests after every build" option in the test explorer. There is not. Any idea how to enable it?
I am running VS2015 Update 2, but perhaps there are some additional settings I need to enable?

The referred article in your question has a note on the availability on that feature:
Warning
Running unit tests after every build is supported in Visual
Studio Enterprise.
I use Community at home and Professional at work and don't have that feature in either of them.

I am using Visual Studio 2017 Professional and I really want to run tests after build, a feature is only available in Visual Studio Enterprise and currently in Visual Studio 2019 Professional Preview as well. Visual Studio 2019's IntelliSense doesn't do "code completion" well, so I still mainly use Visual Studio 2017.
A work-around to run tests after build in VS 2017 is to run the test from the command line using dotnet vstest.
Simply create a batch file to run dotnet vstest [Your Test Project].dll and add to Project Properties > Build Events > Post-build event command line: call $(ProjectDir)YourBatchFile.bat > Run the post-build event: On successful build.
Below is a sample Output after the build:

Related

How to prevent running test after build in Visual Studio Community 2017

I am using Visual Studio Community 2017 15.9.6. After every build all my Tests starts executing. How do i disable it.
There are few SO posts suggesting to disable Run Test After Build option under Test Settings menu however i am using Community edition and i do not see that option available in Community
How do i disable it?

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.

TFS 2017 Express fails build if unit test project is included in solution

I recently installed TFS 2017 Express on my Windows 10 Pro PC. I also have Visual Studio 2017 Pro installed on the same machine. When trying to build a solution on TFS, I noticed a persistent behavior. If my solution includes a unit test project, the build process fails at the "Visual Studio Build" step. If I remove the unit test project, commit to TFS, and queue a new build, the build succeeds.
I made sure to indicate "Visual Studio 2017" in the Nuget and Visual Studio build steps and "latest" in the Test build step.
These are the relevant excerpts from the log:
(Warning) Visual Studio version '15.0' not found. Looking for the latest version.
(Error) HelloConsole\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props (13, 5)
HelloConsole\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props(13,5): Error : Microsoft.Net.Compilers is only supported on MSBuild v14.0 and above
(Error) Process 'msbuild.exe' exited with code '1'.
I would include any other logs or screenshots if that would help diagnose the issue.
This symptom only happens when a C# unit test project is present. Are there any workarounds so that I can run TFS builds with a C# unit test project in the solution?
I did look at the available documentation and see nothing helpful in this scenario. I drilled through that document and looked into MSBuild Command-Line Reference, thinking I could direct Visual Studio Build to use MSBuild version 15. All I found under "version" was /version: Display version information only. The project isn’t built.
Update:
I see that there are two different ways to download TFS Express. The way I downloaded it had no mention of version. I downloaded it from here and scrolled to "Team Foundation Server Express" and clicked "Download". There was no mention of a version, as indicated by #PatrickLu-MSFT.
According to the error message logged above:
Microsoft.Net.Compilers is only supported on MSBuild v14.0 and above
TFS build are using the msbuild version distributed with .NET Framework, which is an old version. You could manually check if there are the path to the version distributed with VS 2017 / Build Tools for VS 2017 on the build agent which should be like
xxx\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
Then directly use this MSBuild.exe run the solution with unit test project on the build agent. This will narrow down if the issue related to build agent environment or not.
Suggest you to enable verbose debug mode to get more detail log for troubleshooting.
You could also upgrade your TFS Express to latest version Team Foundation Server Express 2017 Update 3, and for the build task such as Visual Studio Build, make sure you have selected the latest task version(on left corner of the configuration page).

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

Is it possible to get mstest with /publish option without needing to install Visual Studio?

I am trying to publish some junit.xml test results into my TFS build - I have transformed them into .trx files and they display fine, so long as I use MSTest.exe with /publish - but I have many users who do not have this version of MSTest installed on their build agents.
According to Command-Line options for publishing test results, the prerequisites for the version of MSTest with the /publish option are:
Visual Studio Ultimate, Visual Studio Premium, or Visual Studio Test Professional
Also, the Test Agents (e.g. Visual Studio 2013 Test Agent) only seem to install the version of mstest without the publish functionality.
Is there a way (for example, can I redistribute?) to get MSTest.exe with the publishing functionality onto TFS build agents without needing to purchase (and install) one of those copies of Visual Studio?

Resources