4

I'm trying to resolve this warning from unit test runs in Visual Studio:

[6/7/2019 7:16:21 PM Warning] Test run will use DLL(s) built for framework .NETFramework,Version=v4.5 and platform X64. Following DLL(s) do not match framework/platform settings. MyProject.Tests.dll is built for Framework 4.6.2 and Platform AnyCPU. Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

I know that I need to update the runsettings file with a targetframework version matching the framework of the unit test project (4.6.2). I just can't figure out what the magic string is.

Here's the starting point:

<!-- Configurations that affect the Test Framework -->
  <RunConfiguration>
    <!-- Path relative to solution directory -->
    <ResultsDirectory>.\TestResults</ResultsDirectory>

    <!-- [x86] | x64  
      - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
    <TargetPlatform>x64</TargetPlatform>

    <!-- Framework35 | [Framework40] | Framework45 -->
    <TargetFrameworkVersion>Framework45</TargetFrameworkVersion> 
    <!--
    TargetFrameworkVersion needs to be updated, but documentation is unclear on how
    cf. https://github.com/Microsoft/vstest-docs/issues/163
    <TargetFrameworkVersion>.NETFramework,Version=v4.6.2</TargetFrameworkVersion>
    -->     
  </RunConfiguration>

Every value I can find to try results in the following exception:

[6/7/2019 8:34:20 PM Error] Failed to configure settings for runsettings plugin 'VSTest Run Configuration' as it threw following exception: 'An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'net462' specified for 'TargetFrameworkVersion'..' Please contact the plugin author.

[6/7/2019 8:34:20 PM Diagnostic] Generate test run settings exception:System.Xml.XmlException: An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'net462' specified for 'TargetFrameworkVersion'.. at Microsoft.VisualStudio.TestWindow.VSTest.TestRunSettingsService.ValidateRunConfigurationSettings(XPathNavigator runSettingsNavigator) at Microsoft.VisualStudio.TestWindow.VSTest.TestRunSettingsService.MergeRunSettingsAndFindCompatibleSources(Architecture& platform, FrameworkVersion& framework, String resultsDirectory, String solutionDirectory, IDictionary`2 sourceSettings, IXPathNavigable inputRunSettings, String& incompatibleSourcesWarning) at Microsoft.VisualStudio.TestWindow.VSTest.TestRunSettingsService.AddRunSettings(IXPathNavigable inputRunSettingDocument, IRunSettingsConfigurationInfo configurationInfo, ILogger log) at Microsoft.VisualStudio.TestWindow.Controller.Request.GenerateTestRunSettings(RunSettingConfigurationInfoState infoState)

Values I've tried:

  • .NETFramework,Version=v4.6
  • .NETFramework,Version=v4.6.2
  • v4.6.2
  • net46
  • net462
  • Framework46

Similar:

DonClaveau
  • 43
  • 1
  • 7
  • 1
    Did you found out how to run tests with v4.6.2? The answer below didn't help in my case – RoG Jul 03 '19 at 06:49
  • It didn't work for me either. Still looking. A friend at Microsoft told me to just upgrade to .NET Core. – DonClaveau Jul 06 '19 at 03:29

2 Answers2

3

Had same issue with Framework 4.6.1 tests. Since the original post, the page referenced by the https://developercommunity.visualstudio.com/content/problem/579073/test-discovery-reporting-dlls-do-not-match.html link was updated with a note that the issue is fixed in Visual Studio 16.2, which was released July 24. I upgraded, removed the entire RunConfiguration section from the .runsettings file, and now the unit tests run without error.

  • I still see the warning on 16.2.1. Confirmed that it is resolved in Visual Studio Preview (16.3.0 Preview 1.0) though so it must be coming downing the pipe at some point. – DonClaveau Aug 08 '19 at 20:37
1

I simply removed "TargetFrameworkVersion" and it worked in my case. I guess Visual Studio auto selects the correct framework if this field is not specified.

<!-- Configurations that affect the Test Framework -->
  <RunConfiguration>
    <!-- Path relative to solution directory -->
    <ResultsDirectory>.\TestResults</ResultsDirectory>

    <!-- [x86] | x64  
      - You can also change it from menu Test, Test Settings, Default Processor Architecture -->
    <TargetPlatform>x64</TargetPlatform>

  </RunConfiguration>
chronofanz
  • 11
  • 1