Repository navigation
Closed
Labels
Milestone
Description
Description
It appears dotnet.exe is printing some garbage error message text to stdout whenever it's confused by the setting of the DOTNET_MULTILEVEL_LOOKUP environment variable. I hit this under msbuild, but it's likely caused any time a managed program launches dotnet.exe and sets DOTNET_MULTILEVEL_LOOKUP to empty string in the StartInfo.EnvironmentVariables (reference dotnet/msbuild/blob/main/src/Utilities/ToolTask.cs)
The errors seem to come from dotnet.exe itself. The exact build of dotnet.exe i was using is provided below.
- install dotnetsdk 5.0
- clone https://github.com/aaronla-ms/bug-repros.git
- dotnet build repro-msbuild-envvars-exec
expected:
no errors logged to console
actual:
weird errors logged to console, Failed to read environment variable [DOTNET_MULTILEVEL_LOOKUP], HRESULT: 0x800700CB. Full text:
$ dotnet build
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
Failed to read environment variable [DOTNET_MULTILEVEL_LOOKUP], HRESULT: 0x0
Failed to read environment variable [DOTNET_MULTILEVEL_LOOKUP], HRESULT: 0x800700CB
Failed to read environment variable [DOTNET_MULTILEVEL_LOOKUP], HRESULT: 0x800700CB
5.0.301
repro-msbuild-envvars-exec ->
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.00
Configuration
$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.301
Commit: ef17233f86
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.301\
Host (useful for support):
Version: 6.0.0-preview.4.21253.7
Commit: bfd6048a60
.NET SDKs installed:
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.514 [C:\Program Files\dotnet\sdk]
2.1.518 [C:\Program Files\dotnet\sdk]
2.1.524 [C:\Program Files\dotnet\sdk]
2.1.816 [C:\Program Files\dotnet\sdk]
3.1.410 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
5.0.204 [C:\Program Files\dotnet\sdk]
5.0.300-preview.21258.4 [C:\Program Files\dotnet\sdk]
5.0.301 [C:\Program Files\dotnet\sdk]
6.0.100-preview.4.21255.9 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-preview.4.21253.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-preview.4.21254.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Regression?
Uncertain.
Other information
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
vitek-karas commentedon Jun 11, 2021
Just for ease of access - the simplest repro (note that it's the easiest way since MSBuild is easy to run, could be done via .NET as well if necessary):
Create a
t.csprojwith the above content and rundotnet buildon it. Prints out:There are several issues with the code in the host around this:
GetEnvironmentVariableWwill return0in both cases (error or empty value). We should probably copy the logic inSystem.Environment.GetEnvironmentVariableGetEnvironmentVariableWactually fails it print error message intostderr. But then it ignored the error and continues as if the env. variable was not set. Host must never print tostderrorstdoutunless it will fail - outputs are owned by the app if it runs.What needs to happen:
Note:
Environment.SetEnvironmentVariablewill not work to setup a repro, since when it gets empty string value it will unset the variable.Note: What seems to work is
ProcessStartInfo.EnvironmentVariables