@@ -113,7 +113,7 @@ Task("UpdateNuGet")
113113
114114//-------------------------------------------------------------
115115
116- Task ( "RestorePackages " )
116+ Task ( "RestorePackagesForBuild " )
117117 . IsDependentOn ( "Prepare" )
118118 . IsDependentOn ( "UpdateNuGet" )
119119 . ContinueOnError ( )
@@ -179,6 +179,94 @@ Task("RestorePackages")
179179
180180//-------------------------------------------------------------
181181
182+ Task ( "RestorePackagesForPackage" )
183+ . IsDependentOn ( "Prepare" )
184+ . IsDependentOn ( "UpdateNuGet" )
185+ . ContinueOnError ( )
186+ . Does < BuildContext > ( buildContext =>
187+ {
188+ if ( buildContext . General . IsLocalBuild && buildContext . General . MaximizePerformance )
189+ {
190+ Information ( "Local build with maximized performance detected, skipping package restore" ) ;
191+ return ;
192+ }
193+
194+ var csharpProjects = new List < FilePath > ( ) ;
195+
196+ foreach ( var project in buildContext . AllProjects )
197+ {
198+ if ( ! ShouldPackageProject ( buildContext , project ) ||
199+ IsTestProject ( buildContext , project ) )
200+ {
201+ continue ;
202+ }
203+
204+ var projectFileName = GetProjectFileName ( buildContext , project ) ;
205+ if ( projectFileName . EndsWith ( ".csproj" ) )
206+ {
207+ Information ( "Adding '{0}' as C# specific project to restore" , project ) ;
208+
209+ csharpProjects . Add ( projectFileName ) ;
210+ }
211+ }
212+
213+ var allFiles = new List < FilePath > ( ) ;
214+ allFiles . AddRange ( csharpProjects ) ;
215+
216+ Information ( $ "Found '{ allFiles . Count } ' projects to restore") ;
217+
218+ foreach ( var file in allFiles )
219+ {
220+ RestoreNuGetPackages ( buildContext , file ) ;
221+ }
222+ } ) ;
223+
224+ //-------------------------------------------------------------
225+
226+ Task ( "RestorePackagesForDeploy" )
227+ . IsDependentOn ( "Prepare" )
228+ . IsDependentOn ( "UpdateNuGet" )
229+ . ContinueOnError ( )
230+ . Does < BuildContext > ( buildContext =>
231+ {
232+ if ( buildContext . General . IsLocalBuild && buildContext . General . MaximizePerformance )
233+ {
234+ Information ( "Local build with maximized performance detected, skipping package restore" ) ;
235+ return ;
236+ }
237+
238+ var csharpProjects = new List < FilePath > ( ) ;
239+
240+ foreach ( var project in buildContext . AllProjects )
241+ {
242+ if ( ! ShouldDeployProject ( buildContext , project ) ||
243+ IsTestProject ( buildContext , project ) )
244+ {
245+ continue ;
246+ }
247+
248+ var projectFileName = GetProjectFileName ( buildContext , project ) ;
249+ if ( projectFileName . EndsWith ( ".csproj" ) )
250+ {
251+ Information ( "Adding '{0}' as C# specific project to restore" , project ) ;
252+
253+ csharpProjects . Add ( projectFileName ) ;
254+ }
255+ }
256+
257+ var allFiles = new List < FilePath > ( ) ;
258+ allFiles . AddRange ( csharpProjects ) ;
259+
260+ Information ( $ "Found '{ allFiles . Count } ' projects to restore") ;
261+
262+ foreach ( var file in allFiles )
263+ {
264+ RestoreNuGetPackages ( buildContext , file ) ;
265+ }
266+ } ) ;
267+
268+ //-------------------------------------------------------------
269+
182270// Note: it might look weird that this is dependent on restore packages,
183271// but to clean, the msbuild projects must be able to load. However, they need
184272// some targets files that come in via packages
0 commit comments