@@ -248,6 +248,7 @@ public static string GetMSBuildArguments(
248
248
249
249
// Override the target under ImportsAfter with the current NuGet.targets version.
250
250
AddProperty ( args , "NuGetRestoreTargets" , entryPointTargetPath ) ;
251
+ AddProperty ( args , "RestoreUseCustomAfterTargets" , bool . TrueString ) ;
251
252
252
253
// Set path to nuget.exe or the build task
253
254
AddProperty ( args , "RestoreTaskAssemblyFile" , nugetExePath ) ;
@@ -259,6 +260,18 @@ public static string GetMSBuildArguments(
259
260
AddPropertyIfHasValue ( args , "RestorePackagesPath" , packagesDirectory ) ;
260
261
AddPropertyIfHasValue ( args , "SolutionDir" , solutionDirectory ) ;
261
262
263
+ // Disable parallel and use ContinueOnError since this may run on an older
264
+ // version of MSBuild that do not support SkipNonexistentTargets.
265
+ // When BuildInParallel is used with ContinueOnError it does not continue in
266
+ // some scenarios.
267
+ // Allow opt in to msbuild 15.5 behavior with NUGET_RESTORE_MSBUILD_USESKIPNONEXISTENT
268
+ var nonExistFlag = Environment . GetEnvironmentVariable ( "NUGET_RESTORE_MSBUILD_USESKIPNONEXISTENT" ) ;
269
+ if ( ! StringComparer . OrdinalIgnoreCase . Equals ( nonExistFlag , bool . TrueString ) )
270
+ {
271
+ AddProperty ( args , "RestoreBuildInParallel" , bool . FalseString ) ;
272
+ AddProperty ( args , "RestoreUseSkipNonexistentTargets" , bool . FalseString ) ;
273
+ }
274
+
262
275
// Add additional args to msbuild if needed
263
276
var msbuildAdditionalArgs = Environment . GetEnvironmentVariable ( "NUGET_RESTORE_MSBUILD_ARGS" ) ;
264
277
0 commit comments