-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Issue Description
Some of the unit tests are failing when run from VS (e.g. UnusedEnvironmentVariablesDoNotAppearInBinaryLog
).
Steps to Reproduce
Run UnusedEnvironmentVariablesDoNotAppearInBinaryLog
unit test in VS
Expected Behavior
Test passes
Actual Behavior
Test fails
Analysis
This is caused by the fact that those tests are supposed to execute msbuild and fail to do so due to attempts to interpret the test runner as the dotnet host process:
msbuild/src/UnitTests.Shared/RunnerUtilities.cs
Lines 56 to 66 in cc3db35
/// <summary> | |
/// Resolve the platform specific path to the runtime executable that msbuild.exe needs to be run in (unix-mono, {unix, windows}-corerun). | |
/// </summary> | |
private static string ResolveRuntimeExecutableName() | |
{ | |
// Run the child process with the same host as the currently-running process. | |
using (Process currentProcess = Process.GetCurrentProcess()) | |
{ | |
return currentProcess.MainModule.FileName; | |
} | |
} |
Proposal
This is how sdk achieves similar thing: https://github.com/dotnet/sdk/blob/main/src/Resolvers/Microsoft.DotNet.NativeWrapper/EnvironmentProvider.cs#L65-L94
Although it's sdk specific, it should be sufficient, since the code is supposed to run only for core:
<DefineConstants>$(DefineConstants);FEATURE_RUN_EXE_IN_TESTS</DefineConstants> |