Skip to content

Commit

Permalink
dotnet.exe prints error messages to console when launched with empty …
Browse files Browse the repository at this point in the history
…DOTNET_MULTILEVEL_LOOKUP (#84322)
  • Loading branch information
pedrobsaila authored Apr 11, 2023
1 parent 94f2f27 commit 7ebb888
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ public void AppHost_FrameworkDependent_GlobalLocation_Succeeds(bool useRegistere
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion)
.And.NotHaveStdErr();

// Verify running from within the working directory
Command.Create(appExe)
Expand All @@ -216,7 +217,8 @@ public void AppHost_FrameworkDependent_GlobalLocation_Succeeds(bool useRegistere
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World")
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion);
.And.HaveStdOutContaining(sharedTestState.RepoDirectories.MicrosoftNETCoreAppVersion)
.And.NotHaveStdErr();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/installer/tests/HostActivation.Tests/StartupHooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public void Muxer_activation_of_Empty_StartupHook_Variable_Succeeds()
.CaptureStdErr()
.Execute()
.Should().Pass()
.And.HaveStdOutContaining("Hello World");
.And.HaveStdOutContaining("Hello World")
.And.NotHaveStdErr();
}

// Run the app with a startup hook assembly that depends on assemblies not on the TPA list
Expand Down
8 changes: 6 additions & 2 deletions src/native/corehost/hostmisc/pal.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,18 @@ bool pal::getenv(const char_t* name, string_t* recv)
auto err = GetLastError();
if (err != ERROR_ENVVAR_NOT_FOUND)
{
trace::error(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
trace::warning(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(err));
}
return false;
}
auto buf = new char_t[length];
if (::GetEnvironmentVariableW(name, buf, length) == 0)
{
trace::error(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(GetLastError()));
auto err = GetLastError();
if (err != ERROR_ENVVAR_NOT_FOUND)
{
trace::warning(_X("Failed to read environment variable [%s], HRESULT: 0x%X"), name, HRESULT_FROM_WIN32(err));
}
return false;
}

Expand Down

0 comments on commit 7ebb888

Please sign in to comment.