summaryrefslogtreecommitdiff
path: root/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/Packaging.targets
blob: e6c87359f3c3071230709bf20e0519f555d50bf7 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" TreatAsLocalProperty="BuildProjectReferences" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Condition="'$(_PackagingCommonTargetsImported)' != 'true'" Project="Packaging.common.targets"/>

  <!-- The following properties are expected to change as we transition from
       Beta -> RC - RTM. We should set $(IncludeBuildNumberInPackageVersion)
       to false for the Beta/RC builds that get uploaded to NuGet.
  -->
  <PropertyGroup>
    <PackageVersion Condition="'$(StableVersion)' != ''">$(StableVersion)</PackageVersion>
    <PackageVersion Condition="'$(PackageVersion)' == '' AND '$(Version)' != ''">$(Version)</PackageVersion>
    <PreReleaseLabel Condition="'$(PreReleaseLabel)' == ''">rc2</PreReleaseLabel>
    <IncludeBuildNumberInPackageVersion Condition="'$(IncludeBuildNumberInPackageVersion)' == ''">true</IncludeBuildNumberInPackageVersion>

    <VersionSuffix Condition="'$(PreReleaseLabel)' != ''">-$(PreReleaseLabel)</VersionSuffix>
    <VersionSuffix Condition="'$(IncludeBuildNumberInPackageVersion)' == 'true'">$(VersionSuffix)-$(BuildNumberMajor)-$(BuildNumberMinor)</VersionSuffix>

    <!--
      Empty out the project properties because we want configuration and platform to come from the individual
      projects instead of being overridden by the value the packages have.
    -->
    <ProjectProperties></ProjectProperties>

    <BaseLinePackageDependencies Condition="'$(BaseLinePackageDependencies)' == ''">true</BaseLinePackageDependencies>
    <ApplyMetaPackages Condition="'$(ApplyMetaPackages)' == ''">true</ApplyMetaPackages>

    <!-- By default we'll build libraries referenced by packages -->
    <BuildPackageLibraryReferences Condition="'$(BuildPackageLibraryReferences)' == ''">true</BuildPackageLibraryReferences>

    <BuildInParallel Condition="'$(BuildInParallel)' == '' AND '$(MSBuildNodeCount)' > '1'">true</BuildInParallel>
  </PropertyGroup>

  <PropertyGroup Condition="'$(IsRuntimePackage)' == 'true' or '$(PackageTargetRuntime)' != ''">
    <IdPrefix>runtime.</IdPrefix>
    <IdPrefix Condition="'$(PackageTargetRuntime)' != ''">$(IdPrefix)$(PackageTargetRuntime).</IdPrefix>
    <IdPrefix Condition="'$(PackageTargetFramework)' != ''">$(IdPrefix)$(PackageTargetFramework).</IdPrefix>
  </PropertyGroup>
   
  <!-- If Signing is enabled, we'll always want to write *.nupkg_requires_signing files --> 
  <UsingTask AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" TaskName="WriteSigningRequired" />
  <PropertyGroup>
    <ShouldWritePkgSigningRequired Condition="'$(SkipSigning)' == 'true'">false</ShouldWritePkgSigningRequired>
    <ShouldWritePkgSigningRequired Condition="'$(SignType)' == 'public' or '$(SignType)' == 'oss'">false</ShouldWritePkgSigningRequired>
    <ShouldWritePkgSigningRequired Condition="'$(ShouldWritePkgSigningRequired)'==''">true</ShouldWritePkgSigningRequired>
    <NuPkgAuthenticodeSig          Condition="'$(ShouldWritePkgSigningRequired)'=='true'">Microsoft</NuPkgAuthenticodeSig>    
  </PropertyGroup>

  <!--
       NuSpec configuration.

       NOTE: It's by design that these properties override the project. We don't
       want projects to specify any metadata, most of the metadata should be
       the same for all packages, and the rest will be centralized.
  -->
  <PropertyGroup>
    <BaseId>$(MSBuildProjectName)</BaseId>
    <Id>$(IdPrefix)$(BaseId)</Id>
    <PackedPackageNamePrefix Condition="'$(PackedPackageNamePrefix)' == ''">transport</PackedPackageNamePrefix>
    <PackedPackageId>$(PackedPackageNamePrefix).$(Id)</PackedPackageId>
    <!-- It is by design that the Title matches the Id. We want users to get an assembly view. -->
    <Title>$(Id)</Title>
    <Authors>Microsoft</Authors>
    <Owners>microsoft,dotnetframework</Owners>
    <Description>TODO</Description>
    <LicenseUrl Condition="'$(LicenseUrl)' == ''">http://go.microsoft.com/fwlink/?LinkId=329770</LicenseUrl>
    <IconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</IconUrl>
    <Copyright Condition="'$(Copyright)' == ''">.NET Foundation and Contributors</Copyright>
    <Tags></Tags>
    <RequireLicenseAcceptance Condition="'$(RequireLicenseAcceptance)' == ''">false</RequireLicenseAcceptance>
    <Serviceable Condition="'$(Serviceable)' == ''">true</Serviceable>
    <!-- we depend on nuget v2.12 / v3.4 behavior NuGet doesn't support two different min client versions
         so we declare 2.12 and mention in package description that when using 3.x we require 3.4 or later -->
    <MinClientVersion3 Condition="'$(MinClientVersion3)' == '' and '$(MinClientVersion)' == ''">3.4</MinClientVersion3>
    <MinClientVersion Condition="'$(MinClientVersion)' == ''">2.12</MinClientVersion>
  </PropertyGroup>

  <!-- Shared properties -->
  <PropertyGroup>
    <SymbolPackageOutputPath Condition="'$(SymbolPackageOutputPath)' == ''">$(BaseOutputPath)symbolpkg/</SymbolPackageOutputPath>
    <OutputPath>$(PackageOutputPath)</OutputPath>
    <NuSpecOutputPath Condition="'$(NuSpecOutputPath)' == ''">$(PackageOutputPath)specs/</NuSpecOutputPath>
    <NuSpecPath>$(NuSpecOutputPath)$(Id)$(NuspecSuffix).nuspec</NuSpecPath>
    <PackageReportPath>$(PackageReportDir)$(Id)$(NuspecSuffix).json</PackageReportPath>
    <TargetPath>$(NuSpecPath)</TargetPath>
    <RuntimeFilePath Condition="'$(RuntimeFilePath)' == ''">$(NuSpecOutputPath)$(Id)$(NuspecSuffix)/runtime.json</RuntimeFilePath>
    <PackedPackageRuntimeFilePath Condition="'$(PackedPackageRuntimeFilePath)' == ''">$(NuSpecOutputPath)$(Id)$(NuspecSuffix)/$(PackedPackageNamePrefix).runtime.json</PackedPackageRuntimeFilePath>
    <PlaceholderFile>$(MSBuildThisFileDirectory)_._</PlaceholderFile>
    <PackageDescriptionFile Condition="'$(PackageDescriptionFile)' == ''">path to descriptions.json must be specified</PackageDescriptionFile>
    <ValidationSuppressionFile Condition="'$(ValidationSuppressionFile)' == ''">ValidationSuppression.txt</ValidationSuppressionFile>
    <SyncInfoFile Condition="'$(SyncInfoFile)' == ''">unspecified</SyncInfoFile>
    <LineupPackageId Condition="'$(LineupPackageId)' == ''">Microsoft.NETCore.Targets</LineupPackageId>
    <LineupPackageVersion Condition="'$(LineupPackageVersion)' == ''">1.0.1</LineupPackageVersion>
    <PlatformPackageId Condition="'$(PlatformPackageId)' == ''">Microsoft.NETCore.Platforms</PlatformPackageId>
    <PlatformPackageVersion Condition="'$(PlatformPackageVersion)' == ''">1.0.1</PlatformPackageVersion>
  </PropertyGroup>

  
  <!-- Determine if we actually need to build for this architecture -->
  <!-- Packages can specifically control their architecture by specifying the PackagePlatforms
       property as a semi-colon delimited list.
       If this is not done then the package will build if the target runtime contains the current
       architecture or if we're building for x86. -->
  <PropertyGroup>
    <PackagePlatform Condition="'$(PackagePlatform)' == ''">$(Platform)</PackagePlatform>
    <PackagePlatform Condition="'$(PackagePlatform)' == 'amd64'">x64</PackagePlatform>

    <!-- build if the package specifically requests current architecture via PackagePlatforms -->
    <ShouldGenerateNuSpec Condition="$(PackagePlatforms.Contains('$(PackagePlatform);'))">true</ShouldGenerateNuSpec>
    <!-- build if PackagePlatforms is not specified and the PackageTargetRuntime contains the current architecture -->
    <ShouldGenerateNuSpec Condition="'$(PackagePlatforms)' == '' AND $(PackageTargetRuntime.Contains('-$(PackagePlatform)'))">true</ShouldGenerateNuSpec>
    <!-- build if PackagePlatforms is not specified and arch is x86 or AnyCPU -->
    <ShouldGenerateNuSpec Condition="'$(PackagePlatforms)' == '' AND ('$(PackagePlatform)' == 'x86' OR '$(PackagePlatform)' == 'AnyCPU')">true</ShouldGenerateNuSpec>
    <ShouldCreatePackage Condition="'$(ShouldCreatePackage)' == ''">$(ShouldGenerateNuSpec)</ShouldCreatePackage>
    <BuildDependsOn Condition="'$(ShouldGenerateNuSpec)' == 'true'">GenerateNuSpec</BuildDependsOn>
    <BuildDependsOn Condition="'$(ShouldCreatePackage)' == 'true'">$(BuildDependsOn);CreatePackage</BuildDependsOn>
    <BuildDependsOn Condition="'$(ShouldCreatePackage)' == 'true' OR '$(ShouldGenerateNuSpec)' == 'true'">$(BuildDependsOn);GetPackageReport;ValidatePackage</BuildDependsOn>
  </PropertyGroup>

  <!-- Redefine build to just create the NuSpec only, we'll create the package during ArcProjects phase -->
  <Target Name="Build"
          DependsOnTargets="$(BuildDependsOn)">

    <Message Condition="'$(ShouldGenerateNuSpec)' == 'true'"
             Text="$(MSBuildProjectName) -> $(NuSpecPath)"
             Importance="high" />

    <Message Condition="'$(ShouldGenerateNuSpec)' != 'true'"
             Text="Skipping nuspec generation for this platform."
             Importance="high" />
  </Target>

  <Target Name="Clean">
    <!-- package version is calculated so read the last version from the marker file. -->
    <ReadLinesFromFile File="$(NuSpecPath).pkgpath"
                       Condition="Exists('$(NuSpecPath).pkgpath')">
      <Output TaskParameter="Lines" ItemName="_ToBeDeleted"/>
    </ReadLinesFromFile>

    <ItemGroup>
      <_ToBeDeleted Include="$(NuSpecPath)" />
      <_ToBeDeleted Include="$(NuSpecPath).pkgpath" />
      <_ToBeDeleted Include="$(RuntimeFilePath)" />
      <_ToBeDeleted Include="$(PackedPackageRuntimeFilePath)" />
    </ItemGroup>
    <Delete Files="@(_ToBeDeleted)" />
  </Target>

  <Target Name="Rebuild"
          DependsOnTargets="Clean;Build" />

  <!-- BEGIN project refs-->
  <!-- Don't actually walk the closure all the time, conditioned on GetClosure metadata on ProjectReference.
       Walking the closure is very expensive for many of our packages and is unecessary since we are very
       strict about assets that are included in the package.  -->
  <Target Name="_GetProjectClosure"
          DependsOnTargets="ConvertCommonMetadataToAdditionalProperties"
          Returns="@(_ProjectReferenceClosure)">

    <!-- Get closure of indirect references if they opt-in -->
    <MSBuild Projects="@(ProjectReference)"
             Targets="_GetProjectClosure"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue"
             BuildInParallel="$(BuildInParallel)"
             Condition="'%(ProjectReference.GetClosure)' == 'true'">
      <Output TaskParameter="TargetOutputs"
              ItemName="_ProjectReferenceClosureWithDuplicates" />
    </MSBuild>

    <!-- Remove duplicates from closure -->
    <RemoveDuplicates Inputs="@(_ProjectReferenceClosureWithDuplicates)">
      <Output TaskParameter="Filtered"
              ItemName="_ProjectReferenceClosureWithoutMetadata"/>
    </RemoveDuplicates>

    <ItemGroup>
      <!-- Remove references that are also direct references -->
      <_ProjectReferenceClosureWithoutMetadata Remove="%(ProjectReference.FullPath)" />
      <!-- We can now mark all the closure references as indirect -->
      <_ProjectReferenceClosure Include="@(_ProjectReferenceClosureWithoutMetadata)">
        <DependencyKind>Indirect</DependencyKind>
        <PackageDirectory>%(ProjectReference.PackageDirectory)</PackageDirectory>
      </_ProjectReferenceClosure>
      <!-- Now add the direct references, preserving metadata -->
      <_ProjectReferenceClosure Include="@(ProjectReference->'%(FullPath)')">
        <DependencyKind>Direct</DependencyKind>
      </_ProjectReferenceClosure>
    </ItemGroup>

  </Target>

  <Target Name="SplitProjectReferences"
          DependsOnTargets="_GetProjectClosure">
    <ItemGroup>
      <!-- Split direct and indirect project dependencies -->
      <_PkgProjProjectReferenceClosure Include="@(_ProjectReferenceClosure)"
                                      Condition="'%(_ProjectReferenceClosure.Extension)' == '.pkgproj'" />
      <_NonPkgProjProjectReferenceClosure Include="@(_ProjectReferenceClosure)"
                                         Condition="'%(_ProjectReferenceClosure.Extension)' != '.pkgproj'" />

      <!-- Split direct project dependencies -->
      <_PkgProjProjectReference Include="@(_PkgProjProjectReferenceClosure)"
                               Condition="'%(DependencyKind)' == 'Direct'" />
      <_NonPkgProjProjectReference Include="@(_NonPkgProjProjectReferenceClosure)"
                                  Condition="'%(DependencyKind)' == 'Direct'" />

    </ItemGroup>
  </Target>

  <Target Name="GetPkgProjPackageDependencies"
          Returns="@(PkgProjDependency)"
          Inputs="%(_PkgProjProjectReferenceClosure.DependencyKind)"
          Outputs="fake"
          DependsOnTargets="SplitProjectReferences">
    <MSBuild Targets="GetPackageIdentity"
             BuildInParallel="$(BuildInParallel)"
             Projects="@(_PkgProjProjectReferenceClosure)"
             Properties="%(_PkgProjProjectReferenceClosure.SetConfiguration); %(_PkgProjProjectReferenceClosure.SetPlatform)">
      <Output TaskParameter="TargetOutputs"
              ItemName="_PkgProjDependency" />
    </MSBuild>
    <ItemGroup>
      <PkgProjDependency Include="@(_PkgProjDependency)">
        <DependencyKind>%(_PkgProjProjectReferenceClosure.DependencyKind)</DependencyKind>
      </PkgProjDependency>
    </ItemGroup>
  </Target>


  <PropertyGroup>
    <!-- exclude reference assets for runtime packages
         these assets are only packaged in the reference packages.  Even
         if they have a runtime asset we package it in the reference package
         for better compression.  -->
    <ExcludeReferenceAssets Condition="'$(ExcludeReferenceAssets)' == '' AND '$(PackageTargetRuntime)' != ''">true</ExcludeReferenceAssets>
  </PropertyGroup>

  <!-- We define a custom target: GetFilesToPackage which does a minimal build of the project
       and passes all information in a single item group.
       This helps minimize the number of project evaluations and targets that build in order
       to determine the contents of the package-->
  <Target Name="ExpandProjectReferences"
          DependsOnTargets="SplitProjectReferences">

    <!-- Only rebuild project references when specified -->
    <MSBuild Targets="Build"
             BuildInParallel="$(BuildInParallel)"
             Condition="'$(BuildPackageLibraryReferences)' == 'true' AND '$(DesignTimeBuild)' != 'true'"
             Projects="@(_NonPkgProjProjectReference)"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue"/>

    <MSBuild Targets="GetFilesToPackage"
             BuildInParallel="$(BuildInParallel)"
             Projects="@(_NonPkgProjProjectReference)"
             Properties="$(ProjectProperties)">
      <Output TaskParameter="TargetOutputs"
              ItemName="_FilesToPackage" />
    </MSBuild>

    <ItemGroup>
      <_FilesToPackage Remove="@(_FilesToPackage)" Condition="'$(ExcludeReferenceAssets)' == 'true' AND '%(_FilesToPackage.IsReferenceAsset)' == 'true'" />
      <File Include="@(_FilesToPackage)">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <!-- Some packages support legacy portable profiles where dependencies are provided by targeting pack -->
        <HarvestDependencies Condition="!$([System.String]::Copy('%(_FilesToPackage.TargetFramework)').StartsWith('portable-'))">true</HarvestDependencies>
      </File>
    </ItemGroup>

    <Error Condition="'$(SkipPackageFileCheck)' != 'true' AND
                      '$(IsFrameworkPackage)' != 'true' AND
                      '%(File.SkipPackageFileCheck)' != 'true' AND
                      '%(File.FileName)' != '_' AND
                      '%(File.FileName)%(File.Extension)' != 'runtime.json' AND
                      '%(File.Extension)' != '.cs' AND
                      '%(File.Extension)' != '.vb' AND
                      !$(ID.Contains('%(File.FileName)'))"
           Text="Package $(ID) contains file with name %(File.FileName).  If this is expected you can disable this filename checking for this item or package by setting SkipPackageFileCheck = true" />
  </Target>
  <!-- END project refs-->

  <!-- BEGIN files-->
  <!-- If the "PreventImplementationReference" property is true, then don't permit references to the
    package implementation from lib.  This is used in the platform specific packages which should
    not be directly referenced by projects for implemtation dependencies. -->
  <Target Name="PreventImplementationReference">
    <ItemGroup Condition="'$(PreventImplementationReference)' == 'true'">
      <File Include="$(PlaceholderFile)">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <TargetPath Condition="'$(UseNetPlatform)' != 'true'">ref/netstandard</TargetPath>
        <TargetPath Condition="'$(UseNetPlatform)' == 'true'">ref/dotnet</TargetPath>
      </File>
    </ItemGroup>
  </Target>

  <!--
      InboxOnTargetFramework: contract implementation and reference are inbox, use placeholders for both
      NotSupportedOnTargetFramework: contract should not be supported, use place holder for lib
      ExternalOnTargetFramework: contract implementation is provided by another package, use placeholders for both
  -->
  <Target Name="AddPlaceholders"
          DependsOnTargets="ExpandProjectReferences;PreventImplementationReference"
          Inputs="%(InboxOnTargetFramework.Identity);%(NotSupportedOnTargetFramework.Identity);%(ExternalOnTargetFramework.Identity)"
          Outputs="fake">
    <ItemGroup>
      <_targetItem Include="@(InboxOnTargetFramework)"/>
      <_targetItem Include="@(NotSupportedOnTargetFramework)"/>
      <_targetItem Include="@(ExternalOnTargetFramework)"/>
    </ItemGroup>
    <PropertyGroup>
      <_target>%(_targetItem.Identity)</_target>
      <_targetRuntime>$(PackageTargetRuntime)</_targetRuntime>
      <_targetRuntime Condition="'%(_targetItem.PackageTargetRuntime)' != ''">%(_targetItem.PackageTargetRuntime)</_targetRuntime>
      <!-- don't use 'any' in paths due to https://github.com/NuGet/Home/issues/1676 -->
      <_targetRuntime Condition="'$(_targetRuntime)' == 'any'"></_targetRuntime>
      <!-- include a ref placeholder for everything but NotSupportedOnTargetFramework, never put placeholders in runtime packages -->
      <_targetRef Condition="'%(NotSupportedOnTargetFramework.Identity)' == '' AND '$(PackageTargetRuntime)' == ''">true</_targetRef>
    </PropertyGroup>
    <ItemGroup>
      <File Include="$(PlaceholderFile)">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <TargetPath Condition="'$(_targetRuntime)' != ''">runtimes/$(_targetRuntime)/lib/$(_target)</TargetPath>
        <TargetPath Condition="'$(_targetRuntime)' == ''">lib/$(_target)</TargetPath>
      </File>
      <File Include="$(PlaceholderFile)" Condition="'$(_targetRef)' == 'true'">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <TargetPath>ref/$(_target)</TargetPath>
      </File>
      <FrameworkReference Condition="'%(InboxOnTargetFramework.AsFrameworkReference)' == 'true'" Include="$(Id)">
        <TargetFramework>$(_target)</TargetFramework>
      </FrameworkReference>
      <FrameworkReference Condition="'%(InboxOnTargetFramework.FrameworkReference)' != ''" Include="%(InboxOnTargetFramework.FrameworkReference)">
        <TargetFramework>$(_target)</TargetFramework>
      </FrameworkReference>
      <Dependency Include="_._">
        <TargetFramework>$(_target)</TargetFramework>
      </Dependency>
    </ItemGroup>
  </Target>

  <Target Name="ConvertItems"
          DependsOnTargets="ExpandProjectReferences;AddPlaceholders">
    <CreateItem Include="@(ProjectReferenceOutput)">
      <Output TaskParameter="Include"
              ItemName="File"/>
    </CreateItem>
    <ItemGroup>
      <_LinkedContentFiles Include="@(Content)"
                           Condition="'%(Content.Link)' != ''" />
      <_UnlinkedContentFiles Include="@(Content)"
                             Condition="'%(Content.Link)' == ''" />
    </ItemGroup>
    <CreateItem Include="@(_LinkedContentFiles)"
                AdditionalMetadata="TargetPath=%(Link)">
      <Output TaskParameter="Include"
              ItemName="File"/>
    </CreateItem>
    <CreateItem Include="@(_UnlinkedContentFiles)"
                AdditionalMetadata="TargetPath=%(RelativeDir)">
      <Output TaskParameter="Include"
              ItemName="File"/>
    </CreateItem>

    <!-- We need to special case library files in later phases. In order to make this
         easier, we add custom metadata 'IsLibrary' that indicates whether the file is
         targeting the lib folder or not. -->

    <ItemGroup>
      <_FileWithIsLibrary Include="@(File)"
                          Condition="'%(File.TargetPath)' == 'lib' OR
                                     $([System.String]::Copy('%(File.TargetPath)').ToLower().StartsWith('lib\')) OR
                                     $([System.String]::Copy('%(File.TargetPath)').ToLower().StartsWith('lib/'))">
        <PackageDirectory>Lib</PackageDirectory>
      </_FileWithIsLibrary>
      <_FileWithIsLibrary Include="@(File)"
                          Condition="'%(File.TargetPath)' != 'lib' AND
                                     !$([System.String]::Copy('%(File.TargetPath)').ToLower().StartsWith('lib\')) AND
                                     !$([System.String]::Copy('%(File.TargetPath)').ToLower().StartsWith('lib/'))">
        <PackageDirectory></PackageDirectory>
      </_FileWithIsLibrary>
      <File Remove="@(File)" />
      <File Include="@(_FileWithIsLibrary)" />
    </ItemGroup>
  </Target>

  <Target Name="HarvestStablePackage"
          Condition="'$(HarvestStablePackage)' != 'false'"
          DependsOnTargets="ConvertItems;GetPkgProjPackageDependencies">
    <ItemGroup>
      <_latestPackage Include="$(Id)">
        <Version>$(PackageVersion)</Version>
      </_latestPackage>
      <_latestRuntimePackages Include="@(PkgProjDependency)" Condition="'%(PkgProjDependency.TargetRuntime)' != ''" KeepDuplicates="false" />
    </ItemGroup>

    <!-- Calculate the package version to harvest -->
    <GetLastStablePackage Condition="'$(HarvestVersion)' == ''" 
                          LatestPackages="@(_latestPackage)" 
                          StablePackages="@(StablePackage)"
                          PackageIndexes="@(PackageIndex)">
      <Output  TaskParameter="LastStablePackages" ItemName="_lastStablePackage"/>
    </GetLastStablePackage>

    <PropertyGroup Condition="'$(HarvestVersion)' == ''">
      <HarvestVersion>%(_lastStablePackage.Version)</HarvestVersion>
    </PropertyGroup>

    <!-- Calculate the runtime package versions to use for applicability evaluation -->
    <GetLastStablePackage Condition="'@(HarvestRuntimePackages)' == ''" 
                          LatestPackages="@(_latestRuntimePackages)" 
                          StablePackages="@(StablePackage)"
                          PackageIndexes="@(PackageIndex)">
      <Output  TaskParameter="LastStablePackages" ItemName="HarvestRuntimePackages"/>
    </GetLastStablePackage>

    <GetLastStablePackage Condition="'@(HarvestAdditionalPackageIds)' != ''" 
                          LatestPackages="@(HarvestAdditionalPackageIds)" 
                          StablePackages="@(StablePackage)"
                          PackageIndexes="@(PackageIndex)">
      <Output  TaskParameter="LastStablePackages" ItemName="HarvestAdditionalPackages"/>
    </GetLastStablePackage>
    
    <PropertyGroup>
      <HarvestFiles Condition="'$(HarvestFiles)' == ''">true</HarvestFiles>
    </PropertyGroup>

    <Error Condition="'$(HarvestVersion)' == '' AND '@(HarvestIncludePaths)' != ''"
           Text="HarvestIncludePaths was specified but no previous stable version of this package was found." />

    <!-- Harvest files from old package and determine support using both runtime and additional packages -->
    <HarvestPackage PackageId="$(Id)"
                    PackageVersion="$(HarvestVersion)"
                    PackagesFolder="$(PackagesDir)"
                    Files="@(File)"
                    RuntimeFile="$(RuntimeIdGraphDefinitionFile)" 
                    RuntimePackages="@(HarvestRuntimePackages);@(HarvestAdditionalPackages)"
                    IncludeAllPaths="$(HarvestIncludeAllPaths)"
                    HarvestAssets="$(HarvestFiles)"
                    PathsToExclude="@(HarvestExcludePaths)"
                    PathsToInclude="@(HarvestIncludePaths)"
                    PathsToSuppress="@(HarvestSuppressPaths)"
                    Frameworks="@(DefaultValidateFramework)"
                    Condition="'$(HarvestVersion)' != ''">
      <Output TaskParameter="SupportedFrameworks" ItemName="_HarvestedSupportedFramework"/>
      <Output TaskParameter="HarvestedFiles" ItemName="_harvestedFiles"/>
      <Output TaskParameter="UpdatedFiles" ItemName="_updatedFiles" />
    </HarvestPackage>

    <ItemGroup Condition="'@(_harvestedFiles)' != ''">
      <File Remove="@(File)"/>
      <File Include="@(_updatedFiles);@(_harvestedFiles)"/>
    </ItemGroup>

    <!-- Harvest files from HarvestAdditionalPackages, but don't calculate support-->
    <HarvestPackage PackageId="%(HarvestAdditionalPackages.Identity)"
                    PackageVersion="%(HarvestAdditionalPackages.Version)"
                    PackagesFolder="$(PackagesDir)"
                    Files="@(File)"
                    RuntimeFile="$(RuntimeIdGraphDefinitionFile)"
                    HarvestAssets="$(HarvestFiles)"
                    IncludeAllPaths="$(HarvestIncludeAllPaths)"
                    PathsToExclude="@(HarvestExcludePaths);%(HarvestAdditionalPackages.ExcludePaths)"
                    PathsToInclude="@(HarvestIncludePaths);%(HarvestAdditionalPackages.IncludePaths)"
                    PathsToSuppress="@(HarvestSuppressPaths);%(HarvestAdditionalPackages.SuppressPaths)"
                    Condition="'@(HarvestAdditionalPackages)' != ''" >
      <Output TaskParameter="HarvestedFiles" ItemName="File"/>
    </HarvestPackage>
    
    <ItemGroup>
      <SupportedFramework Include="@(_HarvestedSupportedFramework)" Exclude="@(NotSupportedOnTargetFramework)" />
    </ItemGroup>
  </Target>

  <Target Name="GetFiles"
          Returns="@(File)"
          DependsOnTargets="ConvertItems;HarvestStablePackage" />

  <!-- Don't do any filtering of files.
       We explicitly determine package content so we do not need to
       filter out files that come from dependent packages. -->
  <Target Name="GetPackageFiles"
          Returns="@(PackageFile)"
          DependsOnTargets="GetFiles">
    <ItemGroup>
      <!-- Include all files except source files. Sources need to be deduplicated. -->
      <PackageFile Include="@(File)" Condition="'%(File.IsSourceCodeFile)'!='true'" />
      <PackageFile Condition="'%(PackageFile.PackageId)' == ''">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
      </PackageFile>

      <!-- Include Sources. Deduplicate so the nuspec doesn't contain multiple entries for each source file. -->
      <PackageSources Include="@(File)"
                      KeepMetadata="TargetPath;IsSourceCodeFile"
                      KeepDuplicates="false"
                      Condition="'%(File.IsSourceCodeFile)'=='true'" />
      <!-- Add a placeholder source file if there are symbols but no sources. -->
      <PackageSymbolFiles Include="@(File)" Condition="'%(File.IsSymbolFile)'=='true'" />
      <PackageSources Include="$(PlaceholderFile)" Condition="'@(PackageSymbolFiles)'!='' AND '@(PackageSources)'==''">
        <IsSourceCodeFile>true</IsSourceCodeFile>
        <TargetPath>src</TargetPath>
      </PackageSources>
      <PackageFile Include="@(PackageSources)" />

      <!-- Nuget will treat TargetPath as a directory if the extensions dont match,
           however we need to package files without an extension (Unix exectuables).
           As such nuget will always consider TargetPath to be a file path for these
           files.  Ensure that the TargetPath is the file path for these files. -->
      <PackageFile Condition="'%(Extension)' == ''">
        <TargetPath>%(PackageFile.TargetPath)/%(FileName)</TargetPath>
      </PackageFile>
    </ItemGroup>
  </Target>
  <!-- END files-->

  <!-- BEGIN dependencies-->
  <Target Name="AssignPkgProjPackageDependenciesTargetFramework"
          DependsOnTargets="GetPkgProjPackageDependencies;GetFiles">

    <SplitDependenciesBySupport Condition="'$(SplitDependenciesBySupport)' == 'true'"
                                OriginalDependencies="@(PkgProjDependency)">
      <Output TaskParameter="SplitDependencies" ItemName="_SplitPkgProjDependency" />
    </SplitDependenciesBySupport>

    <ItemGroup Condition="'@(_SplitPkgProjDependency)' != ''">
      <PkgProjDependency Remove="@(PkgProjDependency)" />
      <PkgProjDependency Include="@(_SplitPkgProjDependency)" />
    </ItemGroup>

    <ItemGroup>
      <!-- ensure that unconstrained dependencies are also expanded in constrained TFM groups -->
      <_PkgProjDependencyWithoutTFM Include="@(PkgProjDependency)" Condition="'%(PkgProjDependency.TargetFramework)' == '' AND '%(PkgProjDependency.TargetRuntime)' == '' AND '%(PkgProjDependency.DoNotExpand)' != 'true'" />
      <_AllPkgProjTFMs Include="%(PkgProjDependency.TargetFramework)" Condition="'%(PkgProjDependency.DependencyKind)' == 'Direct'" />
      <!-- Include file TFMs -->
      <_AllPkgProjTFMs Include="%(File.TargetFramework)" Condition="'%(File.TargetFramework)' != ''" />

      <!-- Remove dependencies without a TFM so they can be replaced -->
      <PkgProjDependency Remove="@(_PkgProjDependencyWithoutTFM)" />
      <!-- operate on pkgproj dependencies and file dependencies -->
      <PkgProjDependency Include="@(_PkgProjDependencyWithoutTFM)">
        <TargetFramework>%(_AllPkgProjTFMs.Identity)</TargetFramework>
      </PkgProjDependency>

      <Dependency Include="@(PkgProjDependency)"
                  Condition="'%(PkgProjDependency.DependencyKind)' == 'Direct'" />
    </ItemGroup>
  </Target>

  <Target Name="DetermineRuntimeDependencies"
          DependsOnTargets="AssignPkgProjPackageDependenciesTargetFramework"
          Returns="@(RuntimeDependency)">

    <!-- see if we have any runtime dependencies to write to runtime.json -->
    <ItemGroup>
      <RuntimeDependency Condition="'%(Dependency.TargetRuntime)' != ''" Include="@(Dependency)"/>
      <RuntimeDependency>
        <TargetPackage Condition="'%(RuntimeDependency.TargetPackage)' == ''">$(Id)</TargetPackage>
      </RuntimeDependency>
      <!-- don't include runtime depdendencies in the dependency list, they'll be written to the runtime.json -->
      <Dependency Remove="@(RuntimeDependency)"/>
    </ItemGroup>

    <Error Text="Packages that are constrained by runtime should not have runtime dependencies.  They will be ignored by nuget"
           Condition="'$(PackageTargetRuntime)' != '' AND '@(RuntimeDependency)' != ''" />

    <!-- determine if there is a file to be updated, and setup the output file -->
    <PropertyGroup>
      <RuntimeFileSource Condition="'%(File.FileName)%(File.Extension)' == 'runtime.json'">%(File.Identity)</RuntimeFileSource>
      <_runtimeJsonIncluded Condition="'$(IsLineupPackage)' == 'true' OR '$(IncludeRuntimeJson)' == 'true'">true</_runtimeJsonIncluded>
    </PropertyGroup>

    <!-- only include runtime.json in lineup packages -->
    <ItemGroup Condition="'$(_runtimeJsonIncluded)' == 'true'">
      <!-- if we are updating, remove it from the file group, we'll replace it with the generated version -->
      <PackageFile Condition="'$(RuntimeFileSource)' != ''" Remove="$(RuntimeFileSource)"/>
      <PackageFile Include="$(RuntimeFilePath)">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <IsLibrary>false</IsLibrary>
      </PackageFile>
    </ItemGroup>
  </Target>

  <!-- Harvest dependencies from assembly references.
       Assume version of package dependency == assembly version of dependency (3-part).
       For prerelease (not stable) packages apply a pre-release suffix to the dependency -->
  <Target Name="GetFilePackageReferences"
          DependsOnTargets="GetFiles"
          Condition="'$(OmitDependencies)' != 'true'"
          Inputs="%(File.Identity);%(File.TargetFramework)"
          Outputs="fake">

    <PropertyGroup>
      <_TargetFramework>%(File.TargetFramework)</_TargetFramework>
    </PropertyGroup>
    
    <ItemGroup>
      <_harvestFile Include="@(File)" Condition="'%(File.HarvestDependencies)' == 'true' and '%(File.Extension)' == '.dll'" />
      <_missingHarvestFile Include="@(_harvestFile)" Condition="!Exists('%(FullPath)')" />
      <_harvestFile Remove="@(_missingHarvestFile)" Condition="'$(AllowPartialPackages)' == 'true'" />

      <!-- add a fake dependency to represent the dependencies of any missing file 
           this will prevent the package from installing on that platform. -->
      <FilePackageDependency Include="Unavailable" Condition="'$(AllowPartialPackages)' == 'true' AND '@(_missingHarvestFile)' != '' AND '$(_TargetFramework)' != ''">
        <TargetFramework>$(_TargetFramework)</TargetFramework>
        <Version>0.0.0</Version>
      </FilePackageDependency>
    </ItemGroup>

    <!-- Generate package references based on assembly dependencies -->
    <GetAssemblyReferences Assemblies="@(_harvestFile)">
      <Output TaskParameter="ReferencedAssemblies"
              ItemName="_FileReferencedAssemblies"/>
      <Output TaskParameter="ReferencedNativeLibraries"
              ItemName="_FileReferencedNativeLibraries"/>
    </GetAssemblyReferences>

    <SplitReferences References="@(_FileReferencedAssemblies)"
                     TargetFramework="$(_TargetFramework)"
                     PackageIndexes="@(PackageIndex)">
      <Output TaskParameter="FrameworkReferences" ItemName="_FileFrameworkReference"/>
      <Output TaskParameter="PackageReferences" ItemName="_FilePackageReferenceUnfiltered"/>
    </SplitReferences>
    
    <FilterUnknownPackages Condition="'@(_FilePackageReferenceUnfiltered)' != ''"
                           OriginalDependencies="@(_FilePackageReferenceUnfiltered)"
                           BaseLinePackages="@(BaseLinePackage)"
                           PackageIndexes="@(PackageIndex)">
      <Output TaskParameter="FilteredDependencies" ItemName="_FilePackageReference" />
    </FilterUnknownPackages>
                           

    <ItemGroup Condition="'@(_FilePackageReference)' != ''">
      <_FilePackageReference Remove="corefx;mscorlib;System;System.Core;System.Xml;Windows" />

      <!-- Projects may specify additional references by assembly name & identity that we'll process
           applying pre-release logic -->
      <_FilePackageReference Include="@(AdditionalAssemblyReference)"/>

      <_FilePackageReference Condition="'%(Identity)' == '@(FileRuntimeDependency)'">
        <TargetRuntime>@(FileRuntimeDependency->'%(TargetRuntime)')</TargetRuntime>
      </_FilePackageReference>
    </ItemGroup>

    <GetPackageFromModule Condition="'@(_FileReferencedNativeLibraries)' != ''"
                          ModulesReferenced="@(_FileReferencedNativeLibraries)"
                          ModulePackages="@(NativeLibrary)"
                          PackageIndexes="@(PackageIndex)">
      <Output TaskParameter="PackagesReferenced" ItemName="_FilePackageReference" />
    </GetPackageFromModule>

    <ItemGroup>
      <FilePackageDependency Include="@(_FilePackageReference)" />
      <!-- Only add framework references for desktop frameworks -->
      <FrameworkReference Condition="$(_TargetFramework.StartsWith('net4'))" Include="@(_FileFrameworkReference)" KeepDuplicates="false" />
    </ItemGroup>
  </Target>

  <Target Name="GetNuGetPackageDependencies"
          DependsOnTargets="CreateVersionFileDuringBuild;GetFilePackageReferences;DetermineRuntimeDependencies">
    <PropertyGroup>
      <!-- determine if we have any reference assets in the package (files in the ref folder) -->
      <_containsReferenceAsset Condition="'%(File.IsReferenceAsset)' == 'true'">true</_containsReferenceAsset>
    </PropertyGroup>

    <ItemGroup Condition="'$(_containsReferenceAsset)' == 'true'">
      <!-- If the package contains a reference asset, then make all non-reference dependencies
           exclude compile assets, so as not to leak implementation dependencies into the compile
           graph.-->
      <FilePackageDependency>
        <Exclude Condition="'%(FilePackageDependency.IsReferenceAsset)' != 'true'">Compile</Exclude>
      </FilePackageDependency>
    </ItemGroup>

    <!-- Add a dependency on the lineup & platform package if this package has runtime dependencies and no runtime.json -->
    <ItemGroup Condition="'@(RuntimeDependency)' != '' AND '$(_runtimeJsonIncluded)' != 'true' AND '$(ExcludeLineupReference)' != 'true'">
      <!-- Add to any TargetFramework that isn't a placeholder-->
      <_runtimeDependenciesTargetFramework Include="%(File.TargetFramework)"
                                           Condition="'%(File.Identity)' != '$(PlaceholderFile)'"
                                           KeepDuplicates="false" />
      <!-- remove any frameworks that have an impl in this package -->
      <_runtimeDependenciesTargetFramework Remove="%(File.TargetFramework)"
                                           Condition="$([System.String]::Copy('%(File.TargetPath)').StartsWith('lib/', StringComparison.OrdinalIgnoreCase))" />
      <FilePackageDependency Include="$(LineupPackageId)">
        <Version>$(LineupPackageVersion)</Version>
        <TargetFramework>%(_runtimeDependenciesTargetFramework.Identity)</TargetFramework>
      </FilePackageDependency>
      <FilePackageDependency Include="$(PlatformPackageId)">
        <Version>$(PlatformPackageVersion)</Version>
        <TargetFramework>%(_runtimeDependenciesTargetFramework.Identity)</TargetFramework>
      </FilePackageDependency>
    </ItemGroup>

    <!-- Add a dependency on the runtime graph package for every TFM that has RID-specific assets and is not already a runtime package -->
    <ItemGroup Condition="'$(PackageTargetRuntime)' == '' AND '$(ExcludeRuntimeReference)' != 'true'">
      <_ridSpecificTargetFrameworks Include="@(File->'%(TargetFramework)')"
                                    Condition="$([System.String]::Copy('%(File.TargetPath)').StartsWith('runtimes/', StringComparison.OrdinalIgnoreCase))
                                               AND '%(File.Identity)' != '$(PlaceholderFile)'" />
      <!-- remove any frameworks that have a RID-less impl in this package-->
      <_ridSpecificTargetFrameworks Remove="%(File.TargetFramework)"
                                           Condition="$([System.String]::Copy('%(File.TargetPath)').StartsWith('lib/', StringComparison.OrdinalIgnoreCase))" />

      <FilePackageDependency Include="$(PlatformPackageId)" Condition="'@(_ridSpecificTargetFrameworks)' != ''">
        <Version>$(PlatformPackageVersion)</Version>
        <TargetFramework>%(_ridSpecificTargetFrameworks.Identity)</TargetFramework>
      </FilePackageDependency>
    </ItemGroup>

    <!-- We can reduce the number of dependencies listed for any framework that has
         inbox implementations since that framework doesn't need the packages for
         compile/runtime.  This reduces the noise when consuming our packages in
         packages.config based projects.  -->
    <CreateTrimDependencyGroups Dependencies="@(FilePackageDependency);@(Dependency)"
                      PackageIndexes="@(PackageIndex)"
                      Files="@(File)"
                      Condition="'@(FilePackageDependency)' != '' AND '$(PackageTargetRuntime)' == ''">
      <Output TaskParameter="TrimmedDependencies" ItemName="FilePackageDependency" />
    </CreateTrimDependencyGroups>

    <!-- Promote dependencies from ref to lib and vice-versa -->
    <PromoteDependencies Dependencies="@(FilePackageDependency)"
                         PackageIndexes="@(PackageIndex)"
                         Condition="'@(FilePackageDependency)' != ''">
      <Output TaskParameter="PromotedDependencies" ItemName="FilePackageDependency" />
    </PromoteDependencies>

    <ApplyMetaPackages PackageId="$(Id)"
                       OriginalDependencies="@(FilePackageDependency)"
                       PackageIndexes="@(PackageIndex)"
                       SuppressMetaPackages="@(SuppressMetaPackage)"
                       Apply="$(ApplyMetaPackages)">
      <Output TaskParameter="UpdatedDependencies" ItemName="_ConsolidatedDependencies" />
    </ApplyMetaPackages>

    <Error Condition="'@(PackageIndex)' == '' AND '@(BaseLinePackage)' == '' AND '@(_ConsolidatedDependencies)' != '' AND '$(BaseLinePackageDependencies)' != 'false'"
           Text="Neither PackageIndex nor BaseLinePackage items are defined: ensure you have imported Microsoft.Private.PackageBaseLine.props from the Microsoft.Private.PackageBaseLine package" />
    <ApplyBaseLine OriginalDependencies="@(_ConsolidatedDependencies)"
                   BaseLinePackages="@(BaseLinePackage)"
                   PackageIndexes="@(PackageIndex)"
                   Apply="$(BaseLinePackageDependencies)">
      <Output TaskParameter="BaseLinedDependencies" ItemName="_BaseLinedDependencies" />
    </ApplyBaseLine>


    <Error Condition="'@(_BaseLinedDependencies)' != '' AND '@(PackageIndex)' == '' AND '@(StablePackage)' == ''" 
           Text="Neither PackageIndex nor StablePackage items are defined: ensure you have imported Microsoft.Private.PackageBaseLine.props from the Microsoft.Private.PackageBaseLine package" />
    <ApplyPreReleaseSuffix Condition="'@(_BaseLinedDependencies)' != ''" 
                           OriginalPackages="@(_BaseLinedDependencies)" 
                           StablePackages="@(StablePackage)"
                           PackageIndexes="@(PackageIndex)"
                           PreReleaseSuffix="$(VersionSuffix)">
      <Output TaskParameter="UpdatedPackages" ItemName="Dependency"/>
    </ApplyPreReleaseSuffix>
  </Target>

  <Target Name="GetPackageDependencies"
          DependsOnTargets="AssignPkgProjPackageDependenciesTargetFramework;GetNuGetPackageDependencies"
          Returns="@(Dependency)">
  </Target>
  <!-- END dependencies-->

  <!-- Generates a runtime.json file containing all dependencies with TargetRuntime -->
  <Target Name="GenerateRuntimeDependencies"
          DependsOnTargets="DetermineRuntimeDependencies">
    <ItemGroup>
      <LineupProjectReference Include="@(ProjectReference)" />
    </ItemGroup>

    <!-- Lineups need to have all runtime dependencies to ensure that they are part of the compile graph -->
    <MSBuild Projects="@(LineupProjectReference)"
             Targets="DetermineRuntimeDependencies"
             Condition="'$(IsLineupPackage)' == 'true'"
             BuildInParallel="$(BuildInParallel)"
             Properties="$(ProjectProperties)">
      <Output TaskParameter="TargetOutputs" ItemName="_indirectRuntimeDependencies" />
    </MSBuild>

    <!-- pass both RuntimeDependencies and regular dependencies.
         Only RuntimeDependencies will be generated, but Dependencies are required
         since they may be the target of a RuntimeDependency -->
    <GenerateRuntimeDependencies Condition="'@(RuntimeDependency)' != '' OR '@(_indirectRuntimeDependencies)' != ''"
                                 Dependencies="@(RuntimeDependency);@(Dependency);@(_indirectRuntimeDependencies)"
                                 PackageId="$(Id)"
                                 RuntimeJsonTemplate="$(RuntimeFileSource)"
                                 RuntimeJson="$(RuntimeFilePath)"
                                 />
    
    <ItemGroup Condition="'$(CreatePackedPackage)' == 'true'">
      <PackedPackageRuntimeDependency Include="@(RuntimeDependency->'$(PackedPackageNamePrefix).%(Identity)')">
        <TargetPackage>$(PackedPackageNamePrefix).%(TargetPackage)</TargetPackage>
      </PackedPackageRuntimeDependency>
      <PackedPackageDependency Include="@(Dependency->'$(PackedPackageNamePrefix).%(Identity)')" />
    </ItemGroup>

    <GenerateRuntimeDependencies Condition="('@(PackedPackageRuntimeDependency)' != '' OR '@(_indirectRuntimeDependencies)' != '') AND '$(CreatePackedPackage)' == 'true'"
                                 Dependencies="@(PackedPackageRuntimeDependency);@(PackedPackageDependency);@(_indirectRuntimeDependencies)"
                                 PackageId="$(PackedPackageId)"
                                 RuntimeJsonTemplate="$(RuntimeFileSource)"
                                 RuntimeJson="$(PackedPackageRuntimeFilePath)"/>
  </Target>

  <Target Name="EnsureEmptyPackage"
          DependsOnTargets="DetermineRuntimeDependencies;GetPackageFiles">
    <!-- Nuget will include all files when nuspec is empty, ensure we have at least one file to avoid that -->
    <ItemGroup Condition="'@(PackageFile)' == ''">
      <PackageFile Include="$(PlaceholderFile)">
        <PackageId>$(Id)</PackageId>
        <PackageVersion>$(PackageVersion)</PackageVersion>
        <IsLibrary>false</IsLibrary>
      </PackageFile>
    </ItemGroup>
  </Target>


  <!-- BEGIN Metadata-->

  <!-- Walks every project gathering its AssemblyVersion, choosing the highest -->
  <!-- Skipped if the package explicitly defines a version -->
  <Target Name="GetAssemblyVersionFromProjects"
          Condition="$(PackageVersion) == ''"
          DependsOnTargets="GetFiles">

    <GetPackageVersion Files="@(File)">
      <Output TaskParameter="Version" PropertyName="_AssemblyVersion" />
    </GetPackageVersion>

    <Error Condition="'$(_AssemblyVersion)' == ''"
           Text="No assembly version could be determined." />
  </Target>

  <!-- Calculates the package version including any prerelease suffix -->
  <Target Name="CalculatePackageVersion"
        DependsOnTargets="CreateVersionFileDuringBuild;GetAssemblyVersionFromProjects">

    <Error Text="No version could be detected.  Either specify the Version property or provide at least one managed assembly."
           Condition="'$(PackageVersion)' == '' AND '$(_AssemblyVersion)' == ''" />

    <ItemGroup>
      <_thisPackage Include="$(Id)">
        <Version Condition="'$(PackageVersion)' != ''">$(PackageVersion)</Version>
        <Version Condition="'$(PackageVersion)' == ''">$(_AssemblyVersion)</Version>
      </_thisPackage>
    </ItemGroup>

    <ApplyPreReleaseSuffix Condition="'$(StableVersion)' == ''"
                           OriginalPackages="@(_thisPackage)" 
                           StablePackages="@(StablePackage)"
                           PackageIndexes="@(PackageIndex)"
                           PreReleaseSuffix="$(VersionSuffix)" >
      <Output TaskParameter="UpdatedPackages" ItemName="_thisPackageFinal"/>
    </ApplyPreReleaseSuffix>

    <PropertyGroup Condition="'$(StableVersion)' == ''">
      <PackageVersion>%(_thisPackageFinal.Version)</PackageVersion>
    </PropertyGroup>
  </Target>

  <!-- Permit setting TargetFramework and add our own metadata (TargetRuntime) -->
  <Target Name="GetPackageIdentity"
          Returns="@(_PackageIdentity)"
          DependsOnTargets="GetFiles;CalculatePackageVersion">

    <ItemGroup>
      <_referenceFrameworks Include="%(File.TargetFramework)" Condition="'%(File.IsReferenceAsset)' == 'true'" />
    </ItemGroup>

    <GetMinimumNETStandard Condition="'$(MinimumNETStandard)' == ''"
                           Frameworks="@(_referenceFrameworks)">
      <Output TaskParameter="MinimumNETStandard" PropertyName="MinimumNETStandard"/>
    </GetMinimumNETStandard>

    <ItemGroup>
      <_PackageIdentity Include="$(Id)">
        <Version>$(PackageVersion)</Version>
        <TargetFramework Condition="'$(PackageTargetFramework)' != ''">$(PackageTargetFramework)</TargetFramework>
        <TargetRuntime Condition="'$(PackageTargetRuntime)' != ''">$(PackageTargetRuntime)</TargetRuntime>
        <MinimumNETStandard Condition="'$(MinimumNETStandard)' != ''">$(MinimumNETStandard)</MinimumNETStandard>
      </_PackageIdentity>
    </ItemGroup>
  </Target>

  <Target Name="GetSyncInfo"
    Condition="Exists('$(SyncInfoFile)')">
    <ReadLinesFromFile
      File="$(SyncInfoFile)">
      <Output
        TaskParameter="Lines"
        ItemName="SyncInfoLines" />
    </ReadLinesFromFile>
  </Target>

  <Target Name="GetPackageDescription"
          DependsOnTargets="GetSyncInfo">
    <PropertyGroup>
      <UseRuntimePackageDescription Condition="'$(UseRuntimePackageDescription)' == '' AND $(BaseId.StartsWith('runtime.native'))">true</UseRuntimePackageDescription>
    </PropertyGroup>

    <GetPackageDescription DescriptionFile="$(PackageDescriptionFile)"
                           Condition="'$(UseRuntimePackageDescription)' != 'true'"
                           PackageId="$(BaseId)">
      <Output TaskParameter="Description"
              PropertyName="Description" />
    </GetPackageDescription>

    <GetPackageDescription DescriptionFile="$(PackageDescriptionFile)"
                           Condition="'$(PackageTargetRuntime)' != '' OR '$(UseRuntimePackageDescription)' == 'true'"
                           PackageId="RuntimePackage">
      <Output TaskParameter="Description"
              PropertyName="RuntimeDisclaimer" />
    </GetPackageDescription>

    <!-- Looks up a message similar to "When using NuGet 3.x this package requires at least version {0}." -->
    <GetPackageDescription DescriptionFile="$(PackageDescriptionFile)"
                           Condition="'$(MinClientVersion3)' != ''"
                           PackageId="NuGet3MinVersion">
      <Output TaskParameter="Description"
              PropertyName="NuGet3MinVersionMessage" />
    </GetPackageDescription>

    <PropertyGroup>
      <Description Condition="'$(UseRuntimePackageDescription)' == 'true' AND '$(RuntimeDisclaimer)' != ''">$(RuntimeDisclaimer)</Description>
      <Description Condition="'$(UseRuntimePackageDescription)' != 'true' AND '$(RuntimeDisclaimer)' != ''">$(RuntimeDisclaimer) %0A$(Description)</Description>
      <Description Condition="'@(SyncInfoLines)' != ''">$(Description) %0A%(SyncInfoLines.Identity)</Description>
      <Description Condition="'$(MinClientVersion3)' != ''">$(Description) %0A$([System.String]::Format('$(NuGet3MinVersionMessage)', '$(MinClientVersion3)'))</Description>
    </PropertyGroup>
  </Target>

  <Target Name="GetPackageMetadata"
          DependsOnTargets="GetPackageDescription;GetPackageIdentity" />
  <!-- END Metadata -->
  <PropertyGroup>
    <UAPvNextTFM Condition="'$(UAPvNextTFM)' == ''">uap10.1</UAPvNextTFM>
  </PropertyGroup>

  <!-- BEGIN validation and output -->
  <ItemGroup>
    <NETCoreApp10RIDs Condition="'@(NETCoreApp10RIDs)' == ''" Include="win7-x86;win7-x64;osx.10.11-x64;centos.7-x64;debian.8-x64;linuxmint.17-x64;rhel.7.2-x64;ubuntu.14.04-x64;ubuntu.16.04-x64" />
    <!-- Default validation frameworks : frameworks which we test for support / not support in all packages -->
    <DefaultValidateFramework Include="netcoreapp1.0">
      <RuntimeIDs>@(NETCoreApp10RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NETCoreApp11RIDs Condition="'@(NETCoreApp11RIDs)' == ''" Include="@(NETCoreApp10RIDs);osx.10.12-x64;fedora.24-x64;opensuse.42.1-x64;rhel.7-x64" />
    <DefaultValidateFramework Include="netcoreapp1.1">
      <RuntimeIDs>@(NETCoreApp11RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NETCoreApp20RIDs Condition="'@(NETCoreApp20RIDs)' == ''" Include="@(NETCoreApp11RIDs)" />
    <DefaultValidateFramework Include="netcoreapp2.0">
      <RuntimeIDs>@(NETCoreApp20RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NETCoreApp21RIDs Condition="'@(NETCoreApp21RIDs)' == ''" Include="@(NETCoreApp20RIDs)" />
    <DefaultValidateFramework Include="netcoreapp2.1">
      <RuntimeIDs>@(NETCoreApp21RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NETCoreApp22RIDs Condition="'@(NETCoreApp22RIDs)' == ''" Include="@(NETCoreApp21RIDs)" />
    <DefaultValidateFramework Include="netcoreapp2.2">
      <RuntimeIDs>@(NETCoreApp22RIDs)</RuntimeIDs>
    </DefaultValidateFramework>

    <NETCore50RIDs Condition="'@(NETCore50RIDs)' == ''" Include="win10-x86;win10-x86-aot;win10-x64;win10-x64-aot;win10-arm;win10-arm-aot" />
    <DefaultValidateFramework Include="netcore50">
      <RuntimeIDs>@(NETCore50RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="netcore45">
      <!-- Intentionally empty, no RIDs defined for Win8 as it must work with packages.config-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="netcore451">
      <!-- Intentionally empty, no RIDs defined for Win81 as it must work with packages.config-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>

    <NET45RIDs Condition="'@(NET45RIDs)' == ''" Include=";win-x86;win-x64" />
    <DefaultValidateFramework Include="net45" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET45RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NET451RIDs Condition="'@(NET451RIDs)' == ''" Include="@(NET45RIDs)" />
    <DefaultValidateFramework Include="net451" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET451RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
      <!-- additional win7 RIDs to validate up-level authoring -->
    <NET46RIDs Condition="'@(NET46RIDs)' == ''" Include="@(NET451RIDs);win7-x86;win7-x64" />
    <DefaultValidateFramework Include="net46" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET46RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NET461RIDs Condition="'@(NET461RIDs)' == ''" Include="@(NET46RIDs)" />
    <DefaultValidateFramework Include="net461" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET461RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NET462RIDs Condition="'@(NET462RIDs)' == ''" Include="@(NET461RIDs)" />
    <DefaultValidateFramework Include="net462" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET462RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <NET47RIDs Condition="'@(NET47RIDs)' == ''" Include="@(NET462RIDs)" />
    <DefaultValidateFramework Include="net47" Condition="'$(ExcludeFromDesktopSupportValidation)' != 'true'">
      <RuntimeIDs>;@(NET47RIDs)</RuntimeIDs>
    </DefaultValidateFramework>

    <DefaultValidateFramework Include="wpa81">
      <!-- Intentionally empty, no RIDs defined for phone-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="wp8">
      <!-- Intentionally empty, no RIDs defined for phone-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>

    <UAP10RIDs Condition="'@(UAP10RIDs)' == ''" Include="@(NETCore50RIDs)" />
    <DefaultValidateFramework Include="uap10.0">
      <RuntimeIDs>@(UAP10RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <UAP10016299RIDs Condition="'@(UAP10016299RIDs)' == ''" Include="@(UAP10RIDs)" />
    <DefaultValidateFramework Include="uap10.0.16299">
      <RuntimeIDs>@(UAP10016299RIDs)</RuntimeIDs>
    </DefaultValidateFramework>
    <UAPvNextRIDs Condition="'@(UAPvNextRIDs)' == ''" Include="@(UAP10016299RIDs)" />
    <DefaultValidateFramework Include="$(UAPvNextTFM)">
      <RuntimeIDs>@(UAPvNextRIDs)</RuntimeIDs>
    </DefaultValidateFramework>
  </ItemGroup>

  <ItemGroup Condition="'$(ExcludeXamarinValidationFrameworks)' != 'true'">
    <DefaultValidateFramework Include="MonoAndroid10">
      <!-- Intentionally empty, no RIDs defined for MonoAndroid10-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="MonoTouch10">
      <!-- Intentionally empty, no RIDs defined for MonoTouch10-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="xamarinios10">
      <!-- Intentionally empty, no RIDs defined for xamarinios10-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="xamarinmac20">
      <!-- Intentionally empty, no RIDs defined for xamarinmac20-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="xamarintvos10">
      <!-- Intentionally empty, no RIDs defined for xamarintvos10-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
    <DefaultValidateFramework Include="xamarinwatchos10">
      <!-- Intentionally empty, no RIDs defined for xamarinwatchos10-->
      <RuntimeIDs></RuntimeIDs>
    </DefaultValidateFramework>
  </ItemGroup>

  <PropertyGroup>
    <AllXamarinFrameworks Condition="'$(AllXamarinFrameworks)' == ''">MonoAndroid10;MonoTouch10;xamarinios10;xamarinmac20;xamarintvos10;xamarinwatchos10</AllXamarinFrameworks>
  </PropertyGroup>

  <PropertyGroup Condition="'$(IsFrameworkPackage)' != 'true'">
    <!-- Skip validation of runtime packages, they will be validated in the context of their reference package -->
    <SkipValidatePackage Condition="'$(SkipValidateTargetFrameworks)' == '' AND '$(PackageTargetRuntime)' != ''">true</SkipValidatePackage>
    <SkipSupportCheck Condition="'$(SkipSupportCheck)' == '' AND ($(Id.StartsWith('System.Private.')) OR $(Id.StartsWith('Microsoft.NETCore.')))">true</SkipSupportCheck>
  </PropertyGroup>

  <Target Name="GetPackageAssets"
          DependsOnTargets="GetPackageFiles;DetermineRuntimeDependencies"
          Returns="@(PackageAsset)">
    <ItemGroup>
      <RuntimeDependencyProject Include="%(RuntimeDependency.OriginalItemSpec)" KeepDuplicates="false" />
      <!-- map back to the project references -->
      <RuntimeDependencyProjectFullPath Include="@(RuntimeDependencyProject->'%(FullPath)')"/>
      <ProjectReferenceFullPath Include="@(ProjectReference->'%(FullPath)')"/>
      <RuntimeProjectReference Include="@(ProjectReferenceFullPath)" Condition="'@(ProjectReferenceFullPath->Distinct())' == '@(RuntimeDependencyProjectFullPath)' AND '%(Identity)' != ''"/>
    </ItemGroup>


    <!-- Get all the files from runtime implementation packages to include in reference path-->
    <MSBuild Projects="@(RuntimeProjectReference)"
             Targets="GetPackageFiles"
             BuildInParallel="$(BuildInParallel)"
             Properties="$(ProjectProperties)">
      <Output TaskParameter="TargetOutputs" ItemName="RuntimeFile" />
    </MSBuild>

    <ItemGroup>
      <PackageAsset Include="@(RuntimeFile)"
                    Condition="'%(RuntimeFile.IsSourceCodeFile)'!='true'" />
      <PackageAsset Include="@(PackageFile)"
                    Condition="'%(PackageFile.IsSourceCodeFile)'!='true'" />
    </ItemGroup>
  </Target>
  
  <Target Name="GetPackageReport"
          DependsOnTargets="GetPackageAssets"
          Returns="$(PackageReportPath)">
    <GeneratePackageReport
                     PackageId="$(Id)"
                     PackageVersion="$(PackageVersion)"
                     Files="@(PackageAsset)"
                     Frameworks="@(DefaultValidateFramework)"
                     RuntimeFile="$(RuntimeIdGraphDefinitionFile)"
                     PackageIndexes="@(PackageIndex)"
                     ReportFile="$(PackageReportPath)" />
  </Target>

  <Target Name="ValidateLibraryPackage"
          DependsOnTargets="GetPackageReport"
          Condition="'$(IsFrameworkPackage)' != 'true'">

    <ItemGroup>
      <!-- Validation framework metadata can be sepecified in multiple ways.
           By default we have a set of frameworks that we validate for.  If a package includes SupportedFramework items it will
           be tested for support of those frameworks, and not support of any thing in the default set and not the supported set.
           The default set may be completely replaced by setting IncludeDefaultValidateFramework=false and populating
           the ValidateFramework item yourself (eg: at the repo level), or by excluding individual frameworks by setting
           ExcludeDefaultValidateFramework.  Excluding a framework just means we won't explicitly validate it. -->
      <ValidateFramework Condition="'$(IncludeDefaultValidateFramework)' != 'false'" Include="@(DefaultValidateFramework)" Exclude="@(ExcludeDefaultValidateFramework)" />
    </ItemGroup>

    <ItemGroup>
      <!-- Allow for SupportedFramework to be defined as metadata on project references -->
      <SupportedFramework Include="%(File.SupportedFramework)" Condition="'%(File.SupportedFramework)' != '' AND '%(File.AssemblyVersion)' != ''">
        <Version>%(File.AssemblyVersion)</Version>
      </SupportedFramework>
    </ItemGroup>

    <ItemGroup>
      <!-- default to the current version for any unspecified SupportedFrameworks with unspecified version -->
      <SupportedFramework Condition="'%(SupportedFramework.Version)' == ''">
        <Version>$(_AssemblyVersion)</Version>
      </SupportedFramework>
    </ItemGroup>

    <ValidatePackage ContractName="$(BaseId)"
                     Frameworks="@(ValidateFramework)"
                     PackageId="$(Id)"
                     PackageIndexes="@(PackageIndex)"
                     PackageVersion="$(PackageVersion)"
                     RuntimeFile="$(RuntimeIdGraphDefinitionFile)"
                     SkipGenerationCheck="$(SkipGenerationCheck)"
                     SkipIndexCheck="$(SkipIndexCheck)"
                     SkipSupportCheck="$(SkipSupportCheck)"
                     SupportedFrameworks="@(SupportedFramework)"
                     Suppressions="@(ValidatePackageSuppression)"
                     UseNetPlatform="$(UseNetPlatform)"
                     ReportFile="$(PackageReportPath)" />

  </Target>

  <Target Name="ValidateFrameworkPackage"
          DependsOnTargets="GetPackageReport"
          Condition="'$(IsFrameworkPackage)' == 'true'">
    <ValidateFrameworkPackage Framework="$(TargetFramework)"
                              Runtime="$(PackageTargetRuntime)"
                              PackageIndexes="@(PackageIndex)"
                              ReportFile="$(PackageReportPath)"
                              Suppressions="@(ValidatePackageSuppression)" />
  </Target>
  
  <Target Name="ValidatePackage"
          DependsOnTargets="ValidateLibraryPackage;ValidateFrameworkPackage"
          Condition="'$(SkipValidatePackage)' != 'true'" />

  <!-- Required by Common.Targets when evaluating projectReferences -->
  <Target Name="GetNativeManifest" />
  <Target Name="GetCopyToOutputDirectoryItems" />

  <!-- When building in VS, ResolveProjectReferences only calls GetTargetPath
       and expects that to return the same set of items as Targets defined by
       ProjectReference.Targets metadata.  -->
  <Target Name="GetTargetPath"
          DependsOnTargets="GetPackageAssets"
          Returns="@(PackageAsset)" />

  <!-- App packaging support -->
  <!--
    Following two targets are needed to be present in every project being built
    because the app packaging targets recursively scan all projects referenced
    from projects that generate app packages for them.
  -->
  <Target Name="CleanAppxPackage" />
  <Target Name="GetPackagingOutputs" />

  <Target Name="GenerateNuSpec"
          DependsOnTargets="GetPackageDependencies;GetPackageFiles;GetPackageMetadata;GenerateRuntimeDependencies;EnsureEmptyPackage">

    <ItemGroup>
      <_packageFile Include="@(PackageFile)" />
      <_missingPackageFile Include="@(PackageFile)" Condition="!Exists('%(FullPath)')" />
      <_packageFile Remove="@(_missingPackageFile)" Condition="'$(AllowPartialPackages)' == 'true'" />

      <!-- replace any missing files with placeholders -->
      <_packageFile Include="@(_missingPackageFile->'$(PlaceHolderFile)')" Condition="'$(AllowPartialPackages)' == 'true'" />
    </ItemGroup>

    <PropertyGroup  Condition="'$(AllowPartialPackages)' == 'true' AND '@(_missingPackageFile)' != ''">
      <Description>WARNING: This package is missing files @(_missingPackageFile->'%(TargetPath)/%(Filename)%(Extension)') %0A$(Description)</Description>
    </PropertyGroup>

    <!-- Please Note:
         In order to avoid incremental build issues this target will always run.
         However, the task will make sure that it doesn't touch the file if the
         contents it would generate are identical to a previously generated
         nuspec. -->
    <GenerateNuSpec InputFileName="$(NuSpecTemplate)"
                    OutputFileName="$(NuSpecPath)"
                    MinClientVersion="$(MinClientVersion)"
                    Id="$(Id)"
                    Version="$(PackageVersion)"
                    Title="$(Title)"
                    Authors="$(Authors)"
                    Owners="$(Owners)"
                    Description="$(Description)"
                    ReleaseNotes="$(ReleaseNotes)"
                    Summary="$(Summary)"
                    Language="$(Language)"
                    ProjectUrl="$(ProjectUrl)"
                    IconUrl="$(IconUrl)"
                    LicenseUrl="$(LicenseUrl)"
                    Copyright="$(Copyright)"
                    RequireLicenseAcceptance="$(RequireLicenseAcceptance)"
                    Tags="$(Tags)"
                    DevelopmentDependency="$(DevelopmentDependency)"
                    Dependencies="@(Dependency)"
                    References="@(Reference)"
                    FrameworkReferences="@(FrameworkReference)"
                    Files="@(_packageFile)"
                    Serviceable="$(Serviceable)"/>
  </Target>

  <Target Name="CreatePackage"
          Inputs="$(NuSpecPath)"
          Outputs="$(PackageOutputPath)$(Id).$(PackageVersion).nupkg">

    <ItemGroup>
      <_missingFiles Include="@(PackageFile)" Condition="!Exists(%(FullPath))"/>
    </ItemGroup>

    <PropertyGroup>
      <_SkipCreatePackage Condition="'$(SkipCreatePackageOnMissingFiles)' == 'true' AND '@(_missingFiles)' != ''">true</_SkipCreatePackage>
    </PropertyGroup>

    <Message Condition="'$(_SkipCreatePackage)' == 'true'" Text="Skipping package creation for $(NuSpecPath) because the following files do not exist: @(_missingFiles)" />

    <NugetPack Nuspecs="$(NuSpecPath)"
               OutputDirectory="$(PackageOutputPath)"
               ExcludeEmptyDirectories="true"
               CreateSymbolPackage="true"
               CreatePackedPackage="$(CreatePackedPackage)"
               IncludeSymbolsInPackage="$(IncludeSymbolsInPackage)"
               SymbolPackageOutputDirectory="$(SymbolPackageOutputPath)"
               AdditionalLibPackageExcludes="@(AdditionalLibPackageExcludes)"
               AdditionalSymbolPackageExcludes="@(AdditionalSymbolPackageExcludes)"
               PackedPackageNamePrefix="$(PackedPackageNamePrefix)"
               Condition="'$(_SkipCreatePackage)' != 'true'"/>

    <!-- Create a marker that records the path to the generated package -->
    <WriteLinesToFile Lines="$(PackageOutputPath)$(Id).$(PackageVersion).nupkg;$(SymbolPackageOutputPath)$(Id).$(PackageVersion).nupkg"
                      File="$(NuSpecPath).pkgpath"
                      Overwrite="true"
                      Condition="'$(_SkipCreatePackage)' != 'true'"/>
                      
    <WriteSigningRequired Condition="'$(ShouldWritePkgSigningRequired)'=='true'"
                          AuthenticodeSig="$(NuPkgAuthenticodeSig)"
                          MarkerFile="$(PackageOutputPath)$(Id).$(PackageVersion).nupkg.requires_nupkg_signing" />
    <WriteSigningRequired Condition="'$(ShouldWritePkgSigningRequired)'=='true'"
                          AuthenticodeSig="$(NuPkgAuthenticodeSig)"
                          MarkerFile="$(SymbolPackageOutputPath)$(Id).$(PackageVersion).nupkg.requires_nupkg_signing" />                          
    <ItemGroup Condition="'$(ShouldWritePkgSigningRequired)'=='true'">
      <FileWrites Include="$(SymbolPackageOutputPath)$(Id).$(PackageVersion).nupkg.requires_nupkg_signing"/>
      <FileWrites Include="$(PackageOutputPath)$(Id).$(PackageVersion).nupkg.requires_nupkg_signing"/>
    </ItemGroup>                      

  </Target>

  <!-- Updates the packageIndex with information from the built package for this project -->
  <!-- Intentionally not sequenced, invoked directly through /t:UpdatePackageIndex -->
  <Target Name="UpdatePackageIndex"
          DependsOnTargets="CalculatePackageVersion">

    <Error Condition="'$(PackageIndexFile)' == ''"
           Text="The PackageIndexFile property is not set.  Please set this property to point to the path of the packageIndex.json file for your repo." />

    <UpdatePackageIndex PackageIndexFile="$(PackageIndexFile)"
                        Packages="$(PackageOutputPath)$(Id).$(PackageVersion).nupkg" />
  </Target>

  <!-- Updates the packageIndex with information from the multiple sources for the entire repo -->
  <!-- Intentionally not sequenced, invoked directly through /t:UpdateRepoPackageIndex -->
  <Target Name="UpdateRepoPackageIndex">
    <Error Condition="'$(PackageIndexFile)' == ''"
           Text="The PackageIndexFile property is not set.  Please set this property to point to the path of the packageIndex.json file for your repo." />

    <!-- Set PackageFolders to point to the directories to index, this directories may contain nupkgs or expanded nupkgs -->
    <!-- Set PackageIds to the list of package Ids to consider from PackageFolders -->
    <!-- Set BaseLinePackage to packageId identity with 'Version' metadata to define the set of packages which should set their baseline to a particular version -->
    <!-- Set StablePackage to packageId identity with 'Version' metadata to define the set of packages which should be set as stable -->
    <!-- Set ModuleToPackage to module name identity with 'Package' metadata to define mappings from native modules to package IDs which contain those -->
    <!-- Set FrameworkListsFolder to the path to a set of directories containing framework lists, where the subdirectory name is the TFM.  These lists will determine what is inbox on that framework. -->
    <!-- Set FrameowrkLayout to folder identity with 'TargetFramework' metadata to consider files within that folder inbox on that framework.-->

    <UpdatePackageIndex PackageIndexFile="$(PackageIndexFile)"
                        PackageIds="@(PackageIds)"
                        PackageFolders="@(PackageFolders)"
                        BaselinePackages="@(BaselinePackage)"
                        StablePackages="@(StablePackage)"
                        ModuleToPackages="@(ModuleToPackage)"
                        InboxFrameworkListFolder="$(FrameworkListsFolder)"
                        InboxFrameworkLayoutFolders="@(FrameworkLayout)" />
  </Target>
</Project>