Can I use mstest.exe without installing Visual Studio?

I want to use mstest.exe to run my unit test on the build server, but I do not want to install Visual Studio on the build server. Can I just install MSTest without Visual Studio?

+81
visual-studio mstest build-server
Aug 04 '10 at 5:40
source share
6 answers

You can run mstest.exe without a visual studio.
Download one of the agents for Visual Studio ISO below and install the Test Agent on the server:

Visual Studio 2017 (127 MB disk space, less than download)
Visual Studio 2015 (128 MB configuration, 2 GB of disk space required)
Visual Studio 2012 (224MB)
Visual Studio 2013 (287MB)
Visual Studio 2010 (515MB)

This installs everything you need to run mstest.exe from the command line and has much less weight than visual studio. ~ 500 mb and about ~ 300 mb to install only the test agent, if I remember correctly.

+132
Feb 06 2018-12-12T00:
source share

This answer applies in particular to Visual Studio 2017, and the answer is yes . Remember, however, that Microsoft (still) does not provide any official API for finding the appropriate executable files ( MSBuild.exe and MSTest.exe ), so you are stuck in reading registry keys and / or probing various directories to search for these files . You have been warned.

  • If you need to create a unit test project, install the MSTest.TestFramework package into these projects and remove the link to Microsoft.VisualStudio.QualityTools.UnitTestFramework from them. Now you need to install Visual Studio 2017 Build Tools and call MSBuild.exe to complete the build.
  • If you need to run your tests as well, things get more complicated:
    • The easiest solution is to install VS2017 Community Edition (which includes both msbuild and mstest) - but I'm not sure of the legality of this and I am not a lawyer, so be careful!
    • A legally secure solution (and much easier, in terms of disk space) is to install the Visual Studio 2017 testing agent and then Build Tools for Visual Studio 2017 (the exact order is vital 1 ); this will give you MSTest.exe and vstest.console.exe , which you can then call. Note that actually finding out where these executables are located is a pain because they will not exist in the same directory structure as MSBuild.exe in Build Tools.

Finally, and very important: if you use MSTest.TestFramework and still need to be able to detect and run tests from Visual Studio, you will also need MSTest.TestAdapter installed in your unit test project.

1: Although VS2017 supports side-by-side installation, it uses a single registry key that records only the most recent installation. Therefore, if you install Test Agent last, the key will point to its installation directory ... but the test agent does not include MSBuild.exe , so any code that relies on this registry key to find out that the executable path will fail. Why Microsoft could not make the test agent an optional part of the Build Tools (so that all EXE servers live in the same directory hierarchy), someone guesses.

+5
May 17 '17 at 5:00
source share

I think you can probably, but its definitely not supported.

I found this blog article written by someone who claims that MSTest works without installing Visual Studio.

+4
Aug 04 2018-10-10 at
source share

@crocpulsar, you need to install Visual Studio on the build server , but you do not need to buy an additional license .

There are too many dependencies on building an assembly and running MSTest without installing VS, and this is most definitely not supported.

As long as the person who starts the build has a license, you do not need one for the build server. This has been so since the dark days of 2005, and as long as the parity of the publication exists, then you are fine.

If everyone on your team has Ultimate, then you can install it on the build server; but if one of your team members has Premium, then you should ideally install Premium on the build server. It also allows many other bits to be used, such as Code Coverage, Test Impact Analysis and Architecture Validation.

+4
Aug 07 2018-10-10T00:
source share

Here are the steps I took to get my build server to start MsTest without installing VS 2012:

  • A folder of the "Mstest" directory has been created in the c: \ dev directory.
  • Copied 'Mstest.exe' and 'Mstest.exe.config' from the C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE directory to the 'Mstest' directory
  • Copy the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll file to the 'Mstest' directory
  • Created 'assemblysies' directory in 'Mstest' folder
  • Extracted all v11 Microsoft.VisualStudio.QualityTools files. *. dll from the directory C: \ Windows \ to the directory "Mstest / assemblylies"
  • Copy all Microsoft.VisualStudio.QualityTools..dll files and Microsoft.VisualStudio.TestTools..dll files from C: \ Windows \ Microsoft.NET \ assembly \ GAC_MSIL to 'Mstest / assemblylies'
  • Copy all v11 files Microsoft.VisualStudio.QualityTools..dll and Microsoft.VisualStudio.TestTools..dll from C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE \ PrivateAssemblies to 'Mstest / assemblylies'
  • Add 'assemblies' to the 'privatePath' attribute in 'Mstest.exe.config'
  • Export 'HKEY_LOCAL_MACHINE / SOFTWARE / Wow6432Node / Microsoft / VisualStudio / 11.0 / Enterprise / QualityTools and apply it to the hudson box.
  • Copy QTAgent32.exe and QTAgent32.exe.config to the 'MsTest' directory from C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ IDE
  • Add the 'assemblies' to the 'privatePath' attribute in 'QTAgent32.exe.config'
  • Copy 'msdia110.dll' from 'C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ Common7 \ Packages \ Debugger' to 'MsTest / assemblylies'
  • Register 'msdia110.dll' with c: /windows/syswow64/regsvr32.exe/i '../ mstest / assemblies / msdia110.dll' (This threw an error, but for some reason still worked I checked its pair once and tried different versions of regsvr32.exe before I checked, but it is there in the registry)

  • Add the environment variable 'MSTEST_HOME' and set it to 'c: \ dev \ mstest \' or to your path. I used the environment variable in my build script.

Debugging MsTest Runtime Error:

Add to 'MsTest.exe.config'

 <system.diagnostics> <trace autoflush="true" indentsize="4"> <listeners> <add name="EqtListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\MsTest.log" /> </listeners> </trace> <switches> <add name="EqtTraceLevel" value="Verbose" /> </switches> </system.diagnostics> 
+1
Apr 12 '13 at 0:02
source share

MSTest was announced for .NET Core users . The ad has an example of use with the dotnet tool. I did not understand how to get a standalone mstest .

0
Aug 30 '16 at 13:35
source share



All Articles