|
97 | 97 |
|
98 | 98 | <ItemGroup>
|
99 | 99 | <_BlazorDependencyInput Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')->'%(FullPath)')" />
|
| 100 | + |
| 101 | + <_WebAssemblyBCLFolder Include=" |
| 102 | + $(DotNetWebAssemblyBCLPath); |
| 103 | + $(DotNetWebAssemblyBCLFacadesPath); |
| 104 | + $(DotNetWebAssemblyFrameworkPath)" /> |
| 105 | + |
| 106 | + <_WebAssemblyBCLAssembly Include="%(_WebAssemblyBCLFolder.Identity)*.dll" /> |
| 107 | + </ItemGroup> |
| 108 | + |
| 109 | + <ItemGroup> |
| 110 | + <BlazorLinkerDescriptor Include="$(_BlazorBuiltInBclLinkerDescriptor)" /> |
100 | 111 | </ItemGroup>
|
101 | 112 |
|
102 | 113 | <MakeDir Directories="$(BlazorIntermediateOutputPath)" />
|
|
133 | 144 | </ItemGroup>
|
134 | 145 | </Target>
|
135 | 146 |
|
| 147 | + <UsingTask TaskName="BlazorCreateRootDescriptorFile" AssemblyFile="$(BlazorTasksPath)" /> |
136 | 148 | <Target Name="_GenerateLinkerDescriptor"
|
137 | 149 | Inputs="@(IntermediateAssembly)"
|
138 | 150 | Outputs="$(GeneratedBlazorLinkerDescriptor)"
|
139 | 151 | Condition="'@(BlazorLinkerDescriptor)' == ''">
|
140 | 152 |
|
141 | 153 | <!-- Generate linker descriptors if the project doesn't explicitly provide one. -->
|
142 | 154 |
|
143 |
| - <ItemGroup> |
144 |
| - <_PrepareLinkerDescriptorAssemblyLine Include="@(IntermediateAssembly->'%(FileName)')" /> |
145 |
| - <_GeneratedLinkerDescriptorLine Include="<linker>" /> |
146 |
| - <_GeneratedLinkerDescriptorLine Include="@(_PrepareLinkerDescriptorAssemblyLine->'<assembly fullname="%(Identity)" />')" /> |
147 |
| - <_GeneratedLinkerDescriptorLine Include="</linker>" /> |
148 |
| - </ItemGroup> |
149 |
| - |
150 |
| - <WriteLinesToFile |
151 |
| - Lines="@(_GeneratedLinkerDescriptorLine)" |
152 |
| - File="$(GeneratedBlazorLinkerDescriptor)" |
153 |
| - Overwrite="true" |
154 |
| - WriteOnlyWhenDifferent="True" /> |
| 155 | + <BlazorCreateRootDescriptorFile |
| 156 | + AssemblyNames="@(IntermediateAssembly->'%(Filename)')" |
| 157 | + RootDescriptorFilePath="$(GeneratedBlazorLinkerDescriptor)" /> |
155 | 158 |
|
156 | 159 | <ItemGroup>
|
157 | 160 | <FileWrites Include="$(GeneratedBlazorLinkerDescriptor)" />
|
158 |
| - </ItemGroup> |
159 |
| - |
160 |
| - <ItemGroup> |
161 |
| - <BlazorLinkerDescriptor Include="$(_BlazorBuiltInBclLinkerDescriptor)" /> |
162 | 161 | <BlazorLinkerDescriptor Include="$(GeneratedBlazorLinkerDescriptor)" />
|
163 | 162 | </ItemGroup>
|
164 | 163 | </Target>
|
165 | 164 |
|
| 165 | + <UsingTask TaskName="BlazorILLink" AssemblyFile="$(BlazorTasksPath)" /> |
166 | 166 | <Target
|
167 | 167 | Name="_LinkBlazorApplication"
|
168 | 168 | Inputs="$(ProjectAssetsFile);
|
|
173 | 173 | Outputs="$(_BlazorLinkerOutputCache)">
|
174 | 174 |
|
175 | 175 | <ItemGroup>
|
176 |
| - <_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)"> |
177 |
| - <RelativeDirNoTrailingSlash>$([System.String]::Copy('%(RelativeDir)').TrimEnd('\').TrimEnd('/'))</RelativeDirNoTrailingSlash> |
178 |
| - <IsLinkable Condition="$([System.String]::Copy('%(FileName)').StartsWith('System.'))">true</IsLinkable> |
179 |
| - </_BlazorDependencyAssembly> |
180 |
| - </ItemGroup> |
181 |
| - <ItemGroup> |
182 |
| - <_WebAssemblyBCLFolder Include="$(DotNetWebAssemblyBCLPath);$(DotNetWebAssemblyBCLFacadesPath);$(DotNetWebAssemblyFrameworkPath)" /> |
183 |
| - <_BlazorAssembliesToCopy Include="@(IntermediateAssembly->'-a "%(FullPath)"')" /> |
184 |
| - <_BlazorFolderLookupPaths Include="@(_WebAssemblyBCLFolder->'-d "%(Identity)"')" /> |
185 |
| - |
186 |
| - <!-- For linkable assemblies, add their directories as lookup paths --> |
187 |
| - <_BlazorFolderLookupPaths Condition="'%(_BlazorDependencyAssembly.IsLinkable)' == 'true'" Include="@(_BlazorDependencyAssembly->'-d "%(RelativeDirNoTrailingSlash)"')" /> |
188 |
| - |
189 |
| - <!-- For non-linkable assemblies, reference the .dll directly --> |
190 |
| - <_BlazorAssembliesToCopy Condition="'%(_BlazorDependencyAssembly.IsLinkable)' != 'true'" Include="@(_BlazorDependencyAssembly->'-a "%(FullPath)"')" /> |
191 |
| - |
192 |
| - <_BlazorAssemblyDescriptorFiles |
193 |
| - Include="@(BlazorLinkerDescriptor->'-x "%(FullPath)"')" Condition="'@(BlazorLinkerDescriptor)' != ''" /> |
| 176 | + <!-- |
| 177 | + Previously we limited the linker to run exclusively on assemblies found in the WASM BCL. However, this misses |
| 178 | + out on some assemblies that aren't part of the the BCL but the linker has innate understanding of, and can operate on. |
| 179 | + Consequently we tell the linker to consider any assembly that starts with System. for linking. |
| 180 | + --> |
| 181 | + <_BlazorAssemblyToLink Include="@(_BlazorDependencyInput)" Condition="$([System.String]::Copy('%(_BlazorDependencyInput.FileName)').StartsWith('System.'))" /> |
| 182 | + <_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" /> |
| 183 | + <_BlazorLinkerRoot Include="@(_BlazorDependencyInput)" Exclude="@(_BlazorAssemblyToLink)" /> |
| 184 | + <_BlazorLinkerRoot Include="@(IntermediateAssembly)" /> |
194 | 185 | </ItemGroup>
|
195 | 186 |
|
196 | 187 | <PropertyGroup>
|
|
202 | 193 | <_OldLinkedFile Include="$(BlazorIntermediateLinkerOutputPath)*.dll" />
|
203 | 194 | </ItemGroup>
|
204 | 195 |
|
| 196 | + <!-- When running from Desktop MSBuild, DOTNET_HOST_PATH is not set. |
| 197 | + In this case, explicitly specify the path to the dotnet host. --> |
| 198 | + <PropertyGroup Condition=" '$(DOTNET_HOST_PATH)' == '' "> |
| 199 | + <_DotNetHostDirectory>$(NetCoreRoot)</_DotNetHostDirectory> |
| 200 | + <_DotNetHostFileName>dotnet</_DotNetHostFileName> |
| 201 | + <_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe</_DotNetHostFileName> |
| 202 | + </PropertyGroup> |
| 203 | + |
205 | 204 | <Delete Files="@(_OldLinkedFile)" />
|
206 | 205 |
|
207 |
| - <!-- Run the linker and put the results in /obj/<<configuration>>/<<targetframework>>/blazor/blazor/linker --> |
208 |
| - <Exec Command="dotnet "$(MonoLinkerPath)" $(_BlazorLinkerAdditionalOptions) @(_BlazorFolderLookupPaths, ' ') -o "$(BlazorIntermediateLinkerOutputPath)" @(_BlazorAssemblyDescriptorFiles, ' ') @(_BlazorAssembliesToCopy, ' ')" /> |
| 206 | + <BlazorILLink |
| 207 | + ILLinkPath="$(MonoLinkerPath)" |
| 208 | + AssemblyPaths="@(_BlazorAssemblyToLink)" |
| 209 | + RootAssemblyNames="@(_BlazorLinkerRoot)" |
| 210 | + RootDescriptorFiles="@(BlazorLinkerDescriptor)" |
| 211 | + OutputDirectory="$(BlazorIntermediateLinkerOutputPath)" |
| 212 | + ExtraArgs="$(_BlazorLinkerAdditionalOptions)" |
| 213 | + ToolExe="$(_DotNetHostFileName)" |
| 214 | + ToolPath="$(_DotNetHostDirectory)" /> |
209 | 215 |
|
210 | 216 | <ItemGroup>
|
211 | 217 | <_LinkerResult Include="$(BlazorIntermediateLinkerOutputPath)*.dll" />
|
|
243 | 249 | from the BCL referenced by the app the nuget package into the _framework/_bin folder.
|
244 | 250 | The only thing we need to do here is collect the list of items that will go into _framework/_bin.
|
245 | 251 | -->
|
246 |
| - |
247 |
| - <ItemGroup> |
248 |
| - <_WebAssemblyBCLFolder Include="$(DotNetWebAssemblyBCLPath);$(DotNetWebAssemblyBCLFacadesPath);$(DotNetWebAssemblyFrameworkPath)" /> |
249 |
| - <_WebAssemblyBCLAssembly Include="%(_WebAssemblyBCLFolder.Identity)*.dll" /> |
250 |
| - </ItemGroup> |
251 |
| - |
252 | 252 | <ResolveBlazorRuntimeDependencies
|
253 | 253 | EntryPoint="@(IntermediateAssembly)"
|
254 | 254 | ApplicationDependencies="@(_BlazorDependencyInput)"
|
|
0 commit comments