diff --git a/Public/Src/FrontEnd/MsBuild/PipConstructor.cs b/Public/Src/FrontEnd/MsBuild/PipConstructor.cs index 523180b37..49e399d2a 100644 --- a/Public/Src/FrontEnd/MsBuild/PipConstructor.cs +++ b/Public/Src/FrontEnd/MsBuild/PipConstructor.cs @@ -556,6 +556,9 @@ namespace BuildXL.FrontEnd.MsBuild // to avoid a large number of path sets processBuilder.Options |= Process.Options.EnforceWeakFingerprintAugmentation; + // Allow the pip to consume global dependencies like passthrough environment variables and untracked scopes. + processBuilder.Options |= Process.Options.RequireGlobalDependencies; + // By default the double write policy is to allow same content double writes and safe rewrites. // Otherwise we honor the double write policy specified in the resolver configuration processBuilder.RewritePolicy |= m_resolverSettings.DoubleWritePolicy.HasValue diff --git a/Public/Src/Utilities/Configuration/Resolvers/IProjectGraphResolverSettings.cs b/Public/Src/Utilities/Configuration/Resolvers/IProjectGraphResolverSettings.cs index 12e068caa..f9110c2ae 100644 --- a/Public/Src/Utilities/Configuration/Resolvers/IProjectGraphResolverSettings.cs +++ b/Public/Src/Utilities/Configuration/Resolvers/IProjectGraphResolverSettings.cs @@ -64,6 +64,9 @@ namespace BuildXL.Utilities.Configuration /// public static void ComputeEnvironment(this IProjectGraphResolverSettings resolverSettings, PathTable pathTable, out IDictionary trackedEnv, out ICollection passthroughEnv, out bool processEnvironmentUsed) { + // Do not use CollectionUtilities.EmptyArray() because the caller can modify the collection. + passthroughEnv = new List(); + if (resolverSettings.Environment == null) { var allEnvironmentVariables = Environment.GetEnvironmentVariables(); @@ -75,13 +78,11 @@ namespace BuildXL.Utilities.Configuration trackedEnv[envVar.ToString()] = value.ToString(); } - passthroughEnv = CollectionUtilities.EmptyArray(); return; } processEnvironmentUsed = false; - var trackedList = new Dictionary(OperatingSystemHelper.EnvVarComparer); - var passthroughList = new List(); + trackedEnv = new Dictionary(OperatingSystemHelper.EnvVarComparer); var builder = new StringBuilder(); foreach (var kvp in resolverSettings.Environment) @@ -90,16 +91,13 @@ namespace BuildXL.Utilities.Configuration var valueOrPassthrough = kvp.Value?.GetValue(); if (valueOrPassthrough == null || valueOrPassthrough is not UnitValue) { - trackedList.Add(kvp.Key, ProcessEnvironmentData(kvp.Value, pathTable, builder)); + trackedEnv.Add(kvp.Key, ProcessEnvironmentData(kvp.Value, pathTable, builder)); } else { - passthroughList.Add(kvp.Key); + passthroughEnv.Add(kvp.Key); } } - - trackedEnv = trackedList; - passthroughEnv = passthroughList; } private static string ProcessEnvironmentData([MaybeNull] EnvironmentData environmentData, PathTable pathTable, StringBuilder s)