-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
WasmApp.LocalBuild.targets
80 lines (63 loc) · 4.44 KB
/
WasmApp.LocalBuild.targets
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
<!--
WasmApp.LocalBuild* files are meant for projects that want to use
a local build of `dotnet/runtime` repo.
Two ways to use this:
1. Use a local runtime build from the source directory:
Required properties to be set:
$(RuntimeSrcDir) - path to the runtime checkout. This should have already been
built, and so should have `artifacts` directory.
$(RuntimeConfig) - This is the config that the above checkout was built with.
This can be different from the configuration for the user project.
2. Use a local directory which has all the tasks, targets, runtimepack available
Required properties to be set:
$(WasmBuildSupportDir)
-->
<Project>
<Import Project="$(_WasmTargetsDir)$(_TargetsBaseName).targets" />
<UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />
<UsingTask TaskName="ILStrip" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<UsingTask TaskName="RuntimeConfigParserTask" AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />
<PropertyGroup>
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' != 'Debug'">
<!-- Runtime feature defaults to trim unnecessary code -->
<EventSourceSupport>false</EventSourceSupport>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<DebuggerSupport>false</DebuggerSupport>
<MetricsSupport>false</MetricsSupport>
</PropertyGroup>
<!-- Use local runtime pack -->
<Target Name="UpdateRuntimePack" AfterTargets="ResolveFrameworkReferences" DependsOnTargets="_PrepareAndValidateWasmInputs">
<ItemGroup>
<ResolvedRuntimePack PackageDirectory="$(MicrosoftNetCoreAppRuntimePackLocationToUse)"
Condition="'$(MicrosoftNetCoreAppRuntimePackLocationToUse)' != '' and
'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
</ItemGroup>
<Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory) for $(MSBuildProjectName)" Importance="normal" />
</Target>
<!-- the actual properties need to get set in the props, so because UsingTasks depend on those. -->
<Target Name="_PrepareAndValidateWasmInputs">
<Error Condition="'$(RuntimeSrcDir)' == '' and '$(WasmBuildSupportDir)' == ''"
Text="Both %24(RuntimeSrcDir) and %24(WasmBuildSupportDir) are not set. Either one of them needs to be set to use local runtime builds" />
<Error Condition="'$(RuntimeSrcDir)' != '' and '$(WasmBuildSupportDir)' != ''"
Text="Both %24(RuntimeSrcDir) and %24(WasmBuildSupportDir) are set. " />
<Error Condition="'$(RuntimeSrcDir)' != '' and '$(RuntimeConfig)' == ''"
Text="%24(RuntimeSrcDir) is set, but %24(RuntimeConfig) is not" />
<PropertyGroup>
<MicrosoftNetCoreAppRuntimePackDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackLocationToUse)))</MicrosoftNetCoreAppRuntimePackDir>
<MicrosoftNetCoreAppRuntimePackRidDir>$([MSBuild]::NormalizeDirectory($(MicrosoftNetCoreAppRuntimePackDir), 'runtimes', $(RuntimeIdentifier)))</MicrosoftNetCoreAppRuntimePackRidDir>
<WasmAppBuilderTasksAssemblyPath>$([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll'))</WasmAppBuilderTasksAssemblyPath>
<WasmBuildTasksAssemblyPath>$([MSBuild]::NormalizePath('$(WasmBuildTasksDir)', 'WasmBuildTasks.dll'))</WasmBuildTasksAssemblyPath>
<MonoAOTCompilerTasksAssemblyPath>$([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll'))</MonoAOTCompilerTasksAssemblyPath>
<MonoTargetsTasksAssemblyPath>$([MSBuild]::NormalizePath('$(MonoTargetsTasksDir)', 'MonoTargetsTasks.dll'))</MonoTargetsTasksAssemblyPath>
</PropertyGroup>
<Error Condition="!Exists('$(MicrosoftNetCoreAppRuntimePackRidDir)')"
Text="Cannot find runtime pack at $(MicrosoftNetCoreAppRuntimePackRidDir). Make sure you have the correct %24(RuntimeConfig) set" />
<Warning
Condition="'$(WasmMainJS)' != '' and '$(WasmGenerateAppBundle)' != 'true'"
Text="%24(WasmMainJS) is set when %24(WasmGenerateAppBundle) is not true: it won't be used because an app bundle is not being generated. Possible build authoring error" />
</Target>
</Project>