Skip to content

Commit 95f4da2

Browse files
revert the condition
1 parent d2d33a6 commit 95f4da2

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/Build/BackEnd/Components/Communications/NodeLauncher.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,12 @@ private Process StartInternal(string msbuildLocation, string commandLineArgs, ID
101101
string exeName = msbuildLocation;
102102

103103
#if RUNTIME_TYPE_NETCORE
104-
// If msbuildLocation is a managed assembly (.dll), use dotnet.exe to run it.
105-
// Otherwise (native app host like MSBuild.exe on Windows or MSBuild on Linux), run it directly.
106-
// Note: We avoid using Constants.MSBuildExecutableName here to prevent static initialization order issues.
107-
bool isManagedAssembly = msbuildLocation.EndsWith("MSBuild.dll", StringComparison.OrdinalIgnoreCase);
108-
if (isManagedAssembly)
104+
// If msbuildLocation is a native app host (e.g., MSBuild.exe on Windows, MSBuild on Linux), run it directly.
105+
// Otherwise, use dotnet.exe to run the managed assembly (e.g., MSBuild.dll).
106+
// Check if the filename (not path) matches the executable name exactly.
107+
string fileName = Path.GetFileName(msbuildLocation);
108+
bool isNativeAppHost = fileName.Equals(Constants.MSBuildExecutableName, StringComparison.OrdinalIgnoreCase);
109+
if (!isNativeAppHost)
109110
{
110111
// Run the child process with the same host as the currently-running process.
111112
exeName = CurrentHost.GetCurrentHost();
@@ -153,7 +154,7 @@ private Process StartInternal(string msbuildLocation, string commandLineArgs, ID
153154
{
154155
#if RUNTIME_TYPE_NETCORE
155156
// When using dotnet.exe (for managed assemblies), repeat the executable name in the args to suit CreateProcess
156-
if (isManagedAssembly)
157+
if (isNativeAppHost)
157158
{
158159
commandLineArgs = $"\"{exeName}\" {commandLineArgs}";
159160
}

0 commit comments

Comments
 (0)