Skip to content

Instantly share code, notes, and snippets.

@urasandesu
Created April 29, 2017 00:39
Show Gist options
  • Save urasandesu/0c76233771de2cdc0c8027b1a8441e4a to your computer and use it in GitHub Desktop.
Save urasandesu/0c76233771de2cdc0c8027b1a8441e4a to your computer and use it in GitHub Desktop.
Visual Studio 2017 does not load .runsettings file. The following sample works fine in Visual Studio 2013.
using NUnit.Framework;
using System.Diagnostics;
namespace RunSettings2017
{
[TestFixture]
public class Class1
{
[Test]
public void ProcessNameTest()
{
#if _NET_3_5
Assert.AreEqual("vstest.executionengine.clr20", Process.GetCurrentProcess().ProcessName);
#elif _NET_4_5
Assert.AreEqual("vstest.executionengine", Process.GetCurrentProcess().ProcessName);
#endif
}
[Test]
public void ImageRuntimeVersionTest()
{
#if _NET_3_5
Assert.AreEqual("v2.0.50727", typeof(object).Assembly.ImageRuntimeVersion);
#elif _NET_4_5
Assert.AreEqual("v4.0.30319", typeof(object).Assembly.ImageRuntimeVersion);
#endif
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<TargetFrameworkVersion>Framework35</TargetFrameworkVersion>
</RunConfiguration>
</RunSettings>
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
</RunConfiguration>
</RunSettings>
@urasandesu
Copy link
Author

Visual Studio 2017 does not load .runsettings file. I attached the minimum sample that can work fine in Visual Studio 2013. The procedure is the followings:

  1. Select the Build menu -> open Configuration Manager.
  2. Change Active solution configuration to Debug(.NET 3.5).
  3. Build the solution.
  4. Select the Test menu -> Windows -> open Test Explorer.
  5. Select the Test menu again -> Select Test Settings File -> select v3.5.runsettings in the project.
  6. Select the Test menu again -> Default Processor Architecture -> x64.
  7. Select the Test menu again -> uncheck Keep Test Execution Engine Running.
  8. Select the Test menu -> Run -> execute All Tests.

=> All tests are failed. This is the problem.

The same procedure works fine in Visual Studio 2013. Also, the combination of Active solution configuration: Debug(.NET 4.6.2) and v4.5.runsettings works fine.

@milla
Copy link

milla commented Sep 22, 2017

How about framework 4.6, 4.7?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment