1
+ <Project >
2
+ <!--
3
+ Copied from: https://github.com/aspnet/AspLabs/blob/main/src/ClientAssets/Microsoft.AspNetCore.ClientAssets/build/netstandard2.0/Microsoft.AspNetCore.ClientAssets.targets
4
+
5
+ More information:
6
+ - https://devblogs.microsoft.com/dotnet/build-client-web-assets-for-your-razor-class-library/
7
+ - https://github.com/dotnet/aspnetcore/issues/38445
8
+ -->
9
+ <PropertyGroup >
10
+ <ClientAssetsDirectory Condition =" '$(ClientAssetsDirectory)' == ''" >Client\</ClientAssetsDirectory >
11
+ <ClientAssetsRestoreInputs Condition =" '$(ClientAssetsRestoreInputs)' == ''" >$(ClientAssetsDirectory)\package-lock.json;$(ClientAssetsDirectory)\package.json</ClientAssetsRestoreInputs >
12
+ <ClientAssetsRestoreOutputs Condition =" '$(ClientAssetsRestoreOutputs)' == ''" >$(ClientAssetsDirectory)node_modules\.package-lock.json</ClientAssetsRestoreOutputs >
13
+ <ClientAssetsRestoreCommand Condition =" '$(ClientAssetsRestoreCommand)' == ''" >npm ci --no-fund --no-audit --prefer-offline</ClientAssetsRestoreCommand >
14
+ <ClientAssetsBuildCommand Condition =" '$(ClientAssetsBuildCommand)' == ''" >npm run build</ClientAssetsBuildCommand >
15
+
16
+ <!-- Include project file to pick up changes in the above values -->
17
+ <ClientAssetsRestoreInputs >$(MSBuildProjectFile);$(ClientAssetsRestoreInputs)</ClientAssetsRestoreInputs >
18
+ <!-- Run restore only once for multi targeting builds -->
19
+ <ClientAssetsRestoreBeforeTargets Condition =" '$(TargetFramework)' == ''" >DispatchToInnerBuilds</ClientAssetsRestoreBeforeTargets >
20
+ <!-- Allow multitargeting projects to choose the target framework in which they run by setting this value to true only for a given target framework -->
21
+ <ShouldRunClientAssetsBuild Condition =" '$(ShouldRunClientAssetsBuild)' == ''" >true</ShouldRunClientAssetsBuild >
22
+ </PropertyGroup >
23
+
24
+ <ItemGroup >
25
+ <ClientAssetsInputs Include =" $(ClientAssetsDirectory)**" Exclude =" $(DefaultItemExcludes)" />
26
+ </ItemGroup >
27
+
28
+ <Target Name =" ClientAssetsRestore" BeforeTargets =" $(ClientAssetsRestoreBeforeTargets)" Inputs =" $(ClientAssetsRestoreInputs)" Outputs =" $(ClientAssetsRestoreOutputs)" >
29
+ <Message Text =" Restoring NPM packages" Importance =" high" />
30
+ <Exec Command =" $(ClientAssetsRestoreCommand)" WorkingDirectory =" $(ClientAssetsDirectory)" />
31
+ </Target >
32
+
33
+ <Target Name =" ClientAssetsBuild" Condition =" '$(ShouldRunClientAssetsBuild)' == 'true'" DependsOnTargets =" ClientAssetsRestore" BeforeTargets =" AssignTargetPaths" Inputs =" @(ClientAssetsInputs)" Outputs =" $(IntermediateOutputPath)clientassetsbuild.complete.txt" >
34
+ <PropertyGroup >
35
+ <_ClientAssetsOutputFullPath >$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)clientassets'))</_ClientAssetsOutputFullPath >
36
+ </PropertyGroup >
37
+
38
+ <Message Text =" Executing NPM build script" Importance =" High" />
39
+
40
+ <MakeDir Directories =" $(_ClientAssetsOutputFullPath)" />
41
+ <Exec Command =" $(ClientAssetsBuildCommand)" WorkingDirectory =" $(ClientAssetsDirectory)" />
42
+
43
+ <ItemGroup >
44
+ <_ClientAssetsBuildOutput Include =" $(IntermediateOutputPath)clientassets\**" ></_ClientAssetsBuildOutput >
45
+ </ItemGroup >
46
+
47
+ <WriteLinesToFile File =" $(IntermediateOutputPath)clientassetsbuild.complete.txt" Lines =" @(_ClientAssetsBuildOutput)" />
48
+ </Target >
49
+
50
+ <Target Name =" DefineClientAssets" AfterTargets =" ClientAssetsBuild" DependsOnTargets =" ResolveStaticWebAssetsConfiguration" >
51
+ <ItemGroup >
52
+ <FileWrites Include =" @(_ClientAssetsBuildOutput)" />
53
+ <FileWrites Include =" $(IntermediateOutputPath)clientassetsbuild.complete.txt" />
54
+ </ItemGroup >
55
+
56
+ <DefineStaticWebAssets CandidateAssets =" @(_ClientAssetsBuildOutput)" SourceId =" $(PackageId)" SourceType =" Computed" ContentRoot =" $(_ClientAssetsOutputFullPath)" BasePath =" $(StaticWebAssetBasePath)" >
57
+ <Output TaskParameter =" Assets" ItemName =" StaticWebAsset" />
58
+ </DefineStaticWebAssets >
59
+ </Target >
60
+
61
+ </Project >
0 commit comments