Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Build/Instance/TaskFactories/AssemblyTaskFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,20 +656,30 @@ private static TaskHostParameters AddNetHostParamsIfNeeded(
}

string dotnetHostPath = getProperty(Constants.DotnetHostPathEnvVarName)?.EvaluatedValue;
string ridGraphPath = getProperty(Constants.RuntimeIdentifierGraphPath)?.EvaluatedValue;
string netCoreSdkRoot = getProperty(Constants.NetCoreSdkRoot)?.EvaluatedValue?.TrimEnd('/', '\\');

if (string.IsNullOrEmpty(dotnetHostPath) || string.IsNullOrEmpty(ridGraphPath))
// The NetCoreSdkRoot property got added with .NET 11, so for earlier SDKs we fall back to the RID graph path
if (string.IsNullOrEmpty(netCoreSdkRoot))
{
return currentParams;
string ridGraphPath = getProperty(Constants.RuntimeIdentifierGraphPath)?.EvaluatedValue;
if (!string.IsNullOrEmpty(ridGraphPath))
{
netCoreSdkRoot = Path.GetDirectoryName(ridGraphPath);
}
}
Comment thread
ViktorHofer marked this conversation as resolved.

string msBuildAssemblyPath = Path.GetDirectoryName(ridGraphPath) ?? string.Empty;
// Both DOTNET_HOST_PATH and NetCoreSdkRoot are required to launch .NET task host.
// If both are not present, return the original parameters.
if (string.IsNullOrEmpty(dotnetHostPath) || string.IsNullOrEmpty(netCoreSdkRoot))
{
return currentParams;
}

return new TaskHostParameters(
runtime: currentParams.Runtime,
architecture: currentParams.Architecture,
dotnetHostPath: dotnetHostPath,
msBuildAssemblyPath: msBuildAssemblyPath);
msBuildAssemblyPath: netCoreSdkRoot);
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Build/Resources/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ internal static class Constants
/// </summary>
internal const string RuntimeIdentifierGraphPath = nameof(RuntimeIdentifierGraphPath);

/// <summary>
/// The project property name used to get the root of the .NET Core SDK.
/// </summary>
internal const string NetCoreSdkRoot = nameof(NetCoreSdkRoot);

/// <summary>
/// Defines the name of dotnet process based on the operating system.
/// </summary>
Expand Down
Loading