-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log allowed environment vars case-insensitively #9411
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I was recently investigating a problem where the issue was that `MSBuildSdksPath` was set incorrectly, so an SDK was being resolved incorrectly. I had initially ruled that out, because I knew that we should be logging environment variables that start with `MSBUILD`. We were, but case-sensitively. Since the canonical case for some of our config environment variables is not all caps, we should change that.
rainersigwald
commented
Nov 9, 2023
jaredpar
reviewed
Nov 9, 2023
jaredpar
added a commit
to jaredpar/complog
that referenced
this pull request
Nov 9, 2023
My home box has both the 7.0.400 and 8.0.100 RC2 .NET SDKs installed. This ended up revealing a subtle bug in the CLI when executing `dotnet test`. The test content in this repo generates a global.json that pins the SDK to 7.0.400. That is done for consistency in testing across developer machines and CI. The repository itself has no global.json file so it floats to the _latest_ .NET SDK. This combination revealed an odd bug in MSBuild. When executing `dotnet test` the CLI ended up spawning a `dotnet` that sets the `%MSBuildSDKsPath%` environment variable. Because `dotnet` spawned as an 8.0 process it set that path to the 8.0 SDK. When executing the `dotnet new` actions inside the tests the global.json was read by the runtime host and ended up spawning a `dotnet` process from the 7.0 runtime. But msbuild ended up loading tasks / targets from 8.0 SDK due to the `%MSBuildSDKsPath%` value. Those targeted `net8.0` and hence failed to load in the 7.0 runtime. ``` The template "Console App" was created successfully. Processing post-creation actions... Restoring C:\Users\jaredpar\AppData\Local\Temp\CompilerLogFixture\be3521749f1e49c8bb93b2212110c4a8\scratch dir\0aa90c51a9794319bb0d1370e52350dc\example-no-generator.csproj: Determining projects to restore... C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): error MSB4062: The "CheckForImplicitPackageReferenceOverrides" task could not be loaded from the assembly C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\Sdks\Microsoft.NET.Sdk\targets\..\tools\net8.0\Microsoft.NET.Build.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\Users\jaredpar\AppData\Local\Temp\CompilerLogFixture\be3521749f1e49c8bb93b2212110c4a8\scratch dir\0aa90c51a9794319bb0d1370e52350dc\example-no-generator.csproj] ``` Thanks to @rainersigwald and @baronfel for tracking this down! dotnet/msbuild#9411 variable
jaredpar
approved these changes
Nov 9, 2023
jaredpar
added a commit
to jaredpar/complog
that referenced
this pull request
Nov 10, 2023
My home box has both the 7.0.400 and 8.0.100 RC2 .NET SDKs installed. This ended up revealing a subtle bug in the CLI when executing `dotnet test`. The test content in this repo generates a global.json that pins the SDK to 7.0.400. That is done for consistency in testing across developer machines and CI. The repository itself has no global.json file so it floats to the _latest_ .NET SDK. This combination revealed an odd bug in MSBuild. When executing `dotnet test` the CLI ended up spawning a `dotnet` that sets the `%MSBuildSDKsPath%` environment variable. Because `dotnet` spawned as an 8.0 process it set that path to the 8.0 SDK. When executing the `dotnet new` actions inside the tests the global.json was read by the runtime host and ended up spawning a `dotnet` process from the 7.0 runtime. But msbuild ended up loading tasks / targets from 8.0 SDK due to the `%MSBuildSDKsPath%` value. Those targeted `net8.0` and hence failed to load in the 7.0 runtime. ``` The template "Console App" was created successfully. Processing post-creation actions... Restoring C:\Users\jaredpar\AppData\Local\Temp\CompilerLogFixture\be3521749f1e49c8bb93b2212110c4a8\scratch dir\0aa90c51a9794319bb0d1370e52350dc\example-no-generator.csproj: Determining projects to restore... C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.Shared.targets(152,5): error MSB4062: The "CheckForImplicitPackageReferenceOverrides" task could not be loaded from the assembly C:\Program Files\dotnet\sdk\8.0.100-rc.2.23502.2\Sdks\Microsoft.NET.Sdk\targets\..\tools\net8.0\Microsoft.NET.Build.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [C:\Users\jaredpar\AppData\Local\Temp\CompilerLogFixture\be3521749f1e49c8bb93b2212110c4a8\scratch dir\0aa90c51a9794319bb0d1370e52350dc\example-no-generator.csproj] ``` Thanks to @rainersigwald and @baronfel for tracking this down! dotnet/msbuild#9411 variable
ladipro
approved these changes
Nov 14, 2023
rainersigwald
force-pushed
the
case-insensitive-binlog-env-allow-list
branch
from
November 14, 2023 20:58
72f827b
to
29bf4f0
Compare
FYI @KirillOsenkov - this is what you pointed out in recent viewer PR. |
ladipro
approved these changes
Nov 15, 2023
YuliiaKovalova
approved these changes
Nov 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was recently investigating a problem (jaredpar/complog#73) where the issue was that
MSBuildSdksPath
was set incorrectly, so an SDK was being resolved incorrectly. I had initially ruled that out, because I knew that we should be logging environment variables that start withMSBUILD
.We were, but case-sensitively. Since the canonical case for some of our config environment variables is not all caps, we should change that.