vstest icon indicating copy to clipboard operation
vstest copied to clipboard

dotnet test does not forward MSBuild properties to msbuild in .NET 7 RC1

Open martincostello opened this issue 2 years ago • 5 comments

Description

Starting with .NET SDK 7.0.100-rc.1.22431.12 MSBuild parameters specified on the command line to dotnet test are no longer forwarded to MSBuild.

The issue was not present in .NET 7 preview 7.

Steps to reproduce

Clone the martincostello/api repository at commit 61ec79c1c1e773b721f6ebdf28ed189d78d63ae7 and then run dotnet test with the arguments specified below.

git clone https://github.com/martincostello/api
cd api
git checkout 61ec79c1c1e773b721f6ebdf28ed189d78d63ae7
dotnet test ./tests/API.Tests --configuration Release --filter Category=EndToEnd /p:CollectCoverage=false

Expected behavior

dotnet test exits with an exit code of 0.

Actual behavior

dotnet test returns a non-zero exit code due to the CollectCoverage property not being set to false, causing the minimum coverage requirement of coverlet to not be satisfied.

+--------+------+--------+--------+
| Module | Line | Branch | Method |
+--------+------+--------+--------+
| API    | 0%   | 0%     | 0%     |
+--------+------+--------+--------+

+---------+------+--------+--------+
|         | Line | Branch | Method |
+---------+------+--------+--------+
| Total   | 0%   | 0%     | 0%     |
+---------+------+--------+--------+
| Average | 0%   | 0%     | 0%     |
+---------+------+--------+--------+

C:\Users\martin.costello\.nuget\packages\coverlet.msbuild\3.1.2\build\coverlet.msbuild.targets(71,5): error : The minimum line coverage is below the specified 55 [C:\Coding\martincostello\api\tests\API.Tests\API.Tests.csproj] C:\Users\martin.costello\.nuget\packages\coverlet.msbuild\3.1.2\build\coverlet.msbuild.targets(71,5): error : The minimum branch coverage is below the specified 55 [C:\Coding\martincostello\api\tests\API.Tests\API.Tests.csproj]
C:\Users\martin.costello\.nuget\packages\coverlet.msbuild\3.1.2\build\coverlet.msbuild.targets(71,5): error : The minimum method coverage is below the specified 55 [C:\Coding\martincostello\api\tests\API.Tests\API.Tests.csproj]
C:\Users\martin.costello\.nuget\packages\coverlet.msbuild\3.1.2\build\coverlet.msbuild.targets(71,5): error :  [C:\Coding\martincostello\api\tests\API.Tests\API.Tests.csproj]
C:\Users\martin.costello\.nuget\packages\coverlet.msbuild\3.1.2\build\coverlet.msbuild.targets(71,5): error :    at Coverlet.MSbuild.Tasks.CoverageResultTask.Execute() in /_/src/coverlet.msbuild.tasks/CoverageResultTask.cs:line 247 [C:\Coding\martincostello\api\tests\API.Tests\API.Tests.csproj]

Environment

❯ dotnet --info
.NET SDK:
 Version:   7.0.100-rc.1.22431.12
 Commit:    f1cf61e1c0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

Host:
  Version:      7.0.0-rc.1.22426.10
  Architecture: x64
  Commit:       06aceb7015

.NET SDKs installed:
  2.1.818 [C:\Program Files\dotnet\sdk]
  3.1.120 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.302 [C:\Program Files\dotnet\sdk]
  3.1.303 [C:\Program Files\dotnet\sdk]
  3.1.403 [C:\Program Files\dotnet\sdk]
  3.1.423 [C:\Program Files\dotnet\sdk]
  5.0.103 [C:\Program Files\dotnet\sdk]
  5.0.104 [C:\Program Files\dotnet\sdk]
  5.0.203 [C:\Program Files\dotnet\sdk]
  5.0.214 [C:\Program Files\dotnet\sdk]
  5.0.303 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  5.0.411 [C:\Program Files\dotnet\sdk]
  6.0.100-rc.1.21458.32 [C:\Program Files\dotnet\sdk]
  6.0.102 [C:\Program Files\dotnet\sdk]
  6.0.109 [C:\Program Files\dotnet\sdk]
  6.0.202 [C:\Program Files\dotnet\sdk]
  6.0.203 [C:\Program Files\dotnet\sdk]
  6.0.304 [C:\Program Files\dotnet\sdk]
  6.0.400 [C:\Program Files\dotnet\sdk]
  6.0.401 [C:\Program Files\dotnet\sdk]
  7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.8.20414.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.8.20407.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.5.21301.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21480.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-preview.8.20411.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-preview.5.21301.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.1.21451.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0-rc.2.21501.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.7.22377.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  arm64 [C:\Program Files\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Coding\martincostello\api\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

martincostello avatar Sep 14 '22 17:09 martincostello

Just to add to your voice: we see this issue too when kicking off tests from this PS task.

task RunTests -If {!$SkipTests -and $SolutionToBuild} {
    exec { 
        dotnet test $SolutionToBuild `
                    --configuration $Configuration `
                    --no-build `
                    --no-restore `
                    /p:CollectCoverage="$EnableCoverage" `
                    /p:CoverletOutputFormat=cobertura `
                    /p:ExcludeByFile="$($ExcludeFilesFromCodeCoverage.Replace(",","%2C"))" `
                    --verbosity $LogLevel `
                    --logger $DotNetTestLogger
    }
}

mwadams avatar Sep 15 '22 16:09 mwadams

(Looks like there were changes to the way MSBuild parameters were passed through...)

https://github.com/dotnet/sdk/blob/release/7.0.1xx-preview7/src/Cli/dotnet/commands/dotnet-test/Program.cs

https://github.com/dotnet/sdk/blob/release/7.0.1xx-rc1/src/Cli/dotnet/commands/dotnet-test/Program.cs

mwadams avatar Sep 15 '22 17:09 mwadams

Nice spot @mwadams @baronfel might this change have caused this issue? https://github.com/dotnet/sdk/pull/26761

slang25 avatar Sep 16 '22 09:09 slang25

Good spot, thanks for the ping @slang25. We'll take a look and get this fixed for rc2.

baronfel avatar Sep 16 '22 14:09 baronfel

As a workaround, since MSBuild accepts environment variables as property values you could set an env var for each /p property you needed for the duration of the command.

baronfel avatar Sep 16 '22 18:09 baronfel

Is there an update on whether this issue will be fixed into time for .NET 7 GA?

normj avatar Oct 31 '22 20:10 normj

Hey folks! Sorry for the wait, I will work on this issue starting tomorrow. I see there is a started PR so hopefully it won't be too long.

Evangelink avatar Nov 01 '22 18:11 Evangelink

This did not land on net7.0, did it?

azchohfi avatar Nov 08 '22 20:11 azchohfi

Nope, the PR has not been merged 😢

thinkbeforecoding avatar Nov 08 '22 21:11 thinkbeforecoding

This seems to break all code coverage tools (using coverlet in my case)

thinkbeforecoding avatar Nov 08 '22 21:11 thinkbeforecoding

Yeah, I know it sucks, but a workaround (as mentioned by @baronfel) is to add the parameters as environment variables in your build pipeline; here is an Azure example from my own project:

  - task: DotNetCoreCLI@2
    displayName: 'Test Solution - Linux'
    condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
    inputs:
      command: test
      projects: test/**/*.csproj
      arguments: '--configuration $(BuildConfiguration) --verbosity quiet --collect:"XPlat Code Coverage" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
      publishTestResults: true
    env:
      CollectCoverage: true
      CoverletOutputFormat: opencover

If you want more context, have a look here: https://github.com/gimlichael/Cuemon/blob/development/.azure/steps/unit-test.yml

gimlichael avatar Nov 08 '22 22:11 gimlichael

FYI It seems to accepts the first msbuild property but nothing after. This is causing issues throughout all our pipelines! While the environment variable solution would work, we have to update all our shared and hardened AZDO templates (likely to revert once this is fixed) which we aren't crazy about.

This should've been corrected for GA....

pinkfloydx33 avatar Nov 10 '22 12:11 pinkfloydx33

Hey there! Sorry for the long delay, we have an open PR with the fix that is waiting for validation and we will bring the subject to the table so we can push the release as fast as possible. Will ping back here as soon as it's available.

Evangelink avatar Nov 10 '22 13:11 Evangelink

Hello folks! A quick update to let you know that the fix was just merged and will be available in 7.0.101. Once again really sorry in the delay in fixing the issue!

Evangelink avatar Nov 10 '22 18:11 Evangelink

when will 7.0.101 be released?

samatstariongroup avatar Nov 11 '22 14:11 samatstariongroup

7.0.101 will be the first monthly servicing release of the 7.0.1xx SDK feature band, so it will arrive early/mid next month around the same time as all of our monthly servicing releases.

baronfel avatar Nov 11 '22 14:11 baronfel

Hi, for the people could not wait for release 7.0.101. I was able to build the fixed version of dotnet.dll. You can download from: Here Just copy it in C:\Program Files\dotnet\sdk\7.0.100 and now it will work.

mtelle avatar Nov 13 '22 11:11 mtelle

Another option is to add the necessary properties to csproj/Directory.Build.props, e. g.:

<PropertyGroup Condition="$(MSBuildProjectName.Contains('.Tests.'))">
  <CollectCoverage>true</CollectCoverage>
  <ExcludeByAttribute>GeneratedCodeAttribute</ExcludeByAttribute>
  <Exclude>[*]*.Migrations.*</Exclude>
  <ExcludeByFile>**/MyFile.cs</ExcludeByFile>
  <CoverletOutputFormat>opencover</CoverletOutputFormat>
</PropertyGroup>

mu88 avatar Nov 14 '22 12:11 mu88

Hello folks! A quick update to let you know that the fix was just merged and will be available in 7.0.101. Once again really sorry in the delay in fixing the issue!

Thanks for getting the fix in. What surprises me is that a regression like this landed in the release in the first place. Especially since coverlet appears to be the de facto standard coverage provider and their official tutorial makes heavy use of this mechanic this should have been a release blocker, is there any reason why it wasn't?

Blackclaws avatar Nov 14 '22 16:11 Blackclaws

We had the same issue. All our pipelines broke when upgrading to .NET SDK 7. 😥

We ended up migrating all our parameters to a combination of RSP files in the root directory, RunSettings to configure Coverlet and XUnit configuration files.

Btw, I didn't think about it in the heat of the moment, but another possibility would have been to pin the SDK's version via a global.json. That way we could have continued using .NET 6 until this error was fixed.

Hope it helps someone in our same situation!

Starkie avatar Nov 18 '22 14:11 Starkie

Just adding a workaround for anybody that can't get the update yet, MSBuild properties work if the command line has them at the beginning, e.g..

dotnet test -p:property=value project.csproj

BrunoGuardia avatar Nov 18 '22 17:11 BrunoGuardia

Can anyone confirm (or deny) that any of the pre-release/daily builds include the fix, please?

I wanted to try the 7.0.2xx releases (available from here), but instead settled on using this command (which we also use on our build machines):

$ ./dotnet-install.sh -c 7.0 -q daily

Which resulted in:

dotnet --info                      
.NET SDK:
 Version:   7.0.101
 Commit:    cf1b55e973

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /home/user/.dotnet/sdk/7.0.101/

Host:
  Version:      7.0.0
  Architecture: x64
  Commit:       d099f075e4

.NET SDKs installed:
  5.0.408 [/home/user/.dotnet/sdk]
  6.0.403 [/home/user/.dotnet/sdk]
  7.0.100 [/home/user/.dotnet/sdk]
  7.0.101 [/home/user/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.17 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.11 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [/home/user/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.17 [/home/user/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.11 [/home/user/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [/home/user/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/user/.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

The coverage commands still don't seem to be working with this build... Thanks in advance

danielo-unity3d avatar Nov 18 '22 18:11 danielo-unity3d

This also broke ComputeSharp (https://github.com/Sergio0694/ComputeSharp/issues/437) 🥲 GitHub Actions just updated to VS 17.4 and the .NET 7 SDK and now all my tests are failing in main 😅

Sergio0694 avatar Nov 24 '22 16:11 Sergio0694

This also breaks SqlClient tests. Is there an ETA on the fix?

JRahnama avatar Nov 24 '22 20:11 JRahnama

This also breaks SqlClient tests. Is there an ETA on the fix?

Hi @JRahnama, the fix was done, we are just waiting for the releasing. For the ETA please see https://github.com/microsoft/vstest/issues/4014#issuecomment-1311751668

Evangelink avatar Nov 25 '22 09:11 Evangelink

Our Azure Build VM images were all upgraded from Current image version: '20221027.1' to Current image version: '20221120.1' yesterday which now has VS 17.4 and .net7 sdk installed and hence, all our build pipelines are now failing.

This command doesn't produce cobertura.xml output any more: dotnet test $testprojects[$i] --nologo -l trx /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=TestResults/cobertura.xml /p:Exclude=$coverageExcludes

I'm disabling our coverage checks for now to avoid blocking our developers.

Seems like switching to this approach should avoid the issue and other long-term sporadic issues with MS Build integration: https://github.com/coverlet-coverage/coverlet#vstest-integration-preferred-due-to-known-issue

RetainPhil avatar Nov 25 '22 14:11 RetainPhil

Just offering a work around for those impacted. A common practice is to include UseDotNet@2 task in your build pipelines. This mitigates issues from changes to the hosted build agents.

For instance if your unit test project currently targets netcoreapp3.1, but also has projects in the solution which require dotnet6, you can use UseDotNet@2 twice to bring in both frameworks.

This below sample has been truncated to remove settings not related to this issue.

stages:
  - stage: Build_And_Unit_Test
    jobs:
      - job: Unit_Test
        steps:
          - task: UseDotNet@2
            inputs:
              version: 3.1.x
          - task: UseDotNet@2
            inputs:
              version: 6.x
          - task: DotNetCoreCLI@2
            displayName: Test
            inputs:
              command: test
              projects: '$(buildProjects)'

james-barker-sedgwick avatar Dec 02 '22 16:12 james-barker-sedgwick

This workaround doesn't work for us. We already do that since multi-level lookups don't (or didn't?) work in non-Windows, but we still see dotnet test failing to pass properties when global.json specifies 7.0.100 instead of 6.0.400. Doesn't matter which TFM we pass to --framework either, which we do as part of a matrix strategy e.g. {platform} X {TFM}.

FWIW, I've also noticed that specifying a binary logger does not get passed down, however exactly that works anyway. This made it even harder to figure out what was wrong.

heaths avatar Dec 02 '22 22:12 heaths

@heaths The work around is to not use .net 7.0.100, because that is where the bug originates.

james-barker-sedgwick avatar Dec 05 '22 15:12 james-barker-sedgwick

7.0.101 will be the first monthly servicing release of the 7.0.1xx SDK feature band, so it will arrive early/mid next month around the same time as all of our monthly servicing releases.

@baronfel I'd like to leave the feedback that this is one of those large issues where the fix shouldn't be delayed by over a month to coincide with fixed release schedules. This should have been fixed as fast as possible. Especially seeing all the comments here about people getting this issue pushed on them via updates of their github actions etc.

Blackclaws avatar Dec 05 '22 15:12 Blackclaws