You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Regression in 10.0.101] Running dotnet test with Configuration/Platform environment variables isn't considered #52358
I know what's going on here. This is a regression from the fix we did in .NET 10.0.101 for correct parsing of solution files (#51794).
To mimic MSBuild behavior for solution vs project configuration, what we did on SDK is that we parse the solution file, get the solution configuration (if specified by user), or get the default solution configuration (usually Debug), and map that to the project configurations for the individual projects in the solution.
However, what we missed is that we need to read Configuration (and Platform) env variables if no explicit solution configuration is specified, before we fallback to the default.
When everything is fully MSBuild, this happens naturally because MSBuild property reads will consider env variables, and solution files are no different here (they generate a metaproj behind the scenes).
I really would not suggest leaning more into environment variables for MSBuild properties - especially super important ones like Configuration and Platform. We generally regard this as a mistake in MSBuild these days and would not do this design if we were facing the same problem again. I'd be much more inclined to tell the user they are holding it wrong, and to have a MSbuild BuildCheck to flag any build that uses the Configuration/Platform/etc env vars. In fact, we have a buildcheck today that flags on any env var usage, that's how much we dislike the feature.
@baronfel Hmm, so are we okay with having discrepancy between build and test commands when working on solutions? In addition, a discrepancy in test command itself when running on project (which will consider the env variable most likely) vs when running on solution?
We have a number of pipelines where we heavily rely on env vars for passing msbuild properties like Configuration and Platform. Mainly because we can set these as job level env vars in CI, and then we ensures we pass the same properties through to dotnet restore, dotnet build, dotnet test, dotnet publish, dotnet pack etc. We've found doing this massively dropped the number of times people added properties to one command, leading to a later command rebuilding everything.
If this change is introduced in a newer .Net 10 sdk, that's going to be a massive break across our build pipelines, and certainly not one I'd expect in a minor sdk update.
This is exactly why I filed microsoft/testfx#7121 in the first place. All my .NET builds are setting the Configuration environment variable to Release to ensure that all the dotnet commands use the same configuration through the build pipeline.
Having this behaviour change between the SDK version 10.0.100 and version 10.0.101 is very much unexpected.
We generally regard this (environment variables for MSBuild properties) as a mistake in MSBuild these days
I understand but such a breaking change should definitely not happen in a minor SDK update! Also, the Use environment variables in a build documentation should probably be updated. Nothing discourages users from using environment variables as MSBuild properties, it just explains how the current mechanism works.
we have a buildcheck today that flags on any env var usage, that's how much we dislike the feature
I don't know what a buildcheck is but it did not warn me about using environment variables. It took me quite some time to diagnose why I was getting a Win32Exception while running my tests which were running fine with the SDK 10.0.100.
Are we okay with having discrepancy between build and test commands when working on solutions?
I say no but I'm very aware that my voice in GitHub issues has extremely little weight. 😁
@baronfel@Evangelink I feel like the best way forward here is to manually read the env variable and apply it, similar to MSBuild. I know it's not ideal, but given how MTP works today, I can't see a better alternative.
Alternative: we already have the -c/--configuration CLI option across the codebase, and test already uses it. I bet that if we had it explicitly seed its default from the Configuration env var, if present, then all CLI commands would sidestep this foot-gun without each command having to implement a per-command workaround/mitigation like @Youssef1313 mentioned above.
Activity
dotnet testMicrosoft.Testing.Platform experience #45927Youssef1313 commentedon Jan 7, 2026
I know what's going on here. This is a regression from the fix we did in .NET 10.0.101 for correct parsing of solution files (#51794).
To mimic MSBuild behavior for solution vs project configuration, what we did on SDK is that we parse the solution file, get the solution configuration (if specified by user), or get the default solution configuration (usually Debug), and map that to the project configurations for the individual projects in the solution.
However, what we missed is that we need to read
Configuration(andPlatform) env variables if no explicit solution configuration is specified, before we fallback to the default.When everything is fully MSBuild, this happens naturally because MSBuild property reads will consider env variables, and solution files are no different here (they generate a metaproj behind the scenes).
FYI @baronfel .
dotnet testfails with System.ComponentModel.Win32Exception (SDK 10.0.101) microsoft/testfx#7121 as a duplicate of this issuebaronfel commentedon Jan 7, 2026
I really would not suggest leaning more into environment variables for MSBuild properties - especially super important ones like Configuration and Platform. We generally regard this as a mistake in MSBuild these days and would not do this design if we were facing the same problem again. I'd be much more inclined to tell the user they are holding it wrong, and to have a MSbuild BuildCheck to flag any build that uses the Configuration/Platform/etc env vars. In fact, we have a buildcheck today that flags on any env var usage, that's how much we dislike the feature.
Youssef1313 commentedon Jan 7, 2026
@baronfel Hmm, so are we okay with having discrepancy between build and test commands when working on solutions? In addition, a discrepancy in test command itself when running on project (which will consider the env variable most likely) vs when running on solution?
afscrome commentedon Jan 8, 2026
We have a number of pipelines where we heavily rely on env vars for passing msbuild properties like Configuration and Platform. Mainly because we can set these as job level env vars in CI, and then we ensures we pass the same properties through to
dotnet restore,dotnet build,dotnet test,dotnet publish,dotnet packetc. We've found doing this massively dropped the number of times people added properties to one command, leading to a later command rebuilding everything.If this change is introduced in a newer .Net 10 sdk, that's going to be a massive break across our build pipelines, and certainly not one I'd expect in a minor sdk update.
0xced commentedon Jan 8, 2026
This is exactly why I filed microsoft/testfx#7121 in the first place. All my .NET builds are setting the
Configurationenvironment variable toReleaseto ensure that all thedotnetcommands use the same configuration through the build pipeline.https://github.com/0xced/0xced.Templates/blob/79e9cf98647d981be8db4861d7b47beff37e75b5/templates/nuget-classlib/.github/workflows/continuous-integration.yml#L5-L6
Having this behaviour change between the SDK version 10.0.100 and version 10.0.101 is very much unexpected.
I understand but such a breaking change should definitely not happen in a minor SDK update! Also, the Use environment variables in a build documentation should probably be updated. Nothing discourages users from using environment variables as MSBuild properties, it just explains how the current mechanism works.
I don't know what a buildcheck is but it did not warn me about using environment variables. It took me quite some time to diagnose why I was getting a
Win32Exceptionwhile running my tests which were running fine with the SDK 10.0.100.I say no but I'm very aware that my voice in GitHub issues has extremely little weight. 😁
Youssef1313 commentedon Jan 20, 2026
Ping @baronfel to suggest how to move forward here.
FYI @nohwnd as well.
Use xUnit v3 through Microsoft Testing Platform
6 remaining items
Evangelink commentedon Jun 5, 2026
@baronfel assigning the issue to you to get your decision on how we should proceed forward (also marking the issue as blocked).
Use xUnit v3 through Microsoft Testing Platform
0xced commentedon Jun 28, 2026
For reference: BuildCheck - Design Spec
Youssef1313 commentedon Jun 29, 2026
@baronfel @Evangelink I feel like the best way forward here is to manually read the env variable and apply it, similar to MSBuild. I know it's not ideal, but given how MTP works today, I can't see a better alternative.
Youssef1313 commentedon Jun 29, 2026
My theory is that it's simply this:
sdk/src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Line 49 in dec5a57
to change to:
The same for the
Platformas well.Otherwise, if we don't want to do that, we can possibly close as not planned and document it as a known limitation.
baronfel commentedon Jul 21, 2026
Alternative: we already have the
-c/--configurationCLI option across the codebase, andtestalready uses it. I bet that if we had it explicitly seed its default from theConfigurationenv var, if present, then all CLI commands would sidestep this foot-gun without each command having to implement a per-command workaround/mitigation like @Youssef1313 mentioned above.