File size: 34,267 Bytes
090629c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!--

***********************************************************************************************

Microsoft.NET.Sdk.StaticWebAssets.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.

***********************************************************************************************

-->

<Project ToolsVersion="14.0">

  <!-- Targets that support static content scenarios in ASP.NET Core.

       The main targets are:

       * GenerateStaticWebAssetsManifest: Creates a manifest file to use in development with

         the paths to all the references packages and projects content roots.

       * ResolveStaticWebAssetsInputs: Collects all the static assets from different sources

         * Current project.

         * Referenced project.

         * Referenced packages.

       * GenerateStaticWebAssetsPackTargets: Includes the static web assets in the current project

         under the 'staticwebassets' folder in the nuget package and generates and includes in the

         package the appropriate .props files to support discovering the packaged static web assets.

       * GetCurrentProjectStaticWebAssets: Called on each referenced project to retrieve the list of

         static web assets in the project.

  -->

  <UsingTask

    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateV1StaticWebAssetsManifest"

    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"

    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask

    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ValidateStaticWebAssetsUniquePaths"

    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"

    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask

    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAsssetsPropsFile"

    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"

    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask

    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAssetsGeneratePackagePropsFile"

    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"

    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask

    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAssetsGeneratePackManifest"

    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"

    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <PropertyGroup>
    <GenerateStaticWebAssetsManifestDependsOn>
      ResolveStaticWebAssetsInputs;
      $(GenerateStaticWebAssetsManifestDependsOn)
      _CreateStaticWebAssetsInputsCacheFile;
      GenerateStaticWebAssetsPackTargets;
    </GenerateStaticWebAssetsManifestDependsOn>

    <GetCurrentProjectStaticWebAssetsDependsOn>
      ResolveCurrentProjectStaticWebAssetsInputs;
      $(GetCurrentProjectStaticWebAssetsDependsOn)
    </GetCurrentProjectStaticWebAssetsDependsOn>

    <PrepareForRunDependsOn>
      GenerateStaticWebAssetsManifest;
      $(PrepareForRunDependsOn);
    </PrepareForRunDependsOn>

    <GetCopyToOutputDirectoryItemsDependsOn>
      _IncludeGeneratedStaticWebAssetsManifest;
      $(GetCopyToOutputDirectoryItemsDependsOn);
    </GetCopyToOutputDirectoryItemsDependsOn>

    <ResolveCurrentProjectStaticWebAssetsInputsDependsOn>
      ResolveStaticWebAssetsConfiguration;
      $(ResolveCurrentProjectStaticWebAssetsInputsDependsOn)
    </ResolveCurrentProjectStaticWebAssetsInputsDependsOn>

    <ResolveStaticWebAssetsInputsDependsOn>
      ResolveCurrentProjectStaticWebAssetsInputs;
      ResolveReferencedProjectsStaticWebAssets;
      $(ResolveStaticWebAssetsInputsDependsOn)
    </ResolveStaticWebAssetsInputsDependsOn>

    <ResolveReferencedProjectsStaticWebAssetsDependsOn Condition="'$(TargetFramework)' != ''">
      PrepareProjectReferences;
      $(ResolveReferencedProjectsStaticWebAssetsDependsOn)
    </ResolveReferencedProjectsStaticWebAssetsDependsOn>

    <GenerateStaticWebAssetsPackTargetsDependsOn>
      ResolveStaticWebAssetsInputs;
      $(GenerateStaticWebAssetsPackTargetsDependsOn);
      _CreateStaticWebAssetsCustomPropsCacheFile;
    </GenerateStaticWebAssetsPackTargetsDependsOn>

    <TargetsForTfmSpecificContentInPackage Condition="$(IsInnerBuild) != 'true'" >
      ResolveStaticWebAssetsInputs;
      IncludeStaticWebAssetPackItems;
      $(TargetsForTfmSpecificContentInPackage)
    </TargetsForTfmSpecificContentInPackage>

    <PackDependsOn>
      _RemoveWebRootContentFromPackaging;
      $(PackDependsOn)
    </PackDependsOn>

  </PropertyGroup>

  <PropertyGroup>
    <_StaticWebAssetsIntermediateOutputPath>$(IntermediateOutputPath)staticwebassets\</_StaticWebAssetsIntermediateOutputPath>

    <!-- Development manifest generation -->
    <_GeneratedStaticWebAssetsInputsCacheFile>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.Manifest.cache</_GeneratedStaticWebAssetsInputsCacheFile>
    <_GeneratedStaticWebAssetsDevelopmentManifest>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.xml</_GeneratedStaticWebAssetsDevelopmentManifest>
    <_GeneratedStaticWebAssetsPackManifest>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).pack.json</_GeneratedStaticWebAssetsPackManifest>

    <!-- Project packing generation -->
    <_GeneratedStaticWebAssetsCustomPropsCacheFile>$(_StaticWebAssetsIntermediateOutputPath)$(TargetName).StaticWebAssets.Pack.cache</_GeneratedStaticWebAssetsCustomPropsCacheFile>

    <!-- Temporary files -->
    <_GeneratedStaticWebAssetsPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.$(PackageId).Microsoft.AspNetCore.StaticWebAssets.props</_GeneratedStaticWebAssetsPropsFile>
    <_GeneratedBuildPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.build.$(PackageId).props</_GeneratedBuildPropsFile>
    <_GeneratedBuildMultitargetingPropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.buildMultiTargeting.$(PackageId).props</_GeneratedBuildMultitargetingPropsFile>
    <_GeneratedBuildTransitivePropsFile>$(_StaticWebAssetsIntermediateOutputPath)msbuild.buildTransitive.$(PackageId).props</_GeneratedBuildTransitivePropsFile>

    <!-- Package relative import paths -->
    <_StaticWebAssetsPropsFileImportPath>Microsoft.AspNetCore.StaticWebAssets.props</_StaticWebAssetsPropsFileImportPath>
    <_StaticWebAssetsGeneratedBuildPropsFileImportPath>..\build\$(PackageId).props</_StaticWebAssetsGeneratedBuildPropsFileImportPath>
    <_StaticWebAssetsGeneratedBuildMultiTargetingPropsFileImportPath>..\buildMultiTargeting\$(PackageId).props</_StaticWebAssetsGeneratedBuildMultiTargetingPropsFileImportPath>

  </PropertyGroup>

  <!-- Helper target invoked by other tasks below to ensure that the intermediate output path has the correct

       shape for the intermediate output files that might be generated.

  -->
  <Target Name="_PrepareForStaticWebAssets">
    <MakeDir

      Directories="$(_StaticWebAssetsIntermediateOutputPath)"

      Condition="!Exists('$(_StaticWebAssetsIntermediateOutputPath)')" />
  </Target>

  <Target Name="ResolveStaticWebAssetsConfiguration">
    <PropertyGroup>
      <StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">_content/$(PackageId)</StaticWebAssetBasePath>
    </PropertyGroup>

  </Target>

  <!--

    ============================================================

                                        Static web assets development manifest generation targets



    The main targets for generating a development manifest with information about the static web

    assets found in referenced packages and projects.

    ============================================================

    -->

  <Target

    Name="_CreateStaticWebAssetsInputsCacheFile"

    DependsOnTargets="ResolveStaticWebAssetsInputs;_PrepareForStaticWebAssets">

    <ItemGroup>
      <!--

      This is the list of inputs that will be used for generating the manifest used during development.

      -->
      <_ExternalStaticWebAsset

        Include="%(StaticWebAsset.Identity)"

        Condition="'%(SourceType)' != ''">
          <BasePath>%(StaticWebAsset.BasePath)</BasePath>
          <ContentRoot>%(StaticWebAsset.ContentRoot)</ContentRoot>
          <SourceId>%(StaticWebAsset.SourceId)</SourceId>
      </_ExternalStaticWebAsset>
    </ItemGroup>

    <!-- We need a transform here to make sure we hash the metadata -->
    <Hash ItemsToHash="@(_ExternalStaticWebAsset->'%(Identity)%(SourceId)%(BasePath)%(ContentRoot)')">
      <Output TaskParameter="HashResult" PropertyName="_StaticWebAssetsCacheHash" />
    </Hash>

    <WriteLinesToFile

      Lines="$(_StaticWebAssetsCacheHash)"

      File="$(_GeneratedStaticWebAssetsInputsCacheFile)"

      Overwrite="True"

      WriteOnlyWhenDifferent="True" />

    <ItemGroup>
      <FileWrites Include="$(_GeneratedStaticWebAssetsInputsCacheFile)" />
    </ItemGroup>

  </Target>

  <!--

    This target generates a manifest for development time that includes information

    about the base path for the referenced package and project static web assets. The

    manifest includes the content root and the base path for each of the referenced

    packages and projects.



    Ideally, each package/project contains a unique base path and a given content

    root, but we don't check for duplicates on either of them.

     -->

  <Target

    Name="GenerateStaticWebAssetsManifest"

    Inputs="$(_GeneratedStaticWebAssetsInputsCacheFile)"

    Outputs="$(_GeneratedStaticWebAssetsDevelopmentManifest)"

    DependsOnTargets="$(GenerateStaticWebAssetsManifestDependsOn)">

    <ItemGroup>
      <_WebRootFiles Include="@(ContentWithTargetPath)" Condition="$([System.String]::Copy('%(TargetPath)').Replace('\','/').StartsWith('wwwroot/'))" />
      <_ReferencedStaticWebAssets Include="@(StaticWebAsset)" Condition="'%(SourceType)' != ''" />
    </ItemGroup>

    <ValidateStaticWebAssetsUniquePaths

      StaticWebAssets="@(_ReferencedStaticWebAssets)"

      WebRootFiles="@(_WebRootFiles)" />

    <GenerateV1StaticWebAssetsManifest

      Condition="'@(_ExternalStaticWebAsset->Count())' != '0'"

      ContentRootDefinitions="@(_ExternalStaticWebAsset)"

      TargetManifestPath="$(_GeneratedStaticWebAssetsDevelopmentManifest)" />

    <ItemGroup Condition="'@(_ExternalStaticWebAsset->Count())' != '0'">
      <FileWrites Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)" />
    </ItemGroup>

  </Target>

  <Target Name="_IncludeGeneratedStaticWebAssetsManifest">
      <!-- This is the list of inputs that will be used for generating the manifest used during development. -->
    <ItemGroup>
      <ContentWithTargetPath

        Include="$(_GeneratedStaticWebAssetsDevelopmentManifest)"

        Condition="Exists('$(_GeneratedStaticWebAssetsDevelopmentManifest)')">
        <Pack>false</Pack>
        <TargetPath>$(TargetName).StaticWebAssets.xml</TargetPath>
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        <CopyToPublishDirectory>Never</CopyToPublishDirectory>
      </ContentWithTargetPath>
    </ItemGroup>

  </Target>

  <!--

    ============================================================

                                        Static web assets discovery related targets



    The main targets for discovering static web assets inside referenced packages, projects and

    the current project.

    ============================================================

    -->

  <!-- This target collects all the StaticWebAssets from different sources:

       * The current project StaticWebAssets that come from wwwroot\** by default.

       * Assets from referenced projects that get retrieved invoking an MSBuild target on

         the referenced projects.

       * Assets from the referenced packages. These will be implicitly included when nuget

         restores the package and includes the package props file for the package.

  -->

    <!-- StaticWebAssets from the current project come from ResolveCurrentProjectStaticWebAssetsInputs which is a dependency of this target. -->
    <!-- StaticWebAssets from referenced projects come from ResolveReferencedProjectsStaticWebAssets which is a dependency of this target. -->
    <!-- StaticWebAssets from packages are already available, so we don't do anything. -->
  <Target

    Name="ResolveStaticWebAssetsInputs"

    DependsOnTargets="$(ResolveStaticWebAssetsInputsDependsOn)" />

  <!-- This is a helper task to compute the project references we need to invoke to retrieve

       the static assets for a given application. We do it this way so that we can

       pass additional build properties to compute the assets from the package when referenced

       as a project. For example, Identity uses this hook to extend the project reference and

       pass in the bootstrap version to use.

  -->

  <Target Name="ResolveReferencedProjectsStaticWebAssets" DependsOnTargets="$(ResolveReferencedProjectsStaticWebAssetsDependsOn)">

    <ItemGroup>
      <!-- It is explicitly ok to take a dependency on _MSBuildProjectReferenceExistent as it is

        something many other products already take a dependency on. -->
      <_StaticWebAssetsProjectReference Include="@(_MSBuildProjectReferenceExistent)" />
    </ItemGroup>

    <MSBuild

      Condition="'@(_StaticWebAssetsProjectReference)' != '' and '%(_StaticWebAssetsProjectReference.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != ''"

      Targets="GetCurrentProjectStaticWebAssets"

      Properties="%(_StaticWebAssetsProjectReference.SetConfiguration); %(_StaticWebAssetsProjectReference.SetPlatform);  %(_StaticWebAssetsProjectReference.SetTargetFramework)"

      RemoveProperties="%(_StaticWebAssetsProjectReference.GlobalPropertiesToRemove)"

      Projects="@(_StaticWebAssetsProjectReference)"

      BuildInParallel="$(BuildInParallel)"

      ContinueOnError="!$(BuildingProject)"

      SkipNonexistentTargets="true">

      <Output TaskParameter="TargetOutputs" ItemName="_ReferencedProjectStaticWebAssets" />
    </MSBuild>

    <ItemGroup>
      <StaticWebAsset

        Include="@(_ReferencedProjectStaticWebAssets)"

        KeepMetadata="ContentRoot;BasePath;RelativePath;SourceId;SourceType;CopyToPublishDirectory" />
    </ItemGroup>

  </Target>

  <Target Name="ResolveCurrentProjectStaticWebAssetsInputs" DependsOnTargets="$(ResolveCurrentProjectStaticWebAssetsInputsDependsOn)">
      <ItemGroup>

      <_ThisProjectStaticWebAsset

        Include="@(Content)"

        Condition="$([System.String]::Copy('%(Identity)').Replace('\','/').StartsWith('wwwroot/'))">

        <!-- Remove the wwwroot\ prefix -->
        <RelativePath>$([System.String]::Copy('%(Identity)').Substring(8))</RelativePath>

      </_ThisProjectStaticWebAsset>

      <StaticWebAsset Include="@(_ThisProjectStaticWebAsset->'%(FullPath)')" RemoveMetadata="ExcludeFromSingleFile">
        <!-- (Package, Project, '' (CurrentProject)) -->
        <SourceType></SourceType>
        <!-- Identifier describing the source, the package id, the project name, empty for the current project.  -->
        <SourceId>$(PackageId)</SourceId>
        <!--

          Full path to the content root for the item:

          * For packages it corresponds to %userprofile%/.nuget/packages/<<PackageId>>/<<PackageVersion>>/razorContent

          * For referenced projects it corresponds to <<FullProjectRefPath>>/wwwroot

          * For the current projects it corresponds to $(MSBuildProjectDirectory)wwwroot\

        -->
        <ContentRoot>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\wwwroot\'))</ContentRoot>
        <!-- Subsection (folder) from the url space where content for this library will be served. -->
        <BasePath>$(StaticWebAssetBasePath)</BasePath>
        <!-- Relative path from the content root for the file. At publish time, we combine the BasePath + Relative

             path to determine the final path for the file.

        -->
        <RelativePath>%(RelativePath)</RelativePath>

      </StaticWebAsset>
    </ItemGroup>

  </Target>

  <!--

    Child target to retrieve content from referenced projects

   -->

  <Target Name="GetCurrentProjectStaticWebAssets"

    DependsOnTargets="$(GetCurrentProjectStaticWebAssetsDependsOn)"

    Returns="@(_ThisProjectStaticWebAssets)">

    <ItemGroup>
      <_ThisProjectStaticWebAssets

        Include="@(StaticWebAsset)"

        Condition="'%(StaticWebAsset.SourceType)' == ''">
        <SourceType>Project</SourceType>
      </_ThisProjectStaticWebAssets>
    </ItemGroup>

  </Target>

  <!--

    Forward compatibility with new version of static web assets. This target is invoked by later versions of static web assets to determine

    what targets to invoke, what properties to set, and what properties to remove when doing so, for retrieving the referenced project static

    web assets. For earlier versions of static web assets we will collect the assets and "upgrade" them newer versions by providing default

    values for the additional metadata.

  -->
  <Target Name="GetStaticWebAssetsProjectConfiguration" Returns="@(_StaticWebAssetThisProjectConfiguration)">
    <ItemGroup>
      <_StaticWebAssetThisProjectConfiguration Include="$(MSBuildProjectFullPath)">
        <Version>1</Version>
        <Source>$(PackageId)</Source>
        <StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
        <GetBuildAssetsTargets>GetCurrentProjectStaticWebAssetsV2</GetBuildAssetsTargets>
        <AdditionalBuildProperties>$(StaticWebAssetsAdditionalBuildProperties)</AdditionalBuildProperties>
        <AdditionalBuildPropertiesToRemove>$(StaticWebAssetsAdditionalBuildPropertiesToRemove)</AdditionalBuildPropertiesToRemove>
        <GetPublishAssetsTargets></GetPublishAssetsTargets>
      </_StaticWebAssetThisProjectConfiguration>
    </ItemGroup>
  </Target>

  <PropertyGroup>
    <GetCurrentProjectStaticWebAssetsV2DependsOn>GetCurrentProjectStaticWebAssets;$(GetCurrentProjectStaticWebAssetsV2DependsOn);</GetCurrentProjectStaticWebAssetsV2DependsOn>
  </PropertyGroup>

  <Target Name="GetCurrentProjectStaticWebAssetsV2" DependsOnTargets="$(GetCurrentProjectStaticWebAssetsV2DependsOn)" Returns="@(_ThisProjectStaticWebAssetItems)">
    <ItemGroup>
      <_StaticWebAssetUpgradeMetadataToKeep Include="SourceType" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="SourceId" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="BasePath" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="RelativePath" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="ContentRoot" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="AssetKind" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="AssetMode" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="AssetRole" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="RelatedAsset" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="AssetTraitName" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="AssetTraitValue" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="CopyToOutputDirectory" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="CopyToPublishDirectory" />
      <_StaticWebAssetUpgradeMetadataToKeep Include="OriginalItemSpec" />

      <_ThisProjectStaticWebAssetItems KeepMetadata="@(_StaticWebAssetUpgradeMetadataToKeep)" Include="@(_ThisProjectStaticWebAssets->'%(FullPath)')">
        <ResultType>StaticWebAsset</ResultType>
        <SourceType>Project</SourceType>
        <AssetKind Condition="'%(_ThisProjectStaticWebAssets.AssetKind)' == ''">All</AssetKind>
        <AssetMode Condition="'%(_ThisProjectStaticWebAssets.AssetMode)' == ''">All</AssetMode>
        <AssetRole Condition="'%(_ThisProjectStaticWebAssets.AssetRole)' == ''">Primary</AssetRole>
        <RelatedAsset Condition="'%(_ThisProjectStaticWebAssets.RelatedAsset)' == ''"></RelatedAsset>
        <AssetTraitName Condition="'%(_ThisProjectStaticWebAssets.AssetTraitName)' == ''"></AssetTraitName>
        <AssetTraitValue Condition="'%(_ThisProjectStaticWebAssets.AssetTraitValue)' == ''"></AssetTraitValue>
        <CopyToOutputDirectory Condition="'%(_ThisProjectStaticWebAssets.CopyToOutputDirectory)' == ''">Never</CopyToOutputDirectory>
        <CopyToPublishDirectory  Condition="'%(_ThisProjectStaticWebAssets.CopyToPublishDirectory)' == ''">PreserveNewest</CopyToPublishDirectory>
        <OriginalItemSpec Condition="'%(_ThisProjectStaticWebAssets.OriginalItemSpec)' == ''">%(_ThisProjectStaticWebAssets.Identity)</OriginalItemSpec>
      </_ThisProjectStaticWebAssetItems>
      <_ThisProjectStaticWebAssetItems Include="$(PackageId)\wwwroot" Condition="Exists('$(MSBuildProjectDirectory)\wwwroot')">
        <ResultType>StaticWebAssetDiscoveryPattern</ResultType>
        <ContentRoot>$(MSBuildProjectDirectory)\wwwroot\</ContentRoot>
        <BasePath>$(StaticWebAssetBasePath)</BasePath>
        <Source>$(PackageId)</Source>
        <Pattern>**</Pattern>
      </_ThisProjectStaticWebAssetItems>
    </ItemGroup>
  </Target>

  <!--

    ============================================================

                                        Static web assets packing related targets



    The main targets to enable auto-packing of static web assets.

    ============================================================

    -->

  <!-- We need to remove any content item under wwwroot right before packing to prevent it from getting included

       in the package as content or contentFiles. Unfortunately marking it with pack=false doesn't work as it also

       prevents the content from being packed even though we are including it explictily in

       GenerateStaticWebAssetsPackTargets

   -->
  <Target Name="_RemoveWebRootContentFromPackaging" DependsOnTargets="ResolveStaticWebAssetsInputs">
    <ItemGroup>
      <Content

        Condition="'%(StaticWebAsset.SourceType)' == ''"

        Remove="@(StaticWebAsset->'wwwroot\%(RelativePath)')"  />
    </ItemGroup>
  </Target>

  <Target

    Name="_CreateStaticWebAssetsCustomPropsCacheFile"

    DependsOnTargets="_PrepareForStaticWebAssets">

    <ItemGroup>
      <!-- This is the list of inputs that will be used for generating the props file that will be packed with

      the package.  -->
      <_CurrentProjectStaticWebAsset

        Include="@(StaticWebAsset)"

        Condition="'%(SourceType)' == ''" />
    </ItemGroup>

    <Hash ItemsToHash="@(_CurrentProjectStaticWebAsset->'%(BasePath)%(SourceId)')">
      <Output TaskParameter="HashResult" PropertyName="_StaticWebAssetsPropsFileHash" />
    </Hash>

    <WriteLinesToFile

      Lines="$(_StaticWebAssetsPropsFileHash)"

      File="$(_GeneratedStaticWebAssetsCustomPropsCacheFile)"

      Overwrite="True"

      WriteOnlyWhenDifferent="True" />

    <ItemGroup>
      <FileWrites Include="$(_GeneratedStaticWebAssetsCustomPropsCacheFile)" />
    </ItemGroup>

  </Target>

  <!-- This target makes sure that all static web assets for the current project get included

       in the package under the folder staticwebassets and generates MSBuild props files to

       ensure that consuming packages can discover and use the static web assets.

       This target generates and includes a Microsoft.AspNetCore.StaticWebAssets.props file that

       goes inside the build directory and describes the static web assets in the package as an

       item group.

       This target also generates and includes a $(PackageId).props file under the build, buildMultiTargeting

       and buildTransitive folders that are setup so that:

       * buildTransitive\$(PackageId).props simply imports buildMultitargeting\$(PackageId).props

       * buildMultitargeting\$(PackageId).props simply imports build\$(PackageId).props

       * build\$(PackageId).props simply imports Microsoft.AspNetCore.StaticWebAssets.props



       We do it this way to preserve the ability of package authors to customize the package in any way

       they see fit and to make sure the package works in all scenarios. Authors including custom MSBuild

       targets into their packages are expected to disable the generation of $(PackageId).props files and

       to manually import build\Microsoft.AspNetCore.StaticWebAssets.props in their custom props files.

   -->
  <Target

    Name="GenerateStaticWebAssetsPackTargets"

    DependsOnTargets="$(GenerateStaticWebAssetsPackTargetsDependsOn)"

    Inputs="$(_GeneratedStaticWebAssetsCustomPropsCacheFile)"

    Outputs="$(_GeneratedStaticWebAssetsPropsFile)">

    <PropertyGroup>
      <_CurrentProjectHasStaticWebAssets Condition="'@(_CurrentProjectStaticWebAsset->Count())' != '0'">true</_CurrentProjectHasStaticWebAssets>
    </PropertyGroup>

    <!-- Validate that there are no path conflicts between the assets we are about to pack. -->
    <ValidateStaticWebAssetsUniquePaths Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"

      StaticWebAssets="@(_CurrentProjectStaticWebAsset)"

      WebRootFiles="" />

    <!-- Generates a props file that goes in build\Microsoft.AspNetCore.StaticWebAssets.props

         and that describes the static web assets for the package.

     -->
    <GenerateStaticWebAsssetsPropsFile

      Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"

      StaticWebAssets="@(_CurrentProjectStaticWebAsset)"

      AllowEmptySourceType="true"

      TargetPropsFilePath="$(_GeneratedStaticWebAssetsPropsFile)" />

    <!-- Generates a props file the goes in build\$(PackageId).props and that simply imports

         build\Microsoft.AspNetCore.StaticWebAssets.props

     -->
    <StaticWebAssetsGeneratePackagePropsFile

      Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"

      PropsFileImport="$(_StaticWebAssetsPropsFileImportPath)"

      BuildTargetPath="$(_GeneratedBuildPropsFile)" />

    <!-- Generates a props file the goes in buildMultiTargeting\$(PackageId).props and that simply imports

         build\$(PackageId).props

     -->
    <StaticWebAssetsGeneratePackagePropsFile

      Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"

      PropsFileImport="$(_StaticWebAssetsGeneratedBuildPropsFileImportPath)"

      BuildTargetPath="$(_GeneratedBuildMultitargetingPropsFile)" />

    <!-- Generates a props file the goes in buildTransitive\$(PackageId).props and that simply imports

         buildMultiTargeting\$(PackageId)

     -->
    <StaticWebAssetsGeneratePackagePropsFile

      Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'"

      PropsFileImport="$(_StaticWebAssetsGeneratedBuildMultiTargetingPropsFileImportPath)"

      BuildTargetPath="$(_GeneratedBuildTransitivePropsFile)" />

    <!-- All files potentially created within this target -->
    <ItemGroup>
      <FileWrites Include="$(_GeneratedStaticWebAssetsPropsFile)" />
      <FileWrites Include="$(_GeneratedBuildPropsFile)" />
      <FileWrites Include="$(_GeneratedBuildMultitargetingPropsFile)" />
      <FileWrites Include="$(_GeneratedBuildTransitivePropsFile)" />
    </ItemGroup>

  </Target>

  <Target Name="IncludeStaticWebAssetPackItems">

    <ItemGroup>
      <!-- This is the list of inputs that will be used for generating the props file that will be packed with

      the package.  -->
      <_CurrentProjectStaticWebAsset

        Include="@(StaticWebAsset)"

        Condition="'%(SourceType)' == ''" />
    </ItemGroup>

    <PropertyGroup>
      <_CurrentProjectHasStaticWebAssets Condition="'@(_CurrentProjectStaticWebAsset->Count())' != '0'">true</_CurrentProjectHasStaticWebAssets>
    </PropertyGroup>

    <!-- All files that go into the nuget package -->
    <ItemGroup Condition="'$(_CurrentProjectHasStaticWebAssets)' == 'true'">

      <!-- MSBuild prop files -->

      <TfmSpecificPackageFile Include="$(_GeneratedStaticWebAssetsPropsFile)"

        Condition="'$(DisableStaticWebAssetsBuildPropsFileGeneration)' == ''">

        <PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.props</PackagePath>
      </TfmSpecificPackageFile>

      <TfmSpecificPackageFile Include="$(_GeneratedBuildPropsFile)"

        Condition="'$(StaticWebAssetsDisableProjectBuildPropsFileGeneration)' == ''">

        <PackagePath>build\$(PackageId).props</PackagePath>
      </TfmSpecificPackageFile>

      <TfmSpecificPackageFile Include="$(_GeneratedBuildMultitargetingPropsFile)"

        Condition="'$(StaticWebAssetsDisableProjectBuildMultiTargetingPropsFileGeneration)' == ''">

        <PackagePath>buildMultiTargeting\$(PackageId).props</PackagePath>
      </TfmSpecificPackageFile>

      <TfmSpecificPackageFile Include="$(_GeneratedBuildTransitivePropsFile)"

        Condition="'$(StaticWebAssetsDisableProjectBuildTransitivePropsFileGeneration)' == ''">

        <PackagePath>buildTransitive\$(PackageId).props</PackagePath>
      </TfmSpecificPackageFile>

      <!-- Project file contents -->

      <TfmSpecificPackageFile Include="%(_CurrentProjectStaticWebAsset.Identity)">
        <PackagePath>staticwebassets\%(_CurrentProjectStaticWebAsset.RelativePath)</PackagePath>
      </TfmSpecificPackageFile>
    </ItemGroup>

  </Target>

    <!-- This target is invoked in cross targeting builds to resolve the paths for the pack and build manifests.

         Since for static web assets V1 there is no build manifest, the cross build targets remove the items

         included in the pack manifest from the relevant content item groups.  -->
  <Target Name="ResolveStaticWebAssetsManifestPaths" DependsOnTargets="ResolveStaticWebAssetsInputs" Returns="@(_StaticWebAssetsManifestPaths)">

    <ItemGroup>

      <StaticWebAssetPackageFile Include="$(_GeneratedStaticWebAssetsPropsFile)" Condition="'$(DisableStaticWebAssetsBuildPropsFileGeneration)' == ''">
        <PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.props</PackagePath>
      </StaticWebAssetPackageFile>

      <StaticWebAssetPackageFile Include="$(_GeneratedBuildPropsFile)" Condition="'$(StaticWebAssetsDisableProjectBuildPropsFileGeneration)' == ''">
        <PackagePath>build\$(PackageId).props</PackagePath>
      </StaticWebAssetPackageFile>

      <StaticWebAssetPackageFile Include="$(_GeneratedBuildMultitargetingPropsFile)" Condition="'$(StaticWebAssetsDisableProjectBuildMultiTargetingPropsFileGeneration)' == ''">
        <PackagePath>buildMultiTargeting\$(PackageId).props</PackagePath>
      </StaticWebAssetPackageFile>

      <StaticWebAssetPackageFile Include="$(_GeneratedBuildTransitivePropsFile)" Condition="'$(StaticWebAssetsDisableProjectBuildTransitivePropsFileGeneration)' == ''">
        <PackagePath>buildTransitive\$(PackageId).props</PackagePath>
      </StaticWebAssetPackageFile>

      <_PackStaticWebAssetWithTargetPath

        Include="@(StaticWebAsset)"

        Condition="'%(SourceType)' == ''">
        <TargetPath>staticwebassets\%(StaticWebAsset.RelativePath)</TargetPath>
      </_PackStaticWebAssetWithTargetPath>
    </ItemGroup>

    <StaticWebAssetsGeneratePackManifest

      Assets="@(_PackStaticWebAssetWithTargetPath)"

      AdditionalPackageFiles="@(StaticWebAssetPackageFile->'%(FullPath)')"

      AdditionalElementsToRemoveFromPacking="@(_ThisProjectStaticWebAsset)"

      ManifestPath="$(_GeneratedStaticWebAssetsPackManifest)">
    </StaticWebAssetsGeneratePackManifest>

    <ItemGroup>
      <_StaticWebAssetsManifestPaths Include="$(MSBuildProjectName)">
        <BuildManifest></BuildManifest>
        <PackManifest>$(_GeneratedStaticWebAssetsPackManifest)</PackManifest>
      </_StaticWebAssetsManifestPaths>
    </ItemGroup>
  </Target>

  <!--

    ============================================================

                                        Static web assets publish related targets



    The main targets for publishing static web assets coming from referenced projects

    and packages.

    ============================================================

    -->

    <!--

    Called after ComputeResolvedFilesToPublishList but before CopyFilesToPublishDirectory - this target is called when

    publishing the project to get a list of files to the output directory.

  -->
  <Target

    Name="_StaticWebAssetsComputeFilesToPublish"

    AfterTargets="ComputeResolvedFilesToPublishList"

    DependsOnTargets="ResolveStaticWebAssetsInputs">

    <ItemGroup>

      <!-- Filter the static web assets foreign to the project and then add them to the list of resolved

           files to publish.

       -->
      <_ExternalPublishStaticWebAsset

        Include="%(StaticWebAsset.FullPath)"

        Condition="'%(SourceType)' != '' AND '%(StaticWebAsset.CopyToPublishDirectory)' != 'Never'">

        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
        <RelativePath>$([MSBuild]::MakeRelative('$(MSBuildProjectDirectory)','$([MSBuild]::NormalizePath('wwwroot\%(BasePath)\%(RelativePath)'))'))</RelativePath>
      </_ExternalPublishStaticWebAsset>

      <!-- Remove any existing external static web asset that might have been added as part of the

           regular publish pipeline. -->
      <ResolvedFileToPublish Remove="@(_ExternalPublishStaticWebAsset)" />

      <ResolvedFileToPublish Include="@(_ExternalPublishStaticWebAsset)">
        <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
      </ResolvedFileToPublish>
    </ItemGroup>

  </Target>

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.ScopedCss.5_0.targets" Condition="'$(UsingMicrosoftNETSdkRazor)' == 'true' And '$(ScopedCssEnabled)' == 'true'" />

</Project>