Skip to content

Commit e2df786

Browse files
committed
Cleanup interop build
1 parent 79599bf commit e2df786

File tree

4 files changed

+58
-25
lines changed

4 files changed

+58
-25
lines changed

src/Components/Blazor/WebAssembly.Authentication/src/Interop/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"description": "Interop layer for Microsoft.AspNetCore.Components.WebAssembly.Authentication",
55
"scripts": {
66
"build": "npm run build:release",
7-
"build:release": "webpack --mode production --env.production",
8-
"build:debug": "webpack --mode development",
7+
"build:release": "webpack --mode production --env.production --env.configuration=Release",
8+
"build:debug": "webpack --mode development --env.configuration=Debug",
99
"watch": "webpack --watch --mode development"
1010
},
1111
"repository": {

src/Components/Blazor/WebAssembly.Authentication/src/Interop/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = env => {
1919
},
2020
output: {
2121
filename: 'AuthenticationService.js',
22-
path: path.resolve(__dirname, '..', 'wwwroot'),
22+
path: path.resolve(__dirname, 'dist', env.configuration),
2323
},
2424
};
2525
};

src/Components/Blazor/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,8 @@
88
<IsShippingPackage>true</IsShippingPackage>
99
<HasReferenceAssembly>false</HasReferenceAssembly>
1010
<RazorLangVersion>3.0</RazorLangVersion>
11-
<YarnWorkingDir>$(MSBuildThisFileDirectory)Interop\</YarnWorkingDir>
12-
<ResolveCurrentProjectStaticWebAssetsInputsDependsOn>
13-
CompileInterop;
14-
$(ResolveCurrentProjectStaticWebAssetsInputsDependsOn)
15-
</ResolveCurrentProjectStaticWebAssetsInputsDependsOn>
1611
</PropertyGroup>
1712

18-
<ItemGroup>
19-
<Content Remove="$(YarnWorkingDir)*" />
20-
<Content Remove="wwwroot\.gitignore" />
21-
<YarnInputs Include="$(YarnWorkingDir)**" Exclude="$(YarnWorkingDir)node_modules\**;$(YarnWorkingDir)*.d.ts" />
22-
<YarnOutputs Include="wwwroot\AuthenticationService.js" />
23-
<YarnOutputs Include="wwwroot\AuthenticationService.js.map" />
24-
<Content Include="@(YarnOutputs)" />
25-
<None Include="Interop\AuthenticationService.ts" />
26-
<None Include="Interop\package.json" />
27-
<None Include="Interop\tsconfig.json" />
28-
<None Include="Interop\webpack.config.js" />
29-
<None Include="Interop\yarn.lock" />
30-
<None Include="wwwroot\.gitignore" />
31-
</ItemGroup>
32-
3313
<ItemGroup>
3414
<Reference Include="Mono.WebAssembly.Interop" />
3515
<Reference Include="Microsoft.AspNetCore.Blazor" />
@@ -42,13 +22,66 @@
4222
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication.Tests" />
4323
</ItemGroup>
4424

45-
<Target Name="CompileInterop" Condition="'$(DesignTimeBuild)' != 'true'" Inputs="@(YarnInputs)" Outputs="@(YarnOutputs)">
25+
<PropertyGroup>
26+
<YarnWorkingDir>$(MSBuildThisFileDirectory)Interop\</YarnWorkingDir>
27+
<ResolveCurrentProjectStaticWebAssetsInputsDependsOn>
28+
CompileInterop;
29+
$(ResolveCurrentProjectStaticWebAssetsInputsDependsOn)
30+
</ResolveCurrentProjectStaticWebAssetsInputsDependsOn>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<YarnInputs Include="$(YarnWorkingDir)**" Exclude="$(YarnWorkingDir)node_modules\**;$(YarnWorkingDir)*.d.ts;$(YarnWorkingDir)dist\**" />
35+
<YarnOutputs Include="$(YarnWorkingDir)dist\$(Configuration)\AuthenticationService.js" />
36+
<YarnOutputs Include="$(YarnWorkingDir)dist\$(Configuration)\AuthenticationService.js.map" Condition="'$(Configuration)' == 'Debug'" />
37+
38+
<Content Remove="$(YarnWorkingDir)**" />
39+
<None Include="$(YarnWorkingDir)*" Exclude="$(YarnWorkingDir)node_modules\**" />
40+
</ItemGroup>
41+
42+
<Target Name="_CreateInteropHash" BeforeTargets="CompileInterop" Condition="'$(DesignTimeBuild)' != 'true'">
43+
44+
<PropertyGroup>
45+
<InteropCompilationCacheFile>$(IntermediateOutputPath)interop.cache</InteropCompilationCacheFile>
46+
</PropertyGroup>
47+
48+
<Hash ItemsToHash="@(YarnInputs)">
49+
<Output TaskParameter="HashResult" PropertyName="_YarnInputsHash" />
50+
</Hash>
51+
52+
<WriteLinesToFile
53+
Lines="$(_YarnInputsHash)"
54+
File="$(InteropCompilationCacheFile)"
55+
Overwrite="True"
56+
WriteOnlyWhenDifferent="True" />
57+
58+
<ItemGroup>
59+
<FileWrites Include="$(InteropCompilationCacheFile)" />
60+
</ItemGroup>
61+
62+
</Target>
63+
64+
<Target Name="CompileInterop" Condition="'$(DesignTimeBuild)' != 'true'" Inputs="$(InteropCompilationCacheFile)" Outputs="@(YarnOutputs)">
4665
<Yarn Command="install --mutex network" WorkingDirectory="$(YarnWorkingDir)" />
4766
<Yarn Command="run build:release" WorkingDirectory="$(YarnWorkingDir)" Condition="'$(Configuration)' == 'Release'" />
4867
<Yarn Command="run build:debug" WorkingDirectory="$(YarnWorkingDir)" Condition="'$(Configuration)' == 'Debug'" />
68+
4969
<ItemGroup>
50-
<Content Include="$(YarnOutputPattern)" />
70+
<_InteropBuildOutput Include="$(YarnWorkingDir)dist\$(Configuration)\**" Exclude="$(YarnWorkingDir)dist\.gitignore" />
71+
72+
<StaticWebAsset Include="@(_InteropBuildOutput->'%(FullPath)')">
73+
<SourceType></SourceType>
74+
<SourceId>$(PackageId)</SourceId>
75+
<ContentRoot>$([MSBuild]::NormalizeDirectory('$(YarnWorkingDir)\dist\$(Configuration)'))</ContentRoot>
76+
<BasePath>_content/$(PackageId)</BasePath>
77+
<RelativePath>$([System.String]::Copy('%(RecursiveDir)%(FileName)%(Extension)').Replace('\','/'))</RelativePath>
78+
</StaticWebAsset>
79+
80+
<FileWrites Include="$(_InteropBuildOutput)" />
5181
</ItemGroup>
82+
83+
<Message Importance="high" Text="@(_InteropBuildOutput->'Emitted %(FullPath)')" />
84+
5285
</Target>
5386

5487
</Project>

0 commit comments

Comments
 (0)