|
// Add/set a property with a random value to ensure that restore happens under a different evaluation context |
|
// If the evaluation context is not different, then projects won't be re-evaluated after restore |
|
// The initializer syntax can't be used just in case a user set this property to a value |
|
restoreGlobalProperties[MSBuildConstants.MSBuildRestoreSessionId] = Guid.NewGuid().ToString("D"); |
|
|
|
// Add a property to indicate that a Restore is executing |
|
restoreGlobalProperties[MSBuildConstants.MSBuildIsRestoring] = bool.TrueString; |
this shows where msbuild passes restore only properties in.
While investigating unnecessary evaluations during restore, I noticed that there are always two evaluations per restore project due to the ExcludeRestorePackageImports property being passed in by NuGet but not by msbuild: https://github.com/NuGet/NuGet.Client/blob/8c9291ef4d12fccdf9b02078a428afeee12a73ae/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L109
Static graph restore seems to already pass it in: https://github.com/NuGet/NuGet.Client/blob/8c9291ef4d12fccdf9b02078a428afeee12a73ae/src/NuGet.Core/NuGet.Build.Tasks/StaticGraphRestoreTaskBase.cs#L333
Let's investigate if passing that additional global property is safe and will avoid the extra unnecessary evaluation.
msbuild/src/MSBuild/XMake.cs
Lines 2059 to 2065 in e2c0a31
While investigating unnecessary evaluations during restore, I noticed that there are always two evaluations per restore project due to the ExcludeRestorePackageImports property being passed in by NuGet but not by msbuild: https://github.com/NuGet/NuGet.Client/blob/8c9291ef4d12fccdf9b02078a428afeee12a73ae/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L109
Static graph restore seems to already pass it in: https://github.com/NuGet/NuGet.Client/blob/8c9291ef4d12fccdf9b02078a428afeee12a73ae/src/NuGet.Core/NuGet.Build.Tasks/StaticGraphRestoreTaskBase.cs#L333
Let's investigate if passing that additional global property is safe and will avoid the extra unnecessary evaluation.