File size: 35,366 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
<!--
***********************************************************************************************
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">

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.DiscoverStaticWebAssets"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ComputeStaticWebAssetsTargetPaths"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsManifest"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetsDevelopmentManifest"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateV1StaticWebAssetsManifest"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ReadStaticWebAssetsManifestFile"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.UpdatePackageStaticWebAssets"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ValidateStaticWebAssetsUniquePaths"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.CollectStaticWebAssetsToCopy"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.MergeConfigurationProperties"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ComputePublishStaticWebAssetsList"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ComputeReferenceStaticWebAssetItems"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ComputeStaticWebAssetsForCurrentProject"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.ResolveStaticWebAssetsEmbeddedProjectConfiguration"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <UsingTask
    TaskName="Microsoft.AspNetCore.StaticWebAssets.Tasks.MergeStaticWebAssets"
    AssemblyFile="$(StaticWebAssetsSdkBuildTasksAssembly)"
    Condition="'$(StaticWebAssetsSdkBuildTasksAssembly)' != ''" />

  <!-- Static web assets define how web content needs to be served from web applications, class libraries and packages during
       development and what and where web contents need to be served on the published application.

       Static web assets deal with two concerns:
       * How to map URLs for resources to files during development to serve files from disk as if they were part of the
         wwwroot folder of the app.
       * What files to copy to the publish output folder during the publish folder.

       Static web assets will take over content items within the wwwroot folder of the application and handle all aspects of them.
       During development they will define a JSON manifest that includes the following information:
       * A version number.
       * A hash for the contents of the manifest.
       * The library package id.
       * The asset base path for the library.
       * Manifest mode.
       * The list of related projects manifests with their hashes.
       * The list of "discovery patterns"
       * The list of generated static web assets during build/publish.

       Each section identifies:
       * The version number identifies the manifest format.
       * The hash of the manifest is used for determining whether the contents of the manifest have changed.
       * The library package id is used to differentiate assets served from other projects from assets served from the current project.
       * The asset base path for the library is used to determine what base path to add when applying a discovery pattern to a path coming from another library.
       * The manifest mode defines how assets coming from a given project must be treated during build and publish.
       * The list of related projects manifests is used for determining whether the list of projects have changed since the manifest was generated or if a manifest was updated.
       * The list of "discovery patterns" is useful to enable selective assets to be served at runtime after the manifest has been built. For example
         you can use { Path: "<<Project>/Pages", "BasePath": "{_content/Something}" Pattern: "**.js" } pattern to indicate that only files with a js extension should be served from that folder, so if someone adds
         an image or something like that, it won't be served. (This is important since it is not an asset by any rule and won't be part of the publish output folder).

      We generate two sets of manifests, one build manifest and one publish manifest:
      * The build manifest is generated during the build process and is used during development to serve assets as if they were part of the application.
      * The publish manifest is generated during publish and captures all the transformations that happen during the publish process.

      Assets can be defined during the build and publish phase, and can be "marked" as such at any stage. For example, you can have two files, one that is used during
      development and one that is used on the published app that must be served from the same path. One example of this is `service-worker.js`

      The build time manifest is constructed from the combination of the discovered assets in the project and the assets that come from referenced projects and packages.
      The publish manifest uses the build manifest as a starting point, filtering out the files marked as build only and includes any transformation that happens to those files
      during the build publish process.
      * This enables transformations at publish time like `Linking`, `Bundling`, `Compresion` and other optimizations to take place during the publish step.
      * Referenced projects also produce a publish manifest and their contents are merged with the current project manifest as part of the publish process.
      * We still keep track of the original build manifest for referenced projects during the publish process to enable applications to discard the publish assets for referenced projects
        if they choose to do so and to perform optimizations over the entire transitive closure of assets.
        * For example, a library can produce a minified JS bundle to use during publish. The app can choose to instead of using multiple bundles, collect all the assets from the original build process and generate a single bundle.

      We normally expect the build and publish asset manifest to be the same except when there are publish specific transformations.

      On each manifiest we define the list of assets we generated/computed during the build/publish process and their properties. Those properties are:
        * "Identity": The identity for the asset (Full path to the file).
        * "SourceType": The type of asset ('Discovered', 'Computed', 'Project', 'Package')
        * "ContentRoot": The original path where the asset is exposed in during development.
        * "BasePath": The base path where the asset is exposed.
        * "RelativePath": The relative path for the asset.
        * "AssetKind": The asset kind ('Build', 'Publish' or 'All') This is inferred from CopyToOutputDirectory/CopyToPublishDirectory
        * "AssetMode": The asset mode ('CurrentProject', 'Reference', 'All')
        * "AssetRole": The asset role ('Primary', 'Related', 'Alternative')
        * "AssetMergeSource": The source of the asset when it is being embedded in another TFM.
        * "AssetMergeBehavior": The merge behavior when an asset conflicts with another asset in the same TFM.
        * "RelatedAsset": The Identity of the asset this asset depends on.
        * "AssetTraitName": The name of the trait or characteristic that differentiates this related or dependent asset from a primary asset.
        * "AssetTraitValue": The value of the trait or characteristic that differentiates this related or dependent asset from a primary asset.
        * "CopyToBuildDirectory": Same from Content (PreserveNewest, Always)
        * "CopyToPublishDirectory": Same from Content (PreserveNewest, Always)
        * "OriginalItemSpec": The original spec from where the item was defined

      With regards to how assets are consumed in different scenarios (when they are part of the main project being built or are consumed as a reference) there are three posible options:
      * All: Which means the asset must be used in all situations.
      * Root: Which means the asset must only be considered when the main project is being built.
      * Reference: Which means the asset must only be considered when the project is being consumed as a reference.

      An example of this are the bundles that we produce for CSS isolation:
      * One bundle `<<Project>>.styles.css` is a Root asset and must only be used when the asset is part of the root of the project.
      * The other bundle `<<Project>>.lib.bundle.css` is a Reference asset and must only be used when the asset is being referenced by another project.

      Along with these three modes of operations, projects also define how they operate during build and publish with regards to the files on the manifest. In this regards there are three options:
      * Default: The project copies all the contents to the publish output folder during publish and does not do anything when being referenced from another project. When the project
        is being referenced by another project, it will expect that project to take care of publishing the static web assets.
      * Root: The asset must be considered "a root" for defining static web assets and while a referencing project will still manage the assets,
        they need to be copied to the output folder as if they were being published as the root.
      * Isolated: Its the same as Root with the difference that any referencing project doesn't know anything about static web assets and the project will wire-up handlers for copying the assets to

        the right locations during publish.



      Default is used by class libraries, since they don't copy their assets themselves but rely on a referencing project to copy them to the final publish output folder.
      Root is used by projects like Blazor webassembly hosted where while the project is "referenced" by the hosting ASP.NET Core project, the assets should be considered as if they were
      the root project, so for example, transitive assets are not copied and instead the Root assets were copied instead.
      Isolated is used by projects like Blazor desktop to fold the static web assets into `GetCopyToPublishDirectoryItems` so that any project that references it, doesn't require any knowledge

      of static web assets to work.



      With regards to types of assets, there are four categories that describe static web assets:

      * Discovered assets: These represents assets that were discovered from existing items in the project (Content, None, etc.)

      * Computed assets: Represents assets that were generated as part of the build process and that need to be copied to their final locations during the build.

      * Project: Represents assets that come from a referenced projects.

        * Discovered and Computed assets are transformed into Project assets when manifests from referenced projects get merged.

      * Package: These assets come from a referenced package.



      With regards to asset roles, there are three roles that an asset can play:

      * Primary asset: This value indicates that the asset represents a resource that will be addressable at the appropriate relative path.

        The majority of assets will be part of this role.

      * Related asset: This value indicates that the asset is related to another asset, while maintaining that both assets should be addressable at their own relative paths.

      * Alternative asset: This value indicates that the asset is an alternative representation for the related asset. This can be for example, an asset that is pre-compressed

        or an alternative format for the asset. The expectation is that an alternative asset is served from the same relative path as their related asset. Although its up to

        the runtimes to decide if/how to implement that. At the static web asset level we just make sure we capture the information about the relationship.



      For Related and Alternative assets the RelatedAsset property points to another asset that they depend on. This chain can be extended multiple levels to represent scenarios

      where multiple representations of an asset are produced. Again, static web assets only captures this information, its up to MSBuild targets to decide what to do with it.



      The AssetTraitName and AssetTraitValue define the discriminator between a related or alternative asset and their associated primary asset. In the case of globalization assemblies

      this can capture the assembly culture, in the case of compressed asset it can capture the encoding and the specific encoding format.



      General build/publish flow:

      During a build for the project the following happens:

        PrepareForRun ->

          GenerateStaticWebAssetsManifest ->

            ResolveStaticWebAssetsInputs ->

              ResolveProjectStaticWebAssets;

              ResolveEmbeddedProjectStaticWebAssets;

              ResolveReferencedProjectStaticWebAssetsConfiguration;

              ResolveEmbeddedConfigurationsReferencedProjects;

              ResolveReferencedProjectsStaticWebAssets;

                Invokes the targets returned in ResolveReferencedProjectStaticWebAssetsConfiguration to get the static web assets build

                items from the referenced project.

              (* ResolvePackageStaticWebAssets doesn't need a target, they get defined in the package props file)
              ResolveEmbeddedConfigurationsPackageReferences (* We need to get the package assets that we might need to include in this build
              that come from a TFM we are embedding)
          GetCopyToOutputDirectoryItems ->
            AddStaticWebAssetsManifest
          CopyStaticWebAssetsToOutputDirectory
            MaterializeComputedStaticWebAssets

      During the publish flow for the project the following happens:
        ComputeFilesToPublish ->
          StaticWebAssetsPrepareForPublish ->
            GenerateStaticWebAssetsPublishManifest ->
              ResolvePublishStaticWebAssets ->
                LoadStaticWebAssetsBuildManifest;
                ComputeReferencedProjectsPublishAssets;
                  Invokes ComputeReferencedStaticWebAssetsPublishManifest on referenced projects and gets the list of publish assets.

        // This target is only called by referencing projects, which helps us
        ComputeReferencedStaticWebAssetsPublishManifest ->
          GenerateStaticWebAssetsPublishManifest

          CopyStaticWebAssetsToPublishDirectory ->
            LoadStaticWebAssetsPublishManifest;

        GetCopyToPublishDirectoryItems (only on self-contained mode) ->
          AddStaticWebAssetsToTheListOfResolvedAssetsToPublish ->
            GenerateStaticWebAssetsPublishManifest ->
              ResolvePublishStaticWebAssets ->
                LoadStaticWebAssetsBuildManifest;
                ComputeReferencedProjectsPublishAssets;
                  Invokes ComputeReferencedStaticWebAssetsPublishManifest on referenced projects and gets the list of publish assets.
  -->

  <!-- Dependency definitions -->

  <PropertyGroup>

    <!-- For preview only, to ease in the new implementation -->
    <PrepareForRunDependsOn>StaticWebAssetsPrepareForRun;$(PrepareForRunDependsOn)</PrepareForRunDependsOn>

    <StaticWebAssetsPrepareForRunDependsOn>$(StaticWebAssetsPrepareForRunDependsOn);GenerateStaticWebAssetsManifest;GenerateComputedBuildStaticWebAssets;CopyStaticWebAssetsToOutputDirectory</StaticWebAssetsPrepareForRunDependsOn>

    <!-- This is a hook for features like scoped CSS and Blazor can ensure all the assets have been generated -->
    <GenerateComputedBuildStaticWebAssetsDependsOn></GenerateComputedBuildStaticWebAssetsDependsOn>

    <GenerateStaticWebAssetsManifestDependsOn>$(GenerateStaticWebAssetsManifestDependsOn);ResolveStaticWebAssetsInputs</GenerateStaticWebAssetsManifestDependsOn>

    <ResolveStaticWebAssetsInputsDependsOn>UpdateExistingPackageStaticWebAssets;ResolveProjectStaticWebAssets;ResolveEmbeddedProjectsStaticWebAssets;ResolveReferencedProjectsStaticWebAssets;$(ResolveStaticWebAssetsInputsDependsOn)</ResolveStaticWebAssetsInputsDependsOn>

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

    <CopyStaticWebAssetsToOutputDirectoryDependsOn>LoadStaticWebAssetsBuildManifest;$(CopyStaticWebAssetsToOutputDirectoryDependsOn)</CopyStaticWebAssetsToOutputDirectoryDependsOn>

    <!-- StaticWebAssetsPrepareForPublish -> ComputeFilesToPublish -->

    <StaticWebAssetsPrepareForPublishDependsOn>$(StaticWebAssetsPrepareForPublishDependsOn);ResolveStaticWebAssetsConfiguration;GenerateStaticWebAssetsPublishManifest;GenerateComputedPublishStaticWebAssets</StaticWebAssetsPrepareForPublishDependsOn>

    <GenerateStaticWebAssetsPublishManifestDependsOn>ResolveStaticWebAssetsConfiguration;ResolvePublishStaticWebAssets;$(GenerateStaticWebAssetsPublishManifestDependsOn)</GenerateStaticWebAssetsPublishManifestDependsOn>

    <!-- This is a hook for features like scoped CSS and Blazor can ensure all the assets have been generated -->
    <GenerateComputedPublishStaticWebAssetsDependsOn></GenerateComputedPublishStaticWebAssetsDependsOn>

    <ComputeReferencedStaticWebAssetsPublishManifestDependsOn>
      $(ComputeReferencedStaticWebAssetsPublishManifestDependsOn);
      StaticWebAssetsPrepareForPublish;
    </ComputeReferencedStaticWebAssetsPublishManifestDependsOn>

    <ResolvePublishStaticWebAssetsDependsOn>LoadStaticWebAssetsBuildManifest;ComputeReferencedProjectsEmbeddedPublishAssets;ComputeReferencedProjectsPublishAssets;$(ResolvePublishStaticWebAssetsDependsOn)</ResolvePublishStaticWebAssetsDependsOn>

    <CopyStaticWebAssetsToPublishDirectoryDependsOn>StaticWebAssetsPrepareForPublish;LoadStaticWebAssetsPublishManifest;$(CopyStaticWebAssetsToPublishDirectoryDependsOn)</CopyStaticWebAssetsToPublishDirectoryDependsOn>

  </PropertyGroup>

  <!-- Static web assets canonical metadata -->
  <ItemGroup>

    <!-- Static web assets metadata -->
    <_StaticWebAssetCanonicalMetadata Include="SourceType" />
    <_StaticWebAssetCanonicalMetadata Include="SourceId" />
    <_StaticWebAssetCanonicalMetadata Include="BasePath" />
    <_StaticWebAssetCanonicalMetadata Include="RelativePath" />
    <_StaticWebAssetCanonicalMetadata Include="ContentRoot" />
    <_StaticWebAssetCanonicalMetadata Include="AssetKind" />
    <_StaticWebAssetCanonicalMetadata Include="AssetMode" />
    <_StaticWebAssetCanonicalMetadata Include="AssetRole" />
    <_StaticWebAssetCanonicalMetadata Include="AssetMergeSource" />
    <_StaticWebAssetCanonicalMetadata Include="AssetMergeBehavior" />
    <_StaticWebAssetCanonicalMetadata Include="RelatedAsset" />
    <_StaticWebAssetCanonicalMetadata Include="AssetTraitName" />
    <_StaticWebAssetCanonicalMetadata Include="AssetTraitValue" />
    <_StaticWebAssetCanonicalMetadata Include="CopyToOutputDirectory" />
    <_StaticWebAssetCanonicalMetadata Include="CopyToPublishDirectory" />
    <_StaticWebAssetCanonicalMetadata Include="OriginalItemSpec" />

    <!-- Static web assets discovery pattern metadata -->
    <_StaticWebAssetDiscoveryPatternCanonicalMetadata Include="Source" />
    <_StaticWebAssetDiscoveryPatternCanonicalMetadata Include="BasePath" />
    <_StaticWebAssetDiscoveryPatternCanonicalMetadata Include="ContentRoot" />
    <_StaticWebAssetDiscoveryPatternCanonicalMetadata Include="Pattern" />

    <!-- Static web assets project configuration metadata -->
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="Version" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="Source" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="TargetFramework" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="GetBuildAssetsTargets" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="GetPublishAssetsTargets" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="AdditionalBuildProperties" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="AdditionalBuildPropertiesToRemove" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="AdditionalPublishProperties" />
    <_StaticWebAssetProjectConfigurationCanonicalMetadata Include="AdditionalPublishPropertiesToRemove" />

    <!-- Embedded project configuration -->
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="Version" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="Source" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="TargetFramework" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="GetEmbeddedBuildAssetsTargets" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="GetEmbeddedPublishAssetsTargets" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="AdditionalEmbeddedBuildProperties" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="AdditionalEmbeddedBuildPropertiesToRemove" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="AdditionalEmbeddedPublishProperties" />
    <_StaticWebAssetEmbeddedProjectConfigurationCanonicalMetadata Include="AdditionalEmbeddedPublishPropertiesToRemove" />

  </ItemGroup>

  <Target Name="ResolveStaticWebAssetsConfiguration">
    <PropertyGroup>
      <StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">_content/$(PackageId)</StaticWebAssetBasePath>
      <StaticWebAssetProjectMode Condition="'$(StaticWebAssetProjectMode)' == ''">Default</StaticWebAssetProjectMode>
      <StaticWebAssetMergeTarget Condition="'$(TargetFrameworks)' != '' and '$(TargetPlatformIdentifier)' == 'browser'">Browser</StaticWebAssetMergeTarget>
      <StaticWebAssetMergeTarget Condition="'$(TargetFrameworks)' != '' and '$(TargetPlatformIdentifier)' == ''">Server</StaticWebAssetMergeTarget>

      <!-- Manifest paths -->
      <_StaticWebAssetsManifestBase Condition="'$(_StaticWebAssetsManifestBase)' == ''">$(IntermediateOutputPath)</_StaticWebAssetsManifestBase>
      <StaticWebAssetBuildManifestPath>$(_StaticWebAssetsManifestBase)staticwebassets.build.json</StaticWebAssetBuildManifestPath>
      <StaticWebAssetPackManifestPath>$(_StaticWebAssetsManifestBase)staticwebassets.pack.json</StaticWebAssetPackManifestPath>
      <StaticWebAssetDevelopmentManifestPath>$(_StaticWebAssetsManifestBase)staticwebassets.development.json</StaticWebAssetDevelopmentManifestPath>
      <StaticWebAssetPublishManifestPath>$(_StaticWebAssetsManifestBase)staticwebassets.publish.json</StaticWebAssetPublishManifestPath>

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

      <!-- 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>

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

    </PropertyGroup>

    <MakeDir
      Directories="$(_StaticWebAssetsManifestBase)"
      Condition="!Exists('$(_StaticWebAssetsManifestBase)')" />

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

  <!-- Build -->

  <Target Name="_EnsureContentRootFolders" AfterTargets="LoadStaticWebAssetsBuildManifest">
    <ItemGroup>
      <_StaticWebAssetContentRootFolder Include="@(StaticWebAsset->'%(ContentRoot)')" Condition="'%(SourceType)' == 'Computed'" />
    </ItemGroup>
    <MakeDir Directories="@(_StaticWebAssetContentRootFolder)" />
  </Target>

  <Target Name="CopyStaticWebAssetsToOutputDirectory" DependsOnTargets="$(CopyStaticWebAssetsToOutputDirectoryDependsOn)" />

  <Target Name="_SplitStaticWebAssetsByCopyOptions" AfterTargets="CopyStaticWebAssetsToOutputDirectory">

    <CollectStaticWebAssetsToCopy Assets="@(StaticWebAsset)" OutputPath="$(OutputPath)\wwwroot\">

      <Output TaskParameter="AssetsToCopy" ItemName="_BuildStaticWebAssetsTargetPath" />
    </CollectStaticWebAssetsToCopy>

    <ItemGroup>
      <_BuildStaticWebAssetsCopyAlways Include="@(_BuildStaticWebAssetsTargetPath)" Condition="'%(CopyToOutputDirectory)' == 'Always'" />
      <_BuildStaticWebAssetsPreserveNewest Include="@(_BuildStaticWebAssetsTargetPath)" Condition="'%(CopyToOutputDirectory)' == 'PreserveNewest'" />
    </ItemGroup>

  </Target>

  <Target Name="_BuildCopyStaticWebAssetsPreserveNewest"
    Inputs="@(_BuildStaticWebAssetsPreserveNewest)"
    Outputs="@(_BuildStaticWebAssetsPreserveNewest->'%(TargetPath)')"
    AfterTargets="_SplitStaticWebAssetsByCopyOptions">

    <Copy SourceFiles="@(_BuildStaticWebAssetsPreserveNewest)"
      DestinationFiles="@(_BuildStaticWebAssetsPreserveNewest->'%(TargetPath)')"
      OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
      Retries="$(CopyRetryCount)"
      RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
      UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
      UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">

      <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>

    </Copy>

  </Target>

  <Target Name="_BuildCopyStaticWebAssetsAlways"
    AfterTargets="_SplitStaticWebAssetsByCopyOptions">

    <Copy SourceFiles="@(_BuildStaticWebAssetsCopyAlways)"
      DestinationFiles="@(_BuildStaticWebAssetsCopyAlways->'%(TargetPath)')"
      OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
      Retries="$(CopyRetryCount)"
      RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
      UseHardlinksIfPossible="$(CreateHardLinksForPublishFilesIfPossible)"
      UseSymboliclinksIfPossible="$(CreateSymbolicLinksForPublishFilesIfPossible)">

      <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>

    </Copy>

  </Target>

  <Target Name="AddStaticWebAssetsManifest" DependsOnTargets="ResolveStaticWebAssetsConfiguration">
    <ItemGroup>
      <ContentWithTargetPath Condition="Exists('$(StaticWebAssetDevelopmentManifestPath)')"
        Include="$(StaticWebAssetDevelopmentManifestPath)"
        TargetPath="$(TargetName).staticwebassets.runtime.json"
        CopyToOutputDirectory="PreserveNewest"
        CopyToPublishDirectory="Never" />
    </ItemGroup>
  </Target>

  <Target Name="StaticWebAssetsPrepareForRun" DependsOnTargets="$(StaticWebAssetsPrepareForRunDependsOn)" />

  <!-- Invoked by VS to re-generate scoped css bundle during hot reload -->
  <Target Name="UpdateStaticWebAssetsDesignTime" DependsOnTargets="ResolveReferencedProjectsStaticWebAssets;GenerateComputedBuildStaticWebAssets" />

  <Target Name="GenerateComputedBuildStaticWebAssets" DependsOnTargets="$(GenerateComputedBuildStaticWebAssetsDependsOn)" />

  <Target Name="GenerateStaticWebAssetsManifest" DependsOnTargets="$(GenerateStaticWebAssetsManifestDependsOn)">

    <MergeStaticWebAssets Condition="'@(StaticWebAssetsEmbeddedConfiguration)' != ''"
      CandidateAssets="@(StaticWebAsset)"
      CandidateDiscoveryPatterns="@(StaticWebAssetDiscoveryPattern)"
      MergeTarget="@(StaticWebAssetMergeTarget)">
      <Output TaskParameter="MergedAssets" ItemName="_MergedStaticWebAsset" />
      <Output TaskParameter="MergedDiscoveryPatterns" ItemName="_MergedStaticWebAssetDiscoveryPattern" />
    </MergeStaticWebAssets>

    <ItemGroup Condition="'@(StaticWebAssetsEmbeddedConfiguration)' != ''">
      <StaticWebAsset Remove="@(StaticWebAsset)" />
      <StaticWebAsset Include="@(_MergedStaticWebAsset)" />
      <StaticWebAssetDiscoveryPattern Remove="@(StaticWebAssetDiscoveryPattern)" />
      <StaticWebAssetDiscoveryPattern Include="@(_MergedStaticWebAssetDiscoveryPattern)" />
    </ItemGroup>

    <GenerateStaticWebAssetsManifest
      Source="$(PackageId)"
      BasePath="$(StaticWebAssetBasePath)"
      Mode="$(StaticWebAssetProjectMode)"
      ManifestType="Build"
      ReferencedProjectsConfigurations="@(StaticWebAssetProjectConfiguration)"
      DiscoveryPatterns="@(StaticWebAssetDiscoveryPattern)"
      Assets="@(StaticWebAsset)"
      ManifestPath="$(StaticWebAssetBuildManifestPath)">
    </GenerateStaticWebAssetsManifest>

    <GenerateStaticWebAssetsDevelopmentManifest
      DiscoveryPatterns="@(StaticWebAssetDiscoveryPattern)"
      Assets="@(StaticWebAsset)"
      Source="$(PackageId)"
      ManifestPath="$(StaticWebAssetDevelopmentManifestPath)">
    </GenerateStaticWebAssetsDevelopmentManifest>

    <ItemGroup>
      <FileWrites Include="$(StaticWebAssetBuildManifestPath)" />
      <FileWrites Include="$(StaticWebAssetDevelopmentManifestPath)" />
    </ItemGroup>

  </Target>

  <Target Name="ResolveStaticWebAssetsInputs" DependsOnTargets="$(ResolveStaticWebAssetsInputsDependsOn)" />

  <Target Name="ResolveProjectStaticWebAssets"
    Condition="'$(NoBuild)' != 'true'"
    BeforeTargets="AssignTargetPaths"
    DependsOnTargets="ResolveStaticWebAssetsConfiguration">

    <DiscoverStaticWebAssets
      Candidates="@(Content)"
      SourceId="$(PackageId)"
      Pattern="wwwroot/**"
      ContentRoot="$(MSBuildProjectDirectory)\wwwroot\"

      BasePath="$(StaticWebAssetBasePath)"
      AssetMergeSource="$(StaticWebAssetMergeTarget)"
    >
      <Output TaskParameter="DiscoveredStaticWebAssets" ItemName="StaticWebAsset" />
    </DiscoverStaticWebAssets>

    <ItemGroup>

      <StaticWebAssetDiscoveryPattern Include="$(PackageId)\wwwroot" Condition="Exists('$(MSBuildProjectDirectory)\wwwroot')">
        <Source>$(PackageId)</Source>
        <BasePath>$(StaticWebAssetBasePath)</BasePath>
        <ContentRoot>$(MSBuildProjectDirectory)\wwwroot\</ContentRoot>
        <Pattern>**</Pattern>
      </StaticWebAssetDiscoveryPattern>

      <Content Remove="@(StaticWebAsset)" />
    </ItemGroup>

  </Target>

  <Target Name="UpdateExistingPackageStaticWebAssets">
    <UpdatePackageStaticWebAssets Assets="@(StaticWebAsset)">
      <Output TaskParameter="UpdatedAssets" ItemName="_UpdatedPackageAssets" />
      <Output TaskParameter="OriginalAssets" ItemName="_OriginalPackageAssets" />
    </UpdatePackageStaticWebAssets>

    <ItemGroup>
      <StaticWebAsset Remove="@(_OriginalPackageAssets)"/>
      <StaticWebAsset Include="@(_UpdatedPackageAssets)" />
    </ItemGroup>
  </Target>

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.Publish.targets" />

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.References.targets" />

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.EmbeddedAssets.targets" />

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.Pack.targets" />

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

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.JSModules.targets" Condition="'$(JSModulesEnabled)' == 'true'" />

  <Import Project="Microsoft.NET.Sdk.StaticWebAssets.Compression.targets" Condition="'$(CompressionEnabled)' == 'true'" />

</Project>