0

I have a small demo project, with unit tests. using .net5, and 64 bit/any cpu.

I am having trouble with them running in my azure pipeline.

I have made a runsetting file, but cannot specify the 5.0 net framework

I've made a failing unit test, but it doenst get run.

when I 'debug' it I get this in my azure log..

2021-03-04T16:29:27.9652466Z /TestAdapterPath:"C:\DevOps\Agent 2_work\3\s" 2021-03-04T16:29:27.9652833Z /diag:"C:\DevOps\Agent 2_work_temp\c9f3dc90-7d06-11eb-9f3e-ab7c238ad233.txt" 2021-03-04T16:29:28.0475388Z Settings file provided does not conform to required format. An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'AnyCPU' specified for 'TargetPlatform'.. 2021-03-04T16:29:28.2479067Z ##[debug]Exit code 1 received from tool 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe' 2021-03-04T16:29:28.2484150Z ##[debug]STDIO streams have closed for tool 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console.exe' 2021-03-04T16:29:28.2516774Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.

my .runsettings are:

<?xml version="1.0" encoding="utf-8"?>
 <!-- File name extension must be .runsettings -->
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
  <!-- Path relative to directory that contains .runsettings file-->
  <ResultsDirectory>.\bin\TestResults</ResultsDirectory>
<!-- x86 or x64 -->
    <!-- You can also change it from the Test menu; 
         choose "Processor Architecture for AnyCPU Projects" -->
    <TargetPlatform>AnyCPU</TargetPlatform>
    <!-- Framework35 | [Framework40] | Framework45 ... todo Framework50 er ikke suporteret-->
    <TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
    <!-- true or false -->
    <!-- Value that specifies the exit code when no tests are discovered -->
    <TreatNoTestsAsError>false</TreatNoTestsAsError>
     </RunConfiguration> 
</RunSettings>

Does ms Azure not support .net50 for unit testing, with vs tests?

Thanks for you thoughts.. Kenneth

kfn
  • 620
  • 1
  • 7
  • 26

1 Answers1

0

I have made a runsetting file, but cannot specify the 5.0 net framework

TargetFrameworkVersion:

FrameworkCore10 for .NET Core sources, FrameworkUap10 for UWP-based sources, Framework45 for .NET Framework 4.5 and higher, Framework40 for .NET Framework 4.0, and Framework35 for .NET Framework 3.5.

This setting specifies the version of the unit test framework used to discover and execute the tests. It can be different from the version of the .NET platform that you specify in the build properties of the unit test project.

If you omit the TargetFrameworkVersion element from the .runsettings file, the platform automatically determines the framework version based on the built binaries.

For the error:

An error occurred while loading the settings. Error: Invalid setting 'RunConfiguration'. Invalid value 'AnyCPU' specified for 'TargetPlatform'

TargetPlatform : x86, x64

According to the elements that the RunConfiguration element can include, the TargetPlatform node does not provide the value of AnyCPU.

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • Thanks, I ,had gotten back to the x64, but will try to leave the targetframework veroin out. – kfn Mar 05 '21 at 08:19
  • 2021-03-05T09:03:31.4105258Z [MSTest][Discovery][C:\...\DummyUnitTest.dll] Unable to load types from the test source 'C:\...\DummyUnitTest.dll'. Some or all of the tests in this source may not be discovered. 2021-03-05T09:03:31.4106111Z Error: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.... Cannot find the test. due to problesm locating system.runtime..... hmm.. - sounds kind of like the core of the problem .. – kfn Mar 05 '21 at 09:13
  • Sorry for the late response, you can refer to the workarounds provided by this [ticket](https://stackoverflow.com/questions/42755274/visual-studio-2017-could-not-load-file-or-assembly-system-runtime-version-4/42755305) – Hugh Lin Mar 10 '21 at 10:04