-
Notifications
You must be signed in to change notification settings - Fork 695
/
NuGet.targets
627 lines (557 loc) · 28.1 KB
/
NuGet.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<!--
***********************************************************************************************
NuGet.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
This target file contains the NuGet Restore target for walking the project and reference graph
and restoring dependencies from the graph.
Ways to use this targets file:
1. Invoke it directly and provide project file paths using $(RestoreGraphProjectInput).
2. With a solution this may be used as a target in the metaproj.
3. Import the targets file from a project.
Restore flow summary:
1. Top level projects (entry points) are determined.
2. Each project and all of its project references are walked recursively.
3. The project is evaluated for each $(TargetFramework). Items are created
for project properties and dependencies. Each item is marked
with the project it came from so that it can be matched up later.
4. All restore items generated by the walk are grouped together by
project and convert into a project spec.
The result file contains:
1. A list of projects to restore.
2. The complete closure of all projects referenced (Includes project references that are not being restored directly).
3. Package and project dependencies for each project.
4. DotnetCliTool references
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Mark that this target file has been loaded. -->
<IsRestoreTargetsFileLoaded>true</IsRestoreTargetsFileLoaded>
<!-- Load NuGet.Build.Tasks.dll, this can be overridden to use a different version with $(RestoreTaskAssemblyFile) -->
<RestoreTaskAssemblyFile Condition=" '$(RestoreTaskAssemblyFile)' == '' ">NuGet.Build.Tasks.dll</RestoreTaskAssemblyFile>
<!-- Recurse by default -->
<RestoreRecursive Condition=" '$(RestoreRecursive)' == '' ">true</RestoreRecursive>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<!-- RuntimeIdentifier compatibility check -->
<ValidateRuntimeIdentifierCompatibility Condition=" '$(ValidateRuntimeIdentifierCompatibility)' == '' ">false</ValidateRuntimeIdentifierCompatibility>
<!-- Error handling while walking projects -->
<RestoreContinueOnError Condition=" '$(RestoreContinueOnError)' == '' ">WarnAndContinue</RestoreContinueOnError>
</PropertyGroup>
<PropertyGroup>
<!-- Generate a restore graph for each entry point project. -->
<_GenerateRestoreGraphProjectEntryInputProperties>
RestoreUseCustomAfterTargets=$(RestoreUseCustomAfterTargets);
NuGetRestoreTargets=$(MSBuildThisFileFullPath);
BuildProjectReferences=false;
ExcludeRestorePackageImports=true;
</_GenerateRestoreGraphProjectEntryInputProperties>
<!-- Standalone mode
This is used by NuGet.exe to inject targets into the project that will be
walked next. In normal /t:Restore mode this causes a duplicate import
since NuGet.targets it loaded as part of MSBuild, there is should be
skipped. -->
<_GenerateRestoreGraphProjectEntryInputProperties Condition=" '$(RestoreUseCustomAfterTargets)' == 'true' ">
$(_GenerateRestoreGraphProjectEntryInputProperties);
CustomAfterMicrosoftCommonCrossTargetingTargets=$(MSBuildThisFileFullPath);
CustomAfterMicrosoftCommonTargets=$(MSBuildThisFileFullPath);
</_GenerateRestoreGraphProjectEntryInputProperties>
</PropertyGroup>
<!-- Tasks -->
<UsingTask TaskName="NuGet.Build.Tasks.RestoreTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.WriteRestoreGraphTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreProjectJsonPathTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreProjectReferencesTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestorePackageReferencesTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreDotnetCliToolsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreProjectFrameworks" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<!--
============================================================
Restore
Main entry point for restoring packages
============================================================
-->
<Target Name="Restore" DependsOnTargets="_GenerateRestoreGraph">
<!-- Drop any duplicate items -->
<RemoveDuplicates
Inputs="@(_RestoreGraphEntry)">
<Output
TaskParameter="Filtered"
ItemName="_RestoreGraphEntryFiltered" />
</RemoveDuplicates>
<!-- Call restore -->
<RestoreTask
RestoreGraphItems="@(_RestoreGraphEntryFiltered)"
RestoreSources="$(RestoreSources)"
RestorePackagesPath="$(RestorePackagesPath)"
RestoreDisableParallel="$(RestoreDisableParallel)"
RestoreConfigFile="$(RestoreConfigFile)"
RestoreNoCache="$(RestoreNoCache)"
RestoreIgnoreFailedSources="$(RestoreIgnoreFailedSources)"
RestoreRecursive="$(RestoreRecursive)" />
</Target>
<!--
============================================================
GenerateRestoreGraphFile
Writes the output of _GenerateRestoreGraph to disk
============================================================
-->
<Target Name="GenerateRestoreGraphFile" DependsOnTargets="_GenerateRestoreGraph">
<!-- Validate -->
<Error Condition="$(RestoreGraphOutputPath) == ''" Text="Missing RestoreGraphOutputPath property!" />
<!-- Drop any duplicate items -->
<RemoveDuplicates
Inputs="@(_RestoreGraphEntry)">
<Output
TaskParameter="Filtered"
ItemName="_RestoreGraphEntryFiltered" />
</RemoveDuplicates>
<!-- Write file -->
<WriteRestoreGraphTask
RestoreGraphItems="@(_RestoreGraphEntryFiltered)"
RestoreGraphOutputPath="$(RestoreGraphOutputPath)"
RestoreRecursive="$(RestoreRecursive)" />
</Target>
<!--
============================================================
_LoadRestoreGraphEntryPoints
Find project entry points and load them into items.
============================================================
-->
<Target Name="_LoadRestoreGraphEntryPoints" Returns="@(RestoreGraphProjectInputItems)">
<!-- Allow overriding items with RestoreGraphProjectInput -->
<ItemGroup Condition=" @(RestoreGraphProjectInputItems) == '' ">
<RestoreGraphProjectInputItems Include="$(RestoreGraphProjectInput)" />
</ItemGroup>
<!-- Solution case -->
<ItemGroup Condition=" $(MSBuildProjectFullPath.EndsWith('.metaproj')) == 'true' AND @(RestoreGraphProjectInputItems) == '' ">
<RestoreGraphProjectInputItems Include="@(ProjectReference)" />
</ItemGroup>
<!-- Project case -->
<ItemGroup Condition=" $(MSBuildProjectFullPath.EndsWith('.metaproj')) != 'true' AND @(RestoreGraphProjectInputItems) == '' ">
<RestoreGraphProjectInputItems Include="$(MSBuildProjectFullPath)" />
</ItemGroup>
</Target>
<!--
============================================================
_FilterRestoreGraphProjectInputItems"
Filter out unsupported project entry points.
============================================================
-->
<Target Name="_FilterRestoreGraphProjectInputItems" DependsOnTargets="_LoadRestoreGraphEntryPoints"
Returns="@(FilteredRestoreGraphProjectInputItems)">
<PropertyGroup>
<RestoreProjectFilterMode Condition=" '$(RestoreProjectFilterMode)' == '' ">exclusionlist</RestoreProjectFilterMode>
</PropertyGroup>
<!-- Filter to a list of known supported types -->
<ItemGroup Condition=" '$(RestoreProjectFilterMode)' == 'inclusionlist' ">
<FilteredRestoreGraphProjectInputItems
Include="@(RestoreGraphProjectInputItems)"
Condition=" '%(RestoreGraphProjectInputItems.Extension)' == '.csproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.vbproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.fsproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.nuproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.msbuildproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.vcxproj' " />
</ItemGroup>
<!-- Filter out disallowed types -->
<ItemGroup Condition=" '$(RestoreProjectFilterMode)' == 'exclusionlist' ">
<FilteredRestoreGraphProjectInputItems
Include="@(RestoreGraphProjectInputItems)"
Condition=" '%(RestoreGraphProjectInputItems.Extension)' != '.metaproj'
AND '%(RestoreGraphProjectInputItems.Extension)' != '.shproj'
AND '%(RestoreGraphProjectInputItems.Extension)' != '.vcxitems'
AND '%(RestoreGraphProjectInputItems.Extension)' != '' " />
</ItemGroup>
<!-- No filtering -->
<ItemGroup Condition=" '$(RestoreProjectFilterMode)' != 'exclusionlist' AND '$(RestoreProjectFilterMode)' != 'inclusionlist' ">
<FilteredRestoreGraphProjectInputItems
Include="@(RestoreGraphProjectInputItems)" />
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreGraph
Entry point for creating the project to project restore graph.
============================================================
-->
<Target Name="_GenerateRestoreGraph" DependsOnTargets="_FilterRestoreGraphProjectInputItems">
<Message Text="Generating dg file" Importance="low" />
<Message Text="%(FilteredRestoreGraphProjectInputItems.Identity)" Importance="low" />
<!-- Walk projects -->
<MsBuild
Projects="@(FilteredRestoreGraphProjectInputItems)"
Targets="_GenerateRestoreGraphProjectEntry"
ContinueOnError="$(RestoreContinueOnError)"
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);
%(_MSBuildProjectReferenceExistent.SetPlatform);
$(_GenerateRestoreGraphProjectEntryInputProperties)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MsBuild>
</Target>
<!--
============================================================
_GenerateRestoreGraphProjectEntry
Top level entry point within a project.
============================================================
-->
<Target Name="_GenerateRestoreGraphProjectEntry"
DependsOnTargets="_GenerateRestoreSpecs;_GenerateDotnetCliToolReferenceSpecs;_GenerateRestoreGraphWalk"
Returns="@(_RestoreGraphEntry)">
<!-- Returns restore graph entries for the project and all dependencies -->
</Target>
<!--
============================================================
_GenerateRestoreSpecs
Mark entry points for restore.
============================================================
-->
<Target Name="_GenerateRestoreSpecs"
DependsOnTargets="_GetRestoreProjectStyle"
Returns="@(_RestoreGraphEntry)">
<Message Text="Restore entry point $(MSBuildProjectFullPath)" Importance="low" />
<!-- Mark entry point -->
<ItemGroup Condition=" '$(RestoreProjects)' == '' OR '$(RestoreProjects)' == 'true' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())" Condition=" '$(RestoreProjectStyle)' != 'Unknown' ">
<Type>RestoreSpec</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
</_RestoreGraphEntry>
</ItemGroup>
</Target>
<!--
============================================================
_GenerateDotnetCliToolReferenceSpecs
Collect DotnetCliToolReferences
============================================================
-->
<Target Name="_GenerateDotnetCliToolReferenceSpecs"
Returns="@(_RestoreGraphEntry)">
<PropertyGroup>
<DotnetCliToolTargetFramework Condition=" '$(DotnetCliToolTargetFramework)' == '' ">netcoreapp1.0</DotnetCliToolTargetFramework>
</PropertyGroup>
<!-- Write out tool references -->
<GetRestoreDotnetCliToolsTask
Condition=" '$(RestoreDotnetCliToolReferences)' == '' OR '$(RestoreDotnetCliToolReferences)' == 'true' "
ProjectPath="$(MSBuildProjectFullPath)"
ToolFramework="$(DotnetCliToolTargetFramework)"
DotnetCliToolReferences="@(DotnetCliToolReference)">
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestoreDotnetCliToolsTask>
</Target>
<!--
============================================================
_GetProjectJsonPath
Discover the project.json path if one exists for the project.
============================================================
-->
<Target Name="_GetProjectJsonPath"
Returns="$(_CurrentProjectJsonPath)">
<!-- Get project.json path -->
<!-- Skip this if the project style is already set. -->
<GetRestoreProjectJsonPathTask
ProjectPath="$(MSBuildProjectFullPath)"
Condition=" '$(RestoreProjectStyle)' == 'ProjectJson' OR '$(RestoreProjectStyle)' == '' ">
<Output TaskParameter="ProjectJsonPath" PropertyName="_CurrentProjectJsonPath" />
</GetRestoreProjectJsonPathTask>
</Target>
<!--
============================================================
_GetRestoreProjectStyle
Determine the project restore type.
============================================================
-->
<Target Name="_GetRestoreProjectStyle"
DependsOnTargets="_GetProjectJsonPath"
Returns="$(RestoreProjectStyle)">
<!-- This may be overridden by setting RestoreProjectStyle in the project. -->
<PropertyGroup>
<!-- If any PackageReferences exist treat it as PackageReference. This has priority over project.json. -->
<RestoreProjectStyle Condition=" '$(RestoreProjectStyle)' == '' AND @(PackageReference) != '' ">PackageReference</RestoreProjectStyle>
<!-- If this is not a PackageReference project check if project.json or projectName.project.json exists. -->
<RestoreProjectStyle Condition=" '$(RestoreProjectStyle)' == '' AND '$(_CurrentProjectJsonPath)' != '' ">ProjectJson</RestoreProjectStyle>
<!-- This project is either a packages.config project or one that does not use NuGet at all. -->
<RestoreProjectStyle Condition=" '$(RestoreProjectStyle)' == '' ">Unknown</RestoreProjectStyle>
</PropertyGroup>
</Target>
<!--
============================================================
_GetRestoreTargetFrameworksOutput
Read target frameworks from the project.
============================================================
-->
<Target Name="_GetRestoreTargetFrameworksOutput"
DependsOnTargets="_GetRestoreProjectStyle"
Condition=" '$(RestoreProjectStyle)' != 'ProjectJson' "
Returns="@(_RestoreTargetFrameworksOutputFiltered)">
<PropertyGroup>
<_RestoreProjectFramework></_RestoreProjectFramework>
</PropertyGroup>
<!-- For project.json projects target frameworks will be read from project.json. -->
<GetRestoreProjectFrameworks
ProjectPath="$(MSBuildProjectFullPath)"
TargetFrameworks="$(TargetFrameworks)"
TargetFramework="$(TargetFramework)"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
TargetPlatformIdentifier="$(TargetPlatformIdentifier)"
TargetPlatformVersion="$(TargetPlatformVersion)">
<Output
TaskParameter="ProjectTargetFrameworks"
PropertyName="_RestoreProjectFramework" />
</GetRestoreProjectFrameworks>
<ItemGroup Condition=" '$(_RestoreProjectFramework)' != '' ">
<_RestoreTargetFrameworksOutputFiltered Include="$(_RestoreProjectFramework.Split(';'))" />
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreProjectSpec
Generate a restore project spec for the current project.
============================================================
-->
<Target Name="_GenerateRestoreProjectSpec"
DependsOnTargets="_GetRestoreProjectStyle;_GetRestoreTargetFrameworksOutput"
Returns="@(_RestoreGraphEntry)">
<!-- Determine the restore output path -->
<PropertyGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' ">
<RestoreOutputPath Condition=" '$(RestoreOutputPath)' == '' " >$(BaseIntermediateOutputPath)</RestoreOutputPath>
</PropertyGroup>
<ConvertToAbsolutePath Paths="$(RestoreOutputPath)" Condition=" '$(RestoreProjectStyle)' == 'PackageReference' ">
<Output TaskParameter="AbsolutePaths" PropertyName="RestoreOutputAbsolutePath" />
</ConvertToAbsolutePath>
<!--
Determine project name for the assets file.
Highest priority: PackageId
If PackageId does not exist use: AssemblyName
If AssemblyName does not exist fallback to the project file name without the extension: $(MSBuildProjectName)
For non-NETCore projects use only: $(MSBuildProjectName)
-->
<PropertyGroup>
<_RestoreProjectName>$(MSBuildProjectName)</_RestoreProjectName>
<_RestoreProjectName Condition=" '$(RestoreProjectStyle)' == 'PackageReference' AND '$(AssemblyName)' != '' ">$(AssemblyName)</_RestoreProjectName>
<_RestoreProjectName Condition=" '$(RestoreProjectStyle)' == 'PackageReference' AND '$(PackageId)' != '' ">$(PackageId)</_RestoreProjectName>
</PropertyGroup>
<!--
Determine project version for .NETCore projects
Default to 1.0.0
Use Version if it exists
Override with PackageVersion if it exists (same as pack)
-->
<PropertyGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' ">
<_RestoreProjectVersion>1.0.0</_RestoreProjectVersion>
<_RestoreProjectVersion Condition=" '$(Version)' != '' ">$(Version)</_RestoreProjectVersion>
<_RestoreProjectVersion Condition=" '$(PackageVersion)' != '' ">$(PackageVersion)</_RestoreProjectVersion>
</PropertyGroup>
<!-- Determine if this will use cross targeting -->
<PropertyGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' AND '$(TargetFrameworks)' != '' ">
<_RestoreCrossTargeting>true</_RestoreCrossTargeting>
</PropertyGroup>
<!-- Determine if ContentFiles should be written by NuGet -->
<PropertyGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' AND '$(_RestoreSkipContentFileWrite)' == '' ">
<_RestoreSkipContentFileWrite Condition=" '$(TargetFrameworks)' == '' AND '$(TargetFramework)' == '' ">true</_RestoreSkipContentFileWrite>
</PropertyGroup>
<!-- Write properties for the top level entry point -->
<ItemGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>ProjectSpec</Type>
<Version>$(_RestoreProjectVersion)</Version>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<ProjectName>$(_RestoreProjectName)</ProjectName>
<Sources>$(RestoreSources)</Sources>
<FallbackFolders>$(RestoreFallbackFolders)</FallbackFolders>
<PackagesPath>$(RestorePackagesPath)</PackagesPath>
<ProjectStyle>$(RestoreProjectStyle)</ProjectStyle>
<OutputPath>$(RestoreOutputAbsolutePath)</OutputPath>
<TargetFrameworks>@(_RestoreTargetFrameworksOutputFiltered)</TargetFrameworks>
<RuntimeIdentifiers>$(RuntimeIdentifiers);$(RuntimeIdentifier)</RuntimeIdentifiers>
<RuntimeSupports>$(RuntimeSupports)</RuntimeSupports>
<CrossTargeting>$(_RestoreCrossTargeting)</CrossTargeting>
<RestoreLegacyPackagesDirectory>$(RestoreLegacyPackagesDirectory)</RestoreLegacyPackagesDirectory>
<ValidateRuntimeAssets>$(ValidateRuntimeIdentifierCompatibility)</ValidateRuntimeAssets>
<SkipContentFileWrite>$(_RestoreSkipContentFileWrite)</SkipContentFileWrite>
</_RestoreGraphEntry>
</ItemGroup>
<!-- Use project.json -->
<ItemGroup Condition=" '$(RestoreProjectStyle)' == 'ProjectJson' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>ProjectSpec</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<ProjectName>$(_RestoreProjectName)</ProjectName>
<Sources>$(RestoreSources)</Sources>
<FallbackFolders>$(RestoreFallbackFolders)</FallbackFolders>
<PackagesPath>$(RestorePackagesPath)</PackagesPath>
<FallbackFolders>$(RestoreFallbackFolders)</FallbackFolders>
<ProjectJsonPath>$(_CurrentProjectJsonPath)</ProjectJsonPath>
<ProjectStyle>$(RestoreProjectStyle)</ProjectStyle>
</_RestoreGraphEntry>
</ItemGroup>
<!-- Non-NuGet type -->
<ItemGroup Condition=" '$(RestoreProjectStyle)' == 'Unknown' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>ProjectSpec</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<ProjectName>$(_RestoreProjectName)</ProjectName>
<ProjectStyle>$(RestoreProjectStyle)</ProjectStyle>
<TargetFrameworks>@(_RestoreTargetFrameworksOutputFiltered)</TargetFrameworks>
</_RestoreGraphEntry>
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreDependencies
Generate items for package and project references.
============================================================
-->
<Target Name="_GenerateRestoreDependencies"
DependsOnTargets="_GetRestoreProjectStyle;_GetRestoreTargetFrameworksOutput"
Returns="@(_RestoreGraphEntry)">
<!-- Get project and package references -->
<!-- Evaluate for each framework -->
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="_GenerateRestoreGraphWalkPerFramework"
ContinueOnError="$(RestoreContinueOnError)"
Properties="TargetFramework=%(_RestoreTargetFrameworksOutputFiltered.Identity);
%(_MSBuildProjectReferenceExistent.SetConfiguration);
%(_MSBuildProjectReferenceExistent.SetPlatform);
$(_GenerateRestoreGraphProjectEntryInputProperties)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MSBuild>
</Target>
<!--
============================================================
_GetAllRestoreProjectReferences
Get all project references regardless of framework
============================================================
-->
<Target Name="_GetAllRestoreProjectReferences"
DependsOnTargets="_GetRestoreProjectStyle;_GetRestoreTargetFrameworksOutput"
Returns="@(RestoreGraphProjectFullPathForOutput)">
<!-- Get complete set of project references -->
<MSBuild
Projects="$(MSBuildProjectFullPath)"
Targets="_GenerateRestoreProjectReferencePaths"
ContinueOnError="$(RestoreContinueOnError)"
Properties="TargetFramework=%(_RestoreTargetFrameworksOutputFiltered.Identity);
%(_MSBuildProjectReferenceExistent.SetConfiguration);
%(_MSBuildProjectReferenceExistent.SetPlatform);
$(_GenerateRestoreGraphProjectEntryInputProperties)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
<Output
TaskParameter="TargetOutputs"
ItemName="RestoreGraphProjectFullPathForOutput" />
</MSBuild>
</Target>
<!--
============================================================
_GetChildRestoreProjects
Get all projects for restore.
============================================================
-->
<Target Name="_GetChildRestoreProjects"
DependsOnTargets="_GetRestoreProjectStyle;_GetAllRestoreProjectReferences"
Returns="@(_RestoreGraphEntry)">
<!-- Recurse into referenced projects -->
<MSBuild
Projects="@(RestoreGraphProjectFullPathForOutput)"
Targets="_GenerateRestoreGraphWalk"
ContinueOnError="$(RestoreContinueOnError)"
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);
%(_MSBuildProjectReferenceExistent.SetPlatform);
$(_GenerateRestoreGraphProjectEntryInputProperties)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MSBuild>
</Target>
<!--
============================================================
_GenerateRestoreGraphWalk
Recursively walk project to project references.
============================================================
-->
<Target Name="_GenerateRestoreGraphWalk"
DependsOnTargets="
_GetRestoreProjectStyle;
_GetRestoreTargetFrameworksOutput;
_GenerateRestoreProjectSpec;
_GenerateRestoreDependencies;
_GetChildRestoreProjects"
Returns="@(_RestoreGraphEntry)">
<!-- Output from dependency targets -->
</Target>
<!--
============================================================
_GenerateRestoreGraphWalkPerFramework
Walk dependencies using $(TargetFramework)
============================================================
-->
<Target Name="_GenerateRestoreGraphWalkPerFramework"
DependsOnTargets="_GetRestoreProjectStyle"
Returns="@(_RestoreGraphEntry)">
<!-- Write out project references -->
<GetRestoreProjectReferencesTask
ProjectUniqueName="$(MSBuildProjectFullPath)"
ProjectReferences="@(ProjectReference)"
TargetFrameworks="$(TargetFramework)"
ParentProjectPath="$(MSBuildProjectFullPath)">
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestoreProjectReferencesTask>
<!-- Write out package references for NETCore -->
<GetRestorePackageReferencesTask
Condition=" '$(RestoreProjectStyle)' == 'PackageReference' "
ProjectUniqueName="$(MSBuildProjectFullPath)"
PackageReferences="@(PackageReference)"
TargetFrameworks="$(TargetFramework)">
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestorePackageReferencesTask>
<!-- Write out target framework information -->
<ItemGroup Condition=" '$(RestoreProjectStyle)' == 'PackageReference' AND '$(PackageTargetFallback)' != '' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>TargetFrameworkInformation</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<PackageTargetFallback>$(PackageTargetFallback)</PackageTargetFallback>
<TargetFramework>$(TargetFramework)</TargetFramework>
</_RestoreGraphEntry>
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreProjectReferencePaths
Get absolute paths for all project references.
============================================================
-->
<Target Name="_GenerateRestoreProjectReferencePaths"
DependsOnTargets="_SplitProjectReferencesByFileExistence"
Returns="@(RestoreGraphProjectFullPathForOutput)">
<ItemGroup>
<!-- Filter out project references that specify ReferenceOutputAssembly=false -->
<ValidProjectInputForRestoreGraph Include="@(ProjectReference)"
Condition=" '%(ProjectReference.ReferenceOutputAssembly)' == '' OR '%(ProjectReference.ReferenceOutputAssembly)' == 'true' " />
</ItemGroup>
<!-- Get the absolute paths to all projects -->
<ConvertToAbsolutePath Paths="@(ValidProjectInputForRestoreGraph)">
<Output TaskParameter="AbsolutePaths" PropertyName="RestoreGraphAbsoluteProjectPaths" />
</ConvertToAbsolutePath>
<ItemGroup>
<RestoreGraphProjectFullPathForOutput Include="$(RestoreGraphAbsoluteProjectPaths)" />
</ItemGroup>
</Target>
</Project>