dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.66k stars 1.06k forks source link

Can't opt out of VSTestUseMSBuildOutput in project file #39127

Open sbomer opened 6 months ago

sbomer commented 6 months ago

Run dotnet test on a project that has the following property set:

<VSTestUseMSBuildOutput>False</VSTestUseMSBuildOutput>

This still uses the MSBuild terminal logger output for VSTest (which is broken in preview 1).

Further technical details

I believe the reason for this is that dotnet test passes --property:VsTestUseMSBuildOutput=true by default at https://github.com/dotnet/sdk/blob/20659d1fedc521006d2a554020548fb27a6451e3/src/Cli/dotnet/commands/dotnet-test/Program.cs#L72

This global property setting overrides anything in the project file. I think dotnet test should not be passing this; instead, the default better belongs in the MSBuild logic owned by VSTest.

 Version:           9.0.100-preview.1.24101.2
 Commit:            6bbd460f4d
 Workload version:  9.0.100-manifests.c840f51f

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  23.10
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /home/svbomer/src/runtime/.dotnet/sdk/9.0.100-preview.1.24101.2/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      9.0.0-preview.1.24080.9
  Architecture: x64
  Commit:       1d1bf92fcf

.NET SDKs installed:
  9.0.100-preview.1.24101.2 [/home/svbomer/src/runtime/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.1.24081.5 [/home/svbomer/src/runtime/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.1.24080.9 [/home/svbomer/src/runtime/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  /home/svbomer/src/runtime/global.json

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

Download .NET:
  https://aka.ms/dotnet/download
sbomer commented 6 months ago

@nohwnd this might be a candidate for tracking as part of https://github.com/microsoft/vstest/issues/4843.

nohwnd commented 6 months ago

Thanks, that is good point, added to the known issues.

nohwnd commented 6 months ago

After short analysis I don't think this will be possible to do entirely from project. We need to set nodereuse, and env variables that tell msbuild if it should run with legacy settings and disable terminal logger, and so setting it in project is too late. But I will discuss with the team.

KalleOlaviNiemitalo commented 6 months ago

Can <Project TreatAsLocalProperty="VSTestUseMSBuildOutput"> help with the opt-out?

nohwnd commented 6 months ago

Thanks. This would help override the value in the project, but would not disable the new experience entirely. In hind-sight the overall switch should not have been a property. It is giving off the wrong semantics, I think. We are doing global setup long before msbuild parses the properties, and so overriding the property can disable one aspect of the run, but it won't re-enable nodereuse:false, and it won't set the environment variable that msbuild uses to disable terminal logger and all the connected machinery.