-
Notifications
You must be signed in to change notification settings - Fork 695
/
NuGet.targets
1310 lines (1160 loc) · 57.2 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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
***********************************************************************************************
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>
<!-- Do not hide errors and warnings by default -->
<HideWarningsAndErrors Condition=" '$(HideWarningsAndErrors)' == '' ">false</HideWarningsAndErrors>
<!-- Recurse by default -->
<RestoreRecursive Condition=" '$(RestoreRecursive)' == '' ">true</RestoreRecursive>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<RestoreUseSkipNonexistentTargets Condition=" '$(RestoreUseSkipNonexistentTargets)' == '' ">true</RestoreUseSkipNonexistentTargets>
<!-- RuntimeIdentifier compatibility check -->
<ValidateRuntimeIdentifierCompatibility Condition=" '$(ValidateRuntimeIdentifierCompatibility)' == '' ">false</ValidateRuntimeIdentifierCompatibility>
<!-- Error handling while walking projects -->
<RestoreContinueOnError Condition=" '$(RestoreContinueOnError)' == '' ">WarnAndContinue</RestoreContinueOnError>
<!-- Build in parallel -->
<RestoreBuildInParallel Condition=" '$(BuildInParallel)' != '' ">$(BuildInParallel)</RestoreBuildInParallel>
<RestoreBuildInParallel Condition=" '$(RestoreBuildInParallel)' == '' ">true</RestoreBuildInParallel>
<!-- Check if the restore target was executed on a sln file -->
<_RestoreSolutionFileUsed Condition=" '$(_RestoreSolutionFileUsed)' == '' AND '$(SolutionDir)' != '' AND $(MSBuildProjectFullPath.EndsWith('.metaproj')) == 'true' " >true</_RestoreSolutionFileUsed>
<!-- We default to MSBuildInteractive. -->
<NuGetInteractive Condition=" '$(NuGetInteractive)' == '' ">$(MSBuildInteractive)</NuGetInteractive>
<!-- Mark that this targets file supports package download. -->
<PackageDownloadSupported>true</PackageDownloadSupported>
<!-- Flag if the Central package file is enabled -->
<_CentralPackageVersionsEnabled Condition="'$(ManagePackageVersionsCentrally)' == 'true' AND '$(CentralPackageVersionsFileImported)' == 'true'">true</_CentralPackageVersionsEnabled>
</PropertyGroup>
<PropertyGroup>
<!-- Exclude packages from changing restore inputs. -->
<_GenerateRestoreGraphProjectEntryInputProperties>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);
NuGetRestoreTargets=$(MSBuildThisFileFullPath);
RestoreUseCustomAfterTargets=$(RestoreUseCustomAfterTargets);
CustomAfterMicrosoftCommonCrossTargetingTargets=$(MSBuildThisFileFullPath);
CustomAfterMicrosoftCommonTargets=$(MSBuildThisFileFullPath);
</_GenerateRestoreGraphProjectEntryInputProperties>
<!-- Include SolutionDir and SolutionName for solution restores and persist these properties during the walk. -->
<_GenerateRestoreGraphProjectEntryInputProperties Condition=" '$(_RestoreSolutionFileUsed)' == 'true' ">
$(_GenerateRestoreGraphProjectEntryInputProperties);
_RestoreSolutionFileUsed=true;
SolutionDir=$(SolutionDir);
SolutionName=$(SolutionName);
SolutionFileName=$(SolutionFileName);
SolutionPath=$(SolutionPath);
SolutionExt=$(SolutionExt);
</_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.GetCentralPackageVersionsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestorePackageDownloadsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreFrameworkReferencesTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreDotnetCliToolsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetProjectTargetFrameworksTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreSolutionProjectsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreSettingsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.WarnForInvalidProjectsTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetReferenceNearestTargetFrameworkTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.GetRestoreProjectStyleTask" AssemblyFile="$(RestoreTaskAssemblyFile)" />
<UsingTask TaskName="NuGet.Build.Tasks.NuGetMessageTask" 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)"
RestoreDisableParallel="$(RestoreDisableParallel)"
RestoreNoCache="$(RestoreNoCache)"
RestoreIgnoreFailedSources="$(RestoreIgnoreFailedSources)"
RestoreRecursive="$(RestoreRecursive)"
RestoreForce="$(RestoreForce)"
HideWarningsAndErrors="$(HideWarningsAndErrors)"
Interactive="$(NuGetInteractive)"
RestoreForceEvaluate="$(RestoreForceEvaluate)"
RestorePackagesConfig="$(RestorePackagesConfig)"/>
</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>
<!--
============================================================
CollectPackageReferences
Gathers all PackageReference items from the project.
This target may be used as an extension point to modify
package references before NuGet reads them.
============================================================
-->
<Target Name="CollectPackageReferences" Returns="@(PackageReference)" />
<!--
============================================================
CollectCentralPackageVersions
Gathers all PackageVersion items from the central package versions file.
============================================================
-->
<Target Name="CollectCentralPackageVersions" Returns="@(PackageVersion)" />
<!--
============================================================
CollectPackageDownloads
Gathers all PackageDownload items from the project.
This target may be used as an extension point to modify
package downloads before NuGet reads them.
============================================================
-->
<Target Name="CollectPackageDownloads" Returns="@(PackageDownload)" />
<!--
============================================================
CollectFrameworkReferences
============================================================
-->
<Target Name="CollectFrameworkReferences" Returns="@(FrameworkReference)" />
<!--
============================================================
_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>
<!-- Project case -->
<ItemGroup Condition=" $(MSBuildProjectFullPath.EndsWith('.metaproj')) != 'true' AND @(RestoreGraphProjectInputItems) == '' ">
<RestoreGraphProjectInputItems Include="$(MSBuildProjectFullPath)" />
</ItemGroup>
<!-- Solution case -->
<GetRestoreSolutionProjectsTask
Condition=" $(MSBuildProjectFullPath.EndsWith('.metaproj')) == 'true' AND @(RestoreGraphProjectInputItems) == '' "
ProjectReferences="@(ProjectReference)"
SolutionFilePath="$(MSBuildProjectFullPath)">
<Output
TaskParameter="OutputProjectReferences"
ItemName="RestoreGraphProjectInputItems" />
</GetRestoreSolutionProjectsTask>
</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' ">
<_FilteredRestoreGraphProjectInputItemsTmp
Include="@(RestoreGraphProjectInputItems)"
Condition=" '%(RestoreGraphProjectInputItems.Extension)' == '.csproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.vbproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.fsproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.nuproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.proj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.msbuildproj' Or
'%(RestoreGraphProjectInputItems.Extension)' == '.vcxproj' " />
</ItemGroup>
<!-- Filter out disallowed types -->
<ItemGroup Condition=" '$(RestoreProjectFilterMode)' == 'exclusionlist' ">
<_FilteredRestoreGraphProjectInputItemsTmp
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' ">
<_FilteredRestoreGraphProjectInputItemsTmp
Include="@(RestoreGraphProjectInputItems)" />
</ItemGroup>
<!-- Remove duplicates -->
<RemoveDuplicates
Inputs="@(_FilteredRestoreGraphProjectInputItemsTmp)">
<Output
TaskParameter="Filtered"
ItemName="FilteredRestoreGraphProjectInputItemsWithoutDuplicates" />
</RemoveDuplicates>
<!-- Remove projects that do not support restore. -->
<!-- With SkipNonexistentTargets support -->
<MsBuild Condition=" '$(RestoreUseSkipNonexistentTargets)' == 'true' "
BuildInParallel="$(RestoreBuildInParallel)"
Projects="@(FilteredRestoreGraphProjectInputItemsWithoutDuplicates)"
Targets="_IsProjectRestoreSupported"
SkipNonexistentTargets="true"
Properties="$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="FilteredRestoreGraphProjectInputItems" />
</MsBuild>
<!-- Without SkipNonexistentTargets support -->
<MsBuild Condition=" '$(RestoreUseSkipNonexistentTargets)' != 'true' "
Projects="@(FilteredRestoreGraphProjectInputItemsWithoutDuplicates)"
Targets="_IsProjectRestoreSupported"
ContinueOnError="$(RestoreContinueOnError)"
Properties="$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="FilteredRestoreGraphProjectInputItems" />
</MsBuild>
<!-- Warn for projects that do not support restore. -->
<WarnForInvalidProjectsTask
Condition=" '$(DisableWarnForInvalidRestoreProjects)' != 'true' AND '$(HideWarningsAndErrors)' != 'true' "
AllProjects="@(FilteredRestoreGraphProjectInputItemsWithoutDuplicates)"
ValidProjects="@(FilteredRestoreGraphProjectInputItems)" />
</Target>
<!--
============================================================
_GenerateRestoreGraph
Entry point for creating the project to project restore graph.
============================================================
-->
<Target Name="_GenerateRestoreGraph"
DependsOnTargets="_FilterRestoreGraphProjectInputItems;_GetAllRestoreProjectPathItems"
Returns="@(_RestoreGraphEntry)">
<Message Text="Generating dg file" Importance="low" />
<Message Text="%(_RestoreProjectPathItems.Identity)" Importance="low" />
<!-- Use all projects if RestoreRecursive is true. Otherwise use only the top level projects. -->
<ItemGroup>
<_GenerateRestoreGraphProjectEntryInput Include="@(FilteredRestoreGraphProjectInputItems)" Condition=" '$(RestoreRecursive)' != 'true' " />
<_GenerateRestoreGraphProjectEntryInput Include="@(_RestoreProjectPathItems)" Condition=" '$(RestoreRecursive)' == 'true' " />
</ItemGroup>
<!-- Add top level entries to the direct restore list. These projects will also restore tools. -->
<MsBuild
BuildInParallel="$(RestoreBuildInParallel)"
Projects="@(_GenerateRestoreGraphProjectEntryInput)"
Targets="_GenerateRestoreGraphProjectEntry"
Properties="$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MsBuild>
<!-- Generate a spec for every project including dependencies. -->
<MsBuild
BuildInParallel="$(RestoreBuildInParallel)"
Projects="@(_RestoreProjectPathItems)"
Targets="_GenerateProjectRestoreGraph"
Properties="$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MsBuild>
</Target>
<!--
============================================================
_GenerateRestoreGraphProjectEntry
Top level entry point within a project.
============================================================
-->
<Target Name="_GenerateRestoreGraphProjectEntry"
DependsOnTargets="_GenerateRestoreSpecs;_GenerateDotnetCliToolReferenceSpecs"
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"
DependsOnTargets="_GetRestoreSettings"
Returns="@(_RestoreGraphEntry)">
<PropertyGroup>
<DotnetCliToolTargetFramework Condition=" '$(DotnetCliToolTargetFramework)' == '' ">netcoreapp1.0</DotnetCliToolTargetFramework>
</PropertyGroup>
<!-- Write out tool references -->
<GetRestoreDotnetCliToolsTask
Condition=" '$(RestoreDotnetCliToolReferences)' == '' OR '$(RestoreDotnetCliToolReferences)' == 'true' "
ProjectPath="$(MSBuildProjectFullPath)"
ToolFramework="$(DotnetCliToolTargetFramework)"
RestorePackagesPath="$(_OutputPackagesPath)"
RestoreFallbackFolders="$(_OutputFallbackFolders)"
RestoreSources="$(_OutputSources)"
RestoreConfigFilePaths="$(_OutputConfigFilePaths)"
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;CollectPackageReferences"
Returns="$(RestoreProjectStyle);$(PackageReferenceCompatibleProjectStyle)">
<!--
Older versions of MSBuild do not support the Count() item function which is an optimization. Expanding the
entire item list into a semicolon delimited string is slower but older versions of MSBuild don't support it so
use the older logic if necessary
-->
<PropertyGroup Condition="'$(MSBuildAssemblyVersion)' < '15.0'">
<_HasPackageReferenceItems Condition="'@(PackageReference)' != ''">true</_HasPackageReferenceItems>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildAssemblyVersion)' >= '15.0'">
<_HasPackageReferenceItems Condition="@(PackageReference->Count()) > 0">true</_HasPackageReferenceItems>
</PropertyGroup>
<GetRestoreProjectStyleTask
HasPackageReferenceItems="$(_HasPackageReferenceItems)"
MSBuildProjectDirectory="$(MSBuildProjectDirectory)"
MSBuildProjectName="$(MSBuildProjectName)"
ProjectJsonPath="$(_CurrentProjectJsonPath)"
RestoreProjectStyle="$(RestoreProjectStyle)">
<Output TaskParameter="ProjectStyle" PropertyName="RestoreProjectStyle" />
<Output TaskParameter="IsPackageReferenceCompatibleProjectStyle" PropertyName="PackageReferenceCompatibleProjectStyle" />
</GetRestoreProjectStyleTask>
<PropertyGroup>
<_HasPackageReferenceItems />
</PropertyGroup>
</Target>
<!--
============================================================
EnableIntermediateOutputPathMismatchWarning
If using PackageReference, enable an MSBuild warning if BaseIntermediateOutputPath is set to something different
than MSBuildProjectExtensionsPath, because it may be unexpected that the assets and related files wouldn't be written
to the BaseIntermediateOutputPath.
============================================================
-->
<Target Name="EnableIntermediateOutputPathMismatchWarning" DependsOnTargets="_GetRestoreProjectStyle"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(RestoreProjectStyle)' == 'PackageReference'">
<PropertyGroup Condition="'$(EnableBaseIntermediateOutputPathMismatchWarning)' == ''">
<EnableBaseIntermediateOutputPathMismatchWarning>true</EnableBaseIntermediateOutputPathMismatchWarning>
</PropertyGroup>
</Target>
<!--
============================================================
_GetRestoreTargetFrameworksOutput
Read target frameworks from the project.
Non-NETCore project frameworks will be returned.
============================================================
-->
<Target Name="_GetRestoreTargetFrameworksOutput"
DependsOnTargets="_GetRestoreProjectStyle"
Returns="@(_RestoreTargetFrameworksOutputFiltered)">
<PropertyGroup>
<_RestoreProjectFramework></_RestoreProjectFramework>
</PropertyGroup>
<!-- For project.json projects target frameworks will be read from project.json. -->
<GetProjectTargetFrameworksTask
Condition=" '$(RestoreProjectStyle)' != 'ProjectJson' "
ProjectPath="$(MSBuildProjectFullPath)"
TargetFrameworks="$(TargetFrameworks)"
TargetFramework="$(TargetFramework)"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
TargetPlatformIdentifier="$(TargetPlatformIdentifier)"
TargetPlatformVersion="$(TargetPlatformVersion)"
TargetPlatformMinVersion="$(TargetPlatformMinVersion)">
<Output
TaskParameter="ProjectTargetFrameworks"
PropertyName="_RestoreProjectFramework" />
</GetProjectTargetFrameworksTask>
<ItemGroup Condition=" '$(_RestoreProjectFramework)' != '' ">
<_RestoreTargetFrameworksOutputFiltered Include="$(_RestoreProjectFramework.Split(';'))" />
</ItemGroup>
</Target>
<!--
============================================================
_GetRestoreTargetFrameworksAsItems
Read $(TargetFrameworks) from the project as items.
Projects that do not have $(TargetFrameworks) will noop.
============================================================
-->
<Target Name="_GetRestoreTargetFrameworksAsItems"
DependsOnTargets="_GetRestoreProjectStyle"
Returns="@(_RestoreTargetFrameworkItems)">
<ItemGroup Condition=" '$(TargetFrameworks)' != '' ">
<_RestoreTargetFrameworkItems Include="$(TargetFrameworks.Split(';'))" />
</ItemGroup>
</Target>
<!--
============================================================
_GetRestoreSettings
============================================================
-->
<Target Name="_GetRestoreSettings"
Condition=" '$(RestoreProjectStyle)' == 'PackageReference' OR '$(RestoreProjectStyle)' == 'ProjectJson' OR '$(RestoreProjectStyle)' == 'DotnetToolReference' OR '$(RestoreProjectStyle)' == 'PackagesConfig'"
DependsOnTargets="_GetRestoreSettingsOverrides;_GetRestoreSettingsCurrentProject;_GetRestoreSettingsAllFrameworks"
Returns="$(_OutputSources);$(_OutputPackagesPath);$(_OutputRepositoryPath);$(_OutputFallbackFolders);$(_OutputConfigFilePaths)">
<PropertyGroup Condition=" '$(RestoreSolutionDirectory)' == '' AND '$(RestoreProjectStyle)' == 'PackagesConfig' AND '$(SolutionDir)' != '*Undefined*'">
<RestoreSolutionDirectory>$(SolutionDir)</RestoreSolutionDirectory>
</PropertyGroup>
<!-- For transitive project styles, we rely on evaluating all the settings and including them in the dg spec to faciliate no-op restore-->
<GetRestoreSettingsTask
ProjectUniqueName="$(MSBuildProjectFullPath)"
RestoreSources="$(RestoreSources)"
RestorePackagesPath="$(RestorePackagesPath)"
RestoreRepositoryPath="$(RestoreRepositoryPath)"
RestoreFallbackFolders="$(RestoreFallbackFolders)"
RestoreConfigFile="$(RestoreConfigFile)"
RestoreRootConfigDirectory="$(RestoreRootConfigDirectory)"
RestoreSolutionDirectory="$(RestoreSolutionDirectory)"
RestoreSettingsPerFramework="@(_RestoreSettingsPerFramework)"
RestorePackagesPathOverride="$(_RestorePackagesPathOverride)"
RestoreRepositoryPathOverride="$(_RestoreRepositoryPathOverride)"
RestoreSourcesOverride="$(_RestoreSourcesOverride)"
RestoreFallbackFoldersOverride="$(_RestoreFallbackFoldersOverride)"
RestoreProjectStyle="$(RestoreProjectStyle)"
MSBuildStartupDirectory="$(MSBuildStartupDirectory)">
<Output
TaskParameter="OutputSources"
PropertyName="_OutputSources" />
<Output
TaskParameter="OutputPackagesPath"
PropertyName="_OutputPackagesPath" />
<Output
TaskParameter="OutputRepositoryPath"
PropertyName="_OutputRepositoryPath" />
<Output
TaskParameter="OutputFallbackFolders"
PropertyName="_OutputFallbackFolders" />
<Output
TaskParameter="OutputConfigFilePaths"
PropertyName="_OutputConfigFilePaths" />
</GetRestoreSettingsTask>
</Target>
<!--
============================================================
_GetRestoreSettingsCurrentProject
Generate items for a single framework.
============================================================
-->
<Target Name="_GetRestoreSettingsCurrentProject"
Condition=" '$(TargetFrameworks)' == '' AND '$(PackageReferenceCompatibleProjectStyle)' == 'true' "
DependsOnTargets="_GetRestoreSettingsPerFramework"
Returns="@(_RestoreSettingsPerFramework)">
</Target>
<!--
============================================================
_GetRestoreSettingsCurrentProject
Generate items for a single framework.
============================================================
-->
<Target Name="_GetRestoreSettingsAllFrameworks"
Condition=" '$(TargetFrameworks)' != '' AND '$(PackageReferenceCompatibleProjectStyle)' == 'true' "
DependsOnTargets="_GetRestoreTargetFrameworksAsItems;_GetRestoreProjectStyle"
Returns="@(_RestoreSettingsPerFramework)">
<!-- Read additional sources and fallback folders for each framework -->
<MSBuild
BuildInParallel="$(RestoreBuildInParallel)"
Projects="$(MSBuildProjectFullPath)"
Targets="_GetRestoreSettingsPerFramework"
Properties="TargetFramework=%(_RestoreTargetFrameworkItems.Identity);
$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreSettingsPerFramework" />
</MSBuild>
</Target>
<!--
============================================================
_GetRestoreSettingsPerFramework
Generate items with framework specific settings.
============================================================
-->
<Target Name="_GetRestoreSettingsPerFramework"
Returns="@(_RestoreSettingsPerFramework)">
<ItemGroup>
<_RestoreSettingsPerFramework Include="$([System.Guid]::NewGuid())">
<RestoreAdditionalProjectSources>$(RestoreAdditionalProjectSources)</RestoreAdditionalProjectSources>
<RestoreAdditionalProjectFallbackFolders>$(RestoreAdditionalProjectFallbackFolders)</RestoreAdditionalProjectFallbackFolders>
<RestoreAdditionalProjectFallbackFoldersExcludes>$(RestoreAdditionalProjectFallbackFoldersExcludes)</RestoreAdditionalProjectFallbackFoldersExcludes>
</_RestoreSettingsPerFramework>
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreProjectSpec
Generate a restore project spec for the current project.
============================================================
-->
<Target Name="_GenerateRestoreProjectSpec"
DependsOnTargets="_GetRestoreProjectStyle;_GetRestoreTargetFrameworksOutput;_GetRestoreSettings"
Returns="@(_RestoreGraphEntry)">
<!-- Determine the restore output path -->
<PropertyGroup Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' OR '$(RestoreProjectStyle)' == 'ProjectJson' ">
<RestoreOutputPath Condition=" '$(RestoreOutputPath)' == '' " >$(MSBuildProjectExtensionsPath)</RestoreOutputPath>
</PropertyGroup>
<ConvertToAbsolutePath Paths="$(RestoreOutputPath)" Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' OR '$(RestoreProjectStyle)' == 'ProjectJson'">
<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=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(AssemblyName)' != '' ">$(AssemblyName)</_RestoreProjectName>
<_RestoreProjectName Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' 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=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' ">
<_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=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(TargetFrameworks)' != '' ">
<_RestoreCrossTargeting>true</_RestoreCrossTargeting>
</PropertyGroup>
<!-- Determine if ContentFiles should be written by NuGet -->
<PropertyGroup Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(_RestoreSkipContentFileWrite)' == '' ">
<_RestoreSkipContentFileWrite Condition=" '$(TargetFrameworks)' == '' AND '$(TargetFramework)' == '' ">true</_RestoreSkipContentFileWrite>
</PropertyGroup>
<!-- Write properties for the top level entry point -->
<ItemGroup Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>ProjectSpec</Type>
<Version>$(_RestoreProjectVersion)</Version>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<ProjectName>$(_RestoreProjectName)</ProjectName>
<Sources>$(_OutputSources)</Sources>
<FallbackFolders>$(_OutputFallbackFolders)</FallbackFolders>
<PackagesPath>$(_OutputPackagesPath)</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>
<ConfigFilePaths>$(_OutputConfigFilePaths)</ConfigFilePaths>
<TreatWarningsAsErrors>$(TreatWarningsAsErrors)</TreatWarningsAsErrors>
<WarningsAsErrors>$(WarningsAsErrors)</WarningsAsErrors>
<NoWarn>$(NoWarn)</NoWarn>
<RestorePackagesWithLockFile>$(RestorePackagesWithLockFile)</RestorePackagesWithLockFile>
<NuGetLockFilePath>$(NuGetLockFilePath)</NuGetLockFilePath>
<RestoreLockedMode>$(RestoreLockedMode)</RestoreLockedMode>
<_CentralPackageVersionsEnabled>$(_CentralPackageVersionsEnabled)</_CentralPackageVersionsEnabled>
</_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>$(_OutputSources)</Sources>
<OutputPath>$(RestoreOutputAbsolutePath)</OutputPath>
<FallbackFolders>$(_OutputFallbackFolders)</FallbackFolders>
<PackagesPath>$(_OutputPackagesPath)</PackagesPath>
<ProjectJsonPath>$(_CurrentProjectJsonPath)</ProjectJsonPath>
<ProjectStyle>$(RestoreProjectStyle)</ProjectStyle>
<ConfigFilePaths>$(_OutputConfigFilePaths)</ConfigFilePaths>
</_RestoreGraphEntry>
</ItemGroup>
<!-- Use packages.config -->
<ItemGroup Condition=" '$(RestoreProjectStyle)' == 'PackagesConfig' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>ProjectSpec</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<ProjectPath>$(MSBuildProjectFullPath)</ProjectPath>
<ProjectName>$(_RestoreProjectName)</ProjectName>
<ProjectStyle>$(RestoreProjectStyle)</ProjectStyle>
<TargetFrameworks>@(_RestoreTargetFrameworksOutputFiltered)</TargetFrameworks>
<PackagesConfigPath Condition="Exists('$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config')">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesConfigPath>
<PackagesConfigPath Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfigPath>
<RestorePackagesWithLockFile>$(RestorePackagesWithLockFile)</RestorePackagesWithLockFile>
<NuGetLockFilePath>$(NuGetLockFilePath)</NuGetLockFilePath>
<RestoreLockedMode>$(RestoreLockedMode)</RestoreLockedMode>
<Sources>$(_OutputSources)</Sources>
<SolutionDir>$(SolutionDir)</SolutionDir>
<RepositoryPath>$(_OutputRepositoryPath)</RepositoryPath>
<ConfigFilePaths>$(_OutputConfigFilePaths)</ConfigFilePaths>
<PackagesPath>$(_OutputPackagesPath)</PackagesPath>
</_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>
<!--
============================================================
_GenerateProjectRestoreGraph
Recursively walk project to project references.
============================================================
-->
<Target Name="_GenerateProjectRestoreGraph"
DependsOnTargets="
_GetRestoreProjectStyle;
_GetRestoreTargetFrameworksOutput;
_GenerateRestoreProjectSpec;
_GenerateRestoreDependencies"
Returns="@(_RestoreGraphEntry)">
<!-- Output from dependency targets -->
</Target>
<!--
============================================================
_GenerateRestoreDependencies
Generate items for package and project references.
============================================================
-->
<Target Name="_GenerateRestoreDependencies"
DependsOnTargets="_GenerateProjectRestoreGraphAllFrameworks;_GenerateProjectRestoreGraphCurrentProject"
Returns="@(_RestoreGraphEntry)">
</Target>
<!--
============================================================
_GenerateProjectRestoreGraphAllFrameworks
Walk dependencies for all frameworks.
============================================================
-->
<Target Name="_GenerateProjectRestoreGraphAllFrameworks"
Condition=" '$(TargetFrameworks)' != '' "
DependsOnTargets="_GetRestoreTargetFrameworksAsItems"
Returns="@(_RestoreGraphEntry)">
<!-- Get project and package references -->
<!-- Evaluate for each framework -->
<MSBuild
BuildInParallel="$(RestoreBuildInParallel)"
Projects="$(MSBuildProjectFullPath)"
Targets="_GenerateProjectRestoreGraphPerFramework"
Properties="TargetFramework=%(_RestoreTargetFrameworkItems.Identity);
$(_GenerateRestoreGraphProjectEntryInputProperties)">
<Output
TaskParameter="TargetOutputs"
ItemName="_RestoreGraphEntry" />
</MSBuild>
</Target>
<!--
============================================================
_GenerateProjectRestoreGraphCurrentProject
Walk dependencies with the current framework.
============================================================
-->
<Target Name="_GenerateProjectRestoreGraphCurrentProject"
Condition=" '$(TargetFrameworks)' == '' "
DependsOnTargets="_GenerateProjectRestoreGraphPerFramework"
Returns="@(_RestoreGraphEntry)">
</Target>
<!--
============================================================
_GenerateProjectRestoreGraphPerFramework
Walk dependencies using $(TargetFramework)
============================================================
-->
<Target Name="_GenerateProjectRestoreGraphPerFramework"
DependsOnTargets="_GetRestoreProjectStyle;CollectPackageReferences;CollectPackageDownloads;CollectFrameworkReferences;CollectCentralPackageVersions"
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-->
<GetRestorePackageReferencesTask
Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' "
ProjectUniqueName="$(MSBuildProjectFullPath)"
PackageReferences="@(PackageReference)"
TargetFrameworks="$(TargetFramework)"
>
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestorePackageReferencesTask>
<!-- Write out central package versions -->
<GetCentralPackageVersionsTask
Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(_CentralPackageVersionsEnabled)' == 'true' "
ProjectUniqueName="$(MSBuildProjectFullPath)"
CentralPackageVersions="@(PackageVersion)"
TargetFrameworks="$(TargetFramework)"
>
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetCentralPackageVersionsTask>
<!-- Write out package downloads -->
<GetRestorePackageDownloadsTask
Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' "
ProjectUniqueName="$(MSBuildProjectFullPath)"
PackageDownloads="@(PackageDownload)"
TargetFrameworks="$(TargetFramework)"
>
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestorePackageDownloadsTask>
<!-- Write out Framework References-->
<GetRestoreFrameworkReferencesTask
Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' "
ProjectUniqueName="$(MSBuildProjectFullPath)"
FrameworkReferences="@(FrameworkReference)"
TargetFrameworks="$(TargetFramework)"
>
<Output
TaskParameter="RestoreGraphItems"
ItemName="_RestoreGraphEntry" />
</GetRestoreFrameworkReferencesTask>
<!-- Write out the TargetFramework specific properties -->
<ItemGroup Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(RuntimeIdentifierGraphPath)' != '' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>TargetFrameworkProperties</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<TargetFramework>$(TargetFramework)</TargetFramework>
<RuntimeIdentifierGraphPath>$(RuntimeIdentifierGraphPath)</RuntimeIdentifierGraphPath>
</_RestoreGraphEntry>
</ItemGroup>
<PropertyGroup>
<_CombinedFallbacks>$(PackageTargetFallback);$(AssetTargetFallback)</_CombinedFallbacks>
</PropertyGroup>
<!-- Write out target framework information -->
<ItemGroup Condition=" '$(PackageReferenceCompatibleProjectStyle)' == 'true' AND '$(_CombinedFallbacks)' != '' ">
<_RestoreGraphEntry Include="$([System.Guid]::NewGuid())">
<Type>TargetFrameworkInformation</Type>
<ProjectUniqueName>$(MSBuildProjectFullPath)</ProjectUniqueName>
<PackageTargetFallback>$(PackageTargetFallback)</PackageTargetFallback>
<AssetTargetFallback>$(AssetTargetFallback)</AssetTargetFallback>
<TargetFramework>$(TargetFramework)</TargetFramework>
</_RestoreGraphEntry>
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreProjectPathItemsCurrentProject
Get absolute paths for all project references.
============================================================
-->
<Target Name="_GenerateRestoreProjectPathItemsCurrentProject"
Condition=" '$(TargetFrameworks)' == '' "
DependsOnTargets="_GenerateRestoreProjectPathItemsPerFramework"
Returns="@(_RestoreProjectPathItems)">
</Target>
<!--
============================================================
_GenerateRestoreProjectPathItemsPerFramework
Get absolute paths for all project references.
============================================================
-->
<Target Name="_GenerateRestoreProjectPathItemsPerFramework"
Returns="@(_RestoreProjectPathItems)">
<!-- Get the absolute paths to all projects -->
<ConvertToAbsolutePath Paths="@(ProjectReference)">
<Output TaskParameter="AbsolutePaths" PropertyName="_RestoreGraphAbsoluteProjectPaths" />
</ConvertToAbsolutePath>
<ItemGroup>
<_RestoreProjectPathItems Include="$(_RestoreGraphAbsoluteProjectPaths)" />
</ItemGroup>
</Target>
<!--
============================================================
_GenerateRestoreProjectPathItems
Get all project references regardless of framework
============================================================
-->
<Target Name="_GenerateRestoreProjectPathItems"
DependsOnTargets="_GenerateRestoreProjectPathItemsAllFrameworks;_GenerateRestoreProjectPathItemsCurrentProject"
Returns="@(_CurrentRestoreProjectPathItems)">
<!-- Drop any duplicate items -->
<RemoveDuplicates
Inputs="@(_RestoreProjectPathItems)">
<Output
TaskParameter="Filtered"
ItemName="_CurrentRestoreProjectPathItems" />
</RemoveDuplicates>
</Target>
<!--