@@ -22,15 +22,15 @@ public NodeContext(
2222 string baseLogDirectory ,
2323 ProjectGraphNode node ,
2424 string projectFileRelativePath ,
25- IReadOnlyDictionary < string , string > globalProperties ,
25+ IReadOnlyDictionary < string , string > filteredGlobalProperties ,
2626 IReadOnlyList < string > inputs ,
2727 HashSet < string > targetNames )
2828 {
29- Id = GenerateId ( projectFileRelativePath , node ) ;
29+ Id = GenerateId ( projectFileRelativePath , filteredGlobalProperties ) ;
3030 _logDirectory = Path . Combine ( baseLogDirectory , Id ) ;
3131 Node = node ;
3232 ProjectFileRelativePath = projectFileRelativePath ;
33- GlobalProperties = globalProperties ;
33+ FilteredGlobalProperties = filteredGlobalProperties ;
3434 Inputs = inputs ;
3535 TargetNames = targetNames ;
3636 }
@@ -56,7 +56,7 @@ public string LogDirectory
5656
5757 public string ProjectFileRelativePath { get ; }
5858
59- public IReadOnlyDictionary < string , string > GlobalProperties { get ; }
59+ public IReadOnlyDictionary < string , string > FilteredGlobalProperties { get ; }
6060
6161 public IReadOnlyList < string > Inputs { get ; }
6262
@@ -85,9 +85,17 @@ public void SetBuildResult(NodeBuildResult buildResult)
8585 /// <summary>
8686 /// Generate a stable Id which we can use for sorting and comparison purposes across builds.
8787 /// </summary>
88- private static string GenerateId ( string projectFileRelativePath , ProjectGraphNode node )
88+ private static string GenerateId ( string projectFileRelativePath , IReadOnlyDictionary < string , string > filteredGlobalProperties )
8989 {
90- SortedDictionary < string , string > sortedProperties = new ( node . ProjectInstance . GlobalProperties , StringComparer . OrdinalIgnoreCase ) ;
90+ // In practice, the dictionary we're given is SortedDictionary<string, string>, so try casting.
91+ if ( filteredGlobalProperties is not SortedDictionary < string , string > sortedProperties )
92+ {
93+ sortedProperties = new ( StringComparer . OrdinalIgnoreCase ) ;
94+ foreach ( KeyValuePair < string , string > kvp in filteredGlobalProperties )
95+ {
96+ sortedProperties . Add ( kvp . Key , kvp . Value ) ;
97+ }
98+ }
9199
92100#pragma warning disable CA5351 // Do Not Use Broken Cryptographic Algorithms. This is not used for crypto.
93101 using MD5 hasher = MD5 . Create ( ) ;
0 commit comments