Skip to content
Draft
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
3 changes: 1 addition & 2 deletions src/Build/BackEnd/Client/MSBuildClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,10 @@ private bool TryLaunchServer()
// Set DOTNET_ROOT so the apphost server child can locate the runtime; this
// override is replaced by the client's environment on the first build command
// (see OutOfProcServerNode.HandleServerNodeBuildCommand → SetEnvironment).
// The `!` works around dotnet/msbuild#13761.
NodeLaunchData launchData = new(
MSBuildLocation: _msbuildLocation,
CommandLineArgs: string.Join(" ", msBuildServerOptions),
EnvironmentOverrides: DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides()!);
EnvironmentOverrides: DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides());

using Process msbuildProcess = nodeLauncher.Start(launchData, nodeId: 0);
_launchedServerPid = msbuildProcess.Id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public Process Start(NodeLaunchData launchData, int nodeId)
/// <summary>
/// Creates environment variables with optional overrides for app host bootstrap.
/// </summary>
private static BuildParameters.IBuildParameters CreateEnvironmentVariables(IDictionary<string, string> environmentOverrides)
#nullable enable annotations
private static BuildParameters.IBuildParameters CreateEnvironmentVariables(IDictionary<string, string?> environmentOverrides)
#nullable disable annotations
{
var envVars = new Dictionary<string, string>();
foreach (DictionaryEntry baseVar in Environment.GetEnvironmentVariables())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal readonly record struct NodeLaunchData(
string MSBuildLocation,
string CommandLineArgs,
Handshake? Handshake = null,
IDictionary<string, string>? EnvironmentOverrides = null);
IDictionary<string, string?>? EnvironmentOverrides = null);

internal interface INodeLauncher
{
Expand Down
4 changes: 3 additions & 1 deletion src/Build/BackEnd/Components/Communications/NodeLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ private static STARTUPINFOW CreateStartupInfo(bool redirectStreams)
/// (caller passes the inherited environment).
/// </returns>
[SupportedOSPlatform("windows")]
private static bool BuildEnvironmentBlock(ref ValueStringBuilder builder, IDictionary<string, string> environmentOverrides)
#nullable enable annotations
private static bool BuildEnvironmentBlock(ref ValueStringBuilder builder, IDictionary<string, string?> environmentOverrides)
#nullable disable annotations
{
if (environmentOverrides == null || environmentOverrides.Count == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ private NodeLaunchData ResolveAppHostOrFallback(
{
CommunicationsUtilities.Trace($"For a host context of {hostContext}, using app host from {appHostPath}.");

IDictionary<string, string> dotnetOverrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(dotnetHostPath);
var dotnetOverrides = DotnetHostEnvironmentHelper.CreateDotnetRootEnvironmentOverrides(dotnetHostPath);

return dotnetOverrides == null
? throw new NodeFailedToLaunchException(errorCode: null, ResourceUtilities.GetResourceString("DotnetHostPathNotSet"))
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/DotnetHostEnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ internal static void ClearBootstrapDotnetRootEnvironment(IDictionary<string, str
// Clear architecture-specific overrides that would take precedence over DOTNET_ROOT
foreach (string varName in _archSpecificRootVars)
{
overrides[varName] = null!;
overrides[varName] = null;
}

_cachedOverrides = overrides;
Expand All @@ -114,14 +114,14 @@ internal static void ClearBootstrapDotnetRootEnvironment(IDictionary<string, str
/// </summary>
/// <param name="environment">The environment dictionary to modify.</param>
/// <param name="overrides">The overrides to apply. If null, no changes are made.</param>
internal static void ApplyEnvironmentOverrides(IDictionary<string, string> environment, IDictionary<string, string>? overrides)
internal static void ApplyEnvironmentOverrides(IDictionary<string, string> environment, IDictionary<string, string?>? overrides)
{
if (overrides is null)
{
return;
}

foreach (KeyValuePair<string, string> kvp in overrides)
foreach (KeyValuePair<string, string?> kvp in overrides)
{
if (kvp.Value is null)
{
Expand Down