|
74 | 74 | </ItemGroup>
|
75 | 75 | </Target>
|
76 | 76 |
|
77 |
| - <Target Name="_ResolveBlazorInputs"> |
| 77 | + <Target Name="_ResolveBlazorInputs" DependsOnTargets="ResolveReferences;ResolveRuntimePackAssets"> |
78 | 78 | <PropertyGroup>
|
79 | 79 | <!-- /obj/<<configuration>>/<<targetframework>>/blazor -->
|
80 | 80 | <BlazorIntermediateOutputPath>$(IntermediateOutputPath)blazor\</BlazorIntermediateOutputPath>
|
81 | 81 |
|
82 | 82 | <!-- /obj/<<configuration>>/<<targetframework>>/blazor/linker.descriptor.xml -->
|
83 | 83 | <GeneratedBlazorLinkerDescriptor>$(BlazorIntermediateOutputPath)linker.descriptor.xml</GeneratedBlazorLinkerDescriptor>
|
84 | 84 |
|
| 85 | + <_TypeGranularityLinkerDescriptor>$(BlazorIntermediateOutputPath)linker.typegranularityconfig.xml</_TypeGranularityLinkerDescriptor> |
| 86 | + |
85 | 87 | <!-- /obj/<<configuration>>/<<targetframework>>/blazor/linker/ -->
|
86 | 88 | <BlazorIntermediateLinkerOutputPath>$(BlazorIntermediateOutputPath)linker/</BlazorIntermediateLinkerOutputPath>
|
87 | 89 |
|
|
94 | 96 | </PropertyGroup>
|
95 | 97 |
|
96 | 98 | <ItemGroup>
|
97 |
| - <_BlazorDependencyInput Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')->'%(FullPath)')" /> |
98 |
| - |
99 | 99 | <_WebAssemblyBCLFolder Include="
|
100 | 100 | $(DotNetWebAssemblyBCLPath);
|
101 | 101 | $(DotNetWebAssemblyBCLFacadesPath);
|
|
104 | 104 | <_WebAssemblyBCLAssembly Include="%(_WebAssemblyBCLFolder.Identity)*.dll" />
|
105 | 105 | </ItemGroup>
|
106 | 106 |
|
| 107 | + <!-- |
| 108 | + Calculate the assemblies that act as inputs to calculate assembly closure. Based on _ComputeAssembliesToPostprocessOnPublish which is used as input to SDK's linker |
| 109 | + https://github.com/dotnet/sdk/blob/d597e7b09d7657ba4e326d6734e14fcbf8473564/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L864-L873 |
| 110 | + --> |
| 111 | + <ItemGroup> |
| 112 | + <!-- Assemblies from packages --> |
| 113 | + <_BlazorManagedRuntimeAssemby Include="@(RuntimeCopyLocalItems)" /> |
| 114 | + |
| 115 | + <!-- Assemblies from other references --> |
| 116 | + <_BlazorUserRuntimeAssembly Include="@(ReferencePath->WithMetadataValue('CopyLocal', 'true'))" /> |
| 117 | + <_BlazorUserRuntimeAssembly Include="@(ReferenceDependencyPaths->WithMetadataValue('CopyLocal', 'true'))" /> |
| 118 | + |
| 119 | + <_BlazorManagedRuntimeAssemby Include="@(_BlazorUserRuntimeAssembly)" /> |
| 120 | + <_BlazorManagedRuntimeAssemby Include="@(IntermediateAssembly)" /> |
| 121 | + </ItemGroup> |
| 122 | + |
107 | 123 | <MakeDir Directories="$(BlazorIntermediateOutputPath)" />
|
108 | 124 | </Target>
|
109 | 125 |
|
110 | 126 | <Target Name="_ResolveBlazorOutputs" DependsOnTargets="_ResolveBlazorOutputsWhenLinked;_ResolveBlazorOutputsWhenNotLinked">
|
111 | 127 | <Error
|
112 | 128 | Message="Unrecongnized value for BlazorLinkOnBuild: '$(BlazorLinkOnBuild)'. Valid values are 'true' or 'false'."
|
113 | 129 | Condition="'$(BlazorLinkOnBuild)' != 'true' AND '$(BlazorLinkOnBuild)' != 'false'" />
|
| 130 | + |
| 131 | + <ItemGroup> |
| 132 | + <!-- |
| 133 | + ReferenceCopyLocalPaths includes all files that are part of the build out with CopyLocalLockFileAssemblies on. |
| 134 | + Remove assemblies that are inputs to calculating the assembly closure. Instead use the resolved outputs, since it is the minimal set. |
| 135 | + --> |
| 136 | + <_BlazorCopyLocalPaths Include="@(ReferenceCopyLocalPaths)" /> |
| 137 | + <_BlazorCopyLocalPaths Remove="@(_BlazorManagedRuntimeAssemby)" /> |
| 138 | + |
| 139 | + <BlazorOutputWithTargetPath Include="@(_BlazorCopyLocalPaths)"> |
| 140 | + <BlazorRuntimeFile>true</BlazorRuntimeFile> |
| 141 | + <TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(_BlazorCopyLocalPaths.DestinationSubDirectory)%(FileName)%(Extension)</TargetOutputPath> |
| 142 | + <RelativeOutputPath>%(_BlazorCopyLocalPaths.DestinationSubDirectory)%(FileName)%(Extension)</RelativeOutputPath> |
| 143 | + </BlazorOutputWithTargetPath> |
| 144 | + |
| 145 | + <BlazorOutputWithTargetPath Include="@(_BlazorResolvedAssembly)"> |
| 146 | + <BlazorRuntimeFile>true</BlazorRuntimeFile> |
| 147 | + <TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(FileName)%(Extension)</TargetOutputPath> |
| 148 | + <RelativeOutputPath>%(FileName)%(Extension)</RelativeOutputPath> |
| 149 | + </BlazorOutputWithTargetPath> |
| 150 | + </ItemGroup> |
114 | 151 | </Target>
|
115 | 152 |
|
116 | 153 | <!--
|
|
124 | 161 | <Target
|
125 | 162 | Name="_ResolveBlazorOutputsWhenLinked"
|
126 | 163 | Condition="'$(BlazorLinkOnBuild)' == 'true'"
|
127 |
| - DependsOnTargets="_GenerateBlazorLinkerDescriptor;_LinkBlazorApplication"> |
| 164 | + DependsOnTargets="_PrepareBlazorLinkerInputs;_GenerateBlazorLinkerDescriptor;_GenerateTypeGranularLinkerDescriptor;_LinkBlazorApplication"> |
128 | 165 |
|
129 | 166 | <!-- _BlazorLinkerOutputCache records files linked during the last incremental build of the target. Read the contents and assign linked files to be copied to the output. -->
|
130 | 167 | <ReadLinesFromFile File="$(_BlazorLinkerOutputCache)">
|
131 |
| - <Output TaskParameter="Lines" ItemName="_BlazorLinkedFile"/> |
| 168 | + <Output TaskParameter="Lines" ItemName="_BlazorResolvedAssembly"/> |
132 | 169 | </ReadLinesFromFile>
|
| 170 | + </Target> |
133 | 171 |
|
| 172 | + <Target Name="_PrepareBlazorLinkerInputs"> |
134 | 173 | <ItemGroup>
|
135 |
| - <BlazorOutputWithTargetPath Include="%(_BlazorLinkedFile.Identity)"> |
136 |
| - <TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(FileName)%(Extension)</TargetOutputPath> |
137 |
| - </BlazorOutputWithTargetPath> |
| 174 | + <_BlazorRuntimeCopyLocalItems Include="@(RuntimeCopyLocalItems)" /> |
| 175 | + |
| 176 | + <!-- |
| 177 | + Any assembly from a package reference that starts with System. file name is allowed to be linked. |
| 178 | + Assemblies from Microsoft.AspNetCore and Microsoft.Extensions, are also linked but with TypeGranularity. |
| 179 | + --> |
| 180 | + <_BlazorRuntimeCopyLocalItems IsLinkable="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('System.'))" /> |
| 181 | + <_BlazorRuntimeCopyLocalItems IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.'))" /> |
| 182 | + <_BlazorRuntimeCopyLocalItems IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.Extensions.'))" /> |
| 183 | + |
| 184 | + <_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" /> |
| 185 | + <_BlazorAssemblyToLink Include="@(_BlazorRuntimeCopyLocalItems)" Condition="'%(_BlazorRuntimeCopyLocalItems.IsLinkable)' == 'true'" /> |
| 186 | + |
| 187 | + <_BlazorLinkerRoot Include="@(IntermediateAssembly)" /> |
| 188 | + <_BlazorLinkerRoot Include="@(_BlazorUserRuntimeAssembly)" /> |
| 189 | + <_BlazorLinkerRoot Include="@(_BlazorRuntimeCopyLocalItems)" Condition="'%(_BlazorRuntimeCopyLocalItems.IsLinkable)' != 'true'" /> |
138 | 190 | </ItemGroup>
|
| 191 | + |
139 | 192 | </Target>
|
140 | 193 |
|
141 | 194 | <UsingTask TaskName="BlazorCreateRootDescriptorFile" AssemblyFile="$(BlazorTasksPath)" />
|
|
157 | 210 | </ItemGroup>
|
158 | 211 | </Target>
|
159 | 212 |
|
160 |
| - <UsingTask TaskName="BlazorILLink" AssemblyFile="$(BlazorTasksPath)" /> |
161 | 213 | <UsingTask TaskName="GenerateTypeGranularityLinkingConfig" AssemblyFile="$(BlazorTasksPath)" />
|
| 214 | + <Target Name="_GenerateTypeGranularLinkerDescriptor" |
| 215 | + Inputs="@(_BlazorAssemblyToLink->WithMetadataValue('TypeGranularity', 'true'))" |
| 216 | + Outputs="$(_TypeGranularityLinkerDescriptor)"> |
| 217 | + |
| 218 | + <GenerateTypeGranularityLinkingConfig |
| 219 | + Assemblies="@(_BlazorAssemblyToLink->WithMetadataValue('TypeGranularity', 'true'))" |
| 220 | + OutputPath="$(_TypeGranularityLinkerDescriptor)" /> |
| 221 | + |
| 222 | + <ItemGroup> |
| 223 | + <BlazorLinkerDescriptor Include="$(_TypeGranularityLinkerDescriptor)" /> |
| 224 | + <FileWrites Include="$(_TypeGranularityLinkerDescriptor)" /> |
| 225 | + </ItemGroup> |
| 226 | + </Target> |
162 | 227 |
|
| 228 | + <UsingTask TaskName="BlazorILLink" AssemblyFile="$(BlazorTasksPath)" /> |
163 | 229 | <Target
|
164 | 230 | Name="_LinkBlazorApplication"
|
165 | 231 | Inputs="$(ProjectAssetsFile);
|
166 |
| - @(IntermediateAssembly); |
167 |
| - @(_BlazorDependencyInput); |
| 232 | + @(_BlazorManagedRuntimeAssemby); |
168 | 233 | @(BlazorLinkerDescriptor);
|
169 | 234 | $(MSBuildAllProjects)"
|
170 | 235 | Outputs="$(_BlazorLinkerOutputCache)">
|
171 | 236 |
|
172 |
| - <ItemGroup> |
173 |
| - <_BlazorDependencyAssembly Include="@(_BlazorDependencyInput)" /> |
174 |
| - <_BlazorDependencyAssembly IsLinkable="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('System.'))" /> |
175 |
| - <_BlazorDependencyAssembly IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.'))" /> |
176 |
| - <_BlazorDependencyAssembly IsLinkable="true" TypeGranularity="true" Condition="$([System.String]::Copy('%(Filename)').StartsWith('Microsoft.Extensions.'))" /> |
177 |
| - |
178 |
| - <_BlazorAssemblyToLink Include="@(_WebAssemblyBCLAssembly)" /> |
179 |
| - <_BlazorAssemblyToLink Include="@(_BlazorDependencyAssembly)" Condition="'%(_BlazorDependencyAssembly.IsLinkable)' == 'true'" /> |
180 |
| - |
181 |
| - <_BlazorLinkerRoot Include="@(IntermediateAssembly)" /> |
182 |
| - <_BlazorLinkerRoot Include="@(_BlazorDependencyAssembly)" Condition="'%(_BlazorDependencyAssembly.IsLinkable)' != 'true'" /> |
183 |
| - </ItemGroup> |
184 |
| - |
185 | 237 | <PropertyGroup>
|
186 | 238 | <_BlazorLinkerAdditionalOptions>-l $(MonoLinkerI18NAssemblies) $(AdditionalMonoLinkerOptions)</_BlazorLinkerAdditionalOptions>
|
187 | 239 | </PropertyGroup>
|
|
203 | 255 | <_DotNetHostFileName Condition=" '$(OS)' == 'Windows_NT' ">dotnet.exe</_DotNetHostFileName>
|
204 | 256 | </PropertyGroup>
|
205 | 257 |
|
206 |
| - <PropertyGroup> |
207 |
| - <_TypeGranularityLinkingConfig>$(BlazorIntermediateOutputPath)linker.typegranularityconfig.xml</_TypeGranularityLinkingConfig> |
208 |
| - </PropertyGroup> |
209 |
| - <GenerateTypeGranularityLinkingConfig Assemblies="@(_BlazorAssemblyToLink->WithMetadataValue('TypeGranularity', 'true'))" OutputPath="$(_TypeGranularityLinkingConfig)" /> |
210 |
| - <ItemGroup> |
211 |
| - <BlazorLinkerDescriptor Include="$(_TypeGranularityLinkingConfig)" /> |
212 |
| - <FileWrites Include="$(_TypeGranularityLinkingConfig)" /> |
213 |
| - </ItemGroup> |
214 |
| - |
215 | 258 | <BlazorILLink
|
216 | 259 | ILLinkPath="$(MonoLinkerPath)"
|
217 | 260 | AssemblyPaths="@(_BlazorAssemblyToLink)"
|
|
230 | 273 | <WriteLinesToFile File="$(_BlazorLinkerOutputCache)" Lines="@(_LinkerResult)" Overwrite="true" />
|
231 | 274 | </Target>
|
232 | 275 |
|
233 |
| - |
234 | 276 | <UsingTask TaskName="ResolveBlazorRuntimeDependencies" AssemblyFile="$(BlazorTasksPath)" />
|
235 | 277 | <Target
|
236 | 278 | Name="_ResolveBlazorOutputsWhenNotLinked"
|
237 | 279 | DependsOnTargets="_ResolveBlazorRuntimeDependencies"
|
238 | 280 | Condition="'$(BlazorLinkOnBuild)' != 'true'">
|
239 | 281 |
|
240 |
| - <ReadLinesFromFile File="$(_BlazorApplicationAssembliesCacheFile)" Condition="'@(_BlazorResolvedRuntimeDependencies->Count())' == '0'"> |
241 |
| - <Output TaskParameter="Lines" ItemName="_BlazorResolvedRuntimeDependencies"/> |
| 282 | + <ReadLinesFromFile File="$(_BlazorApplicationAssembliesCacheFile)" Condition="'@(_BlazorResolvedAssembly->Count())' == '0'"> |
| 283 | + <Output TaskParameter="Lines" ItemName="_BlazorResolvedAssembly"/> |
242 | 284 | </ReadLinesFromFile>
|
243 |
| - |
244 |
| - <ItemGroup> |
245 |
| - <BlazorOutputWithTargetPath Include="@(_BlazorResolvedRuntimeDependencies)"> |
246 |
| - <TargetOutputPath>$(BlazorRuntimeBinOutputPath)%(FileName)%(Extension)</TargetOutputPath> |
247 |
| - </BlazorOutputWithTargetPath> |
248 |
| - </ItemGroup> |
249 | 285 | </Target>
|
250 | 286 |
|
251 | 287 | <Target
|
252 | 288 | Name="_ResolveBlazorRuntimeDependencies"
|
253 | 289 | Inputs="$(ProjectAssetsFile);
|
254 | 290 | @(IntermediateAssembly);
|
255 |
| - @(_BlazorDependencyInput)" |
| 291 | + @(_BlazorManagedRuntimeAssemby)" |
256 | 292 | Outputs="$(_BlazorApplicationAssembliesCacheFile)">
|
257 | 293 |
|
258 | 294 | <!--
|
|
262 | 298 | -->
|
263 | 299 | <ResolveBlazorRuntimeDependencies
|
264 | 300 | EntryPoint="@(IntermediateAssembly)"
|
265 |
| - ApplicationDependencies="@(_BlazorDependencyInput)" |
| 301 | + ApplicationDependencies="@(_BlazorManagedRuntimeAssemby)" |
266 | 302 | WebAssemblyBCLAssemblies="@(_WebAssemblyBCLAssembly)">
|
267 | 303 |
|
268 |
| - <Output TaskParameter="Dependencies" ItemName="_BlazorResolvedRuntimeDependencies" /> |
| 304 | + <Output TaskParameter="Dependencies" ItemName="_BlazorResolvedAssembly" /> |
269 | 305 | </ResolveBlazorRuntimeDependencies>
|
270 | 306 |
|
271 | 307 | <WriteLinesToFile File="$(_BlazorApplicationAssembliesCacheFile)" Lines="@(_BlazorResolvedRuntimeDependencies)" Overwrite="true" />
|
|
282 | 318 | Inputs="@(BlazorOutputWithTargetPath)"
|
283 | 319 | Outputs="$(BlazorBootJsonIntermediateOutputPath)">
|
284 | 320 | <ItemGroup>
|
285 |
| - <_AppReferences Include="@(BlazorOutputWithTargetPath->WithMetadataValue('Extension','.dll'))" /> |
286 |
| - <_AppReferences Include="@(BlazorOutputWithTargetPath->WithMetadataValue('Extension','.pdb'))" Condition="'$(BlazorEnableDebugging)' == 'true'" /> |
| 321 | + <_BlazorRuntimeFile Include="@(BlazorOutputWithTargetPath->WithMetadataValue('BlazorRuntimeFile', 'true'))" /> |
287 | 322 | </ItemGroup>
|
288 | 323 |
|
289 | 324 | <GenerateBlazorBootJson
|
290 | 325 | AssemblyPath="@(IntermediateAssembly)"
|
291 |
| - References="@(_AppReferences)" |
| 326 | + References="@(_BlazorRuntimeFile)" |
292 | 327 | LinkerEnabled="$(BlazorLinkOnBuild)"
|
293 | 328 | OutputPath="$(BlazorBootJsonIntermediateOutputPath)" />
|
294 | 329 |
|
|
0 commit comments