A better fix for the VS publishing hosted projects issue (#274)

This commit is contained in:
Steve Sanderson 2018-03-16 09:13:48 +00:00 committed by GitHub
parent 4202a6c9e1
commit 03ac95f086
2 changed files with 41 additions and 8 deletions

View File

@ -24,6 +24,13 @@
<FileWrites Include="@(BlazorItemOutput->'%(TargetOutputPath)')" /> <FileWrites Include="@(BlazorItemOutput->'%(TargetOutputPath)')" />
</ItemGroup> </ItemGroup>
</Target> </Target>
<Target Name="_BlazorTrackResolveReferencesDidRun" AfterTargets="ResolveReferences">
<PropertyGroup>
<!-- So we know we can trust @(ReferenceCopyLocalPaths) later -->
<_BlazorResolveReferencesDidRun>true</_BlazorResolveReferencesDidRun>
</PropertyGroup>
</Target>
<Target Name="_BlazorBuildReport" <Target Name="_BlazorBuildReport"
AfterTargets="_BlazorCopyFilesToOutputDirectory"> AfterTargets="_BlazorCopyFilesToOutputDirectory">
@ -128,6 +135,9 @@
for the mono linker. for the mono linker.
/obj/<<configuration>>/<<targetframework>>/blazor/inputs.basic.cache <- This is the marker file to track the inputs common /obj/<<configuration>>/<<targetframework>>/blazor/inputs.basic.cache <- This is the marker file to track the inputs common
inputs to the output generation process. inputs to the output generation process.
/obj/<<configuration>>/<<targetframework>>/blazor/inputs.copylocal.txt <- Paths to all the copy-local referenced assemblies found
during the build process (i.e., the @(ReferenceCopyLocalPaths) values). We need this because when publishing, the build doesn't
necessarily also run so this is the only way we know which assemblies to include in linking/resolveassemblies.
/obj/<<configuration>>/<<targetframework>>/blazor/inputs.linkerswitch.cache <- This is the marker file to track the /obj/<<configuration>>/<<targetframework>>/blazor/inputs.linkerswitch.cache <- This is the marker file to track the
switch from linking to not linking and viceversa. switch from linking to not linking and viceversa.
/obj/<<configuration>>/<<targetframework>>/blazor/inputs.linker.cache <- This is the marker file to track the inputs /obj/<<configuration>>/<<targetframework>>/blazor/inputs.linker.cache <- This is the marker file to track the inputs
@ -187,6 +197,9 @@
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.basic.cache --> <!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.basic.cache -->
<BlazorBuildCommonInputsCache>$(BlazorIntermediateOutputPath)inputs.basic.cache</BlazorBuildCommonInputsCache> <BlazorBuildCommonInputsCache>$(BlazorIntermediateOutputPath)inputs.basic.cache</BlazorBuildCommonInputsCache>
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.copylocal.txt -->
<BlazorLocalReferencesOutputPath>$(BlazorIntermediateOutputPath)inputs.copylocal.txt</BlazorLocalReferencesOutputPath>
<!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.linkerswitch.cache --> <!-- /obj/<<configuration>>/<<targetframework>>/blazor/inputs.linkerswitch.cache -->
<BlazorBuildLinkerSwitchInputsCache>$(BlazorIntermediateOutputPath)inputs.linkerswitch.cache</BlazorBuildLinkerSwitchInputsCache> <BlazorBuildLinkerSwitchInputsCache>$(BlazorIntermediateOutputPath)inputs.linkerswitch.cache</BlazorBuildLinkerSwitchInputsCache>
@ -231,10 +244,21 @@
</Target> </Target>
<Target Name="_DefineBlazorCommonInputs"> <Target Name="_DefineBlazorCommonInputs">
<!-- If ResolveReferences hasn't yet run, we must be inside a VS publish process
that doesn't also do a build, so use the stored information. -->
<ReadLinesFromFile
Condition="'$(_BlazorResolveReferencesDidRun)'!='true'"
File="$(BlazorLocalReferencesOutputPath)">
<Output TaskParameter="Lines" ItemName="_BlazorDependencyInput"/>
</ReadLinesFromFile>
<ItemGroup Condition="'$(_BlazorResolveReferencesDidRun)'=='true'">
<!-- ... otherwise we can get the fresh info from @(ReferenceCopyLocalPaths) -->
<_BlazorDependencyInput Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')->'%(FullPath)')" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<_BlazorCommonInput Include="@(IntermediateAssembly)" /> <_BlazorCommonInput Include="@(IntermediateAssembly)" />
<_BlazorCommonInput Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll'))" /> <_BlazorCommonInput Include="@(_BlazorDependencyInput)" />
<_BlazorCommonInput Include="$(_BlazorShouldLinkApplicationAssemblies)" /> <_BlazorCommonInput Include="$(_BlazorShouldLinkApplicationAssemblies)" />
<_BlazorLinkingOption Condition="_BlazorShouldLinkApplicationAssemblies == ''" Include="false" /> <_BlazorLinkingOption Condition="_BlazorShouldLinkApplicationAssemblies == ''" Include="false" />
<_BlazorLinkingOption Condition="_BlazorShouldLinkApplicationAssemblies != ''" Include="true" /> <_BlazorLinkingOption Condition="_BlazorShouldLinkApplicationAssemblies != ''" Include="true" />
@ -249,6 +273,12 @@
File="$(BlazorBuildCommonInputsCache)" File="$(BlazorBuildCommonInputsCache)"
Overwrite="True" Overwrite="True"
WriteOnlyWhenDifferent="True" /> WriteOnlyWhenDifferent="True" />
<WriteLinesToFile
Lines="@(_BlazorDependencyInput)"
File="$(BlazorLocalReferencesOutputPath)"
Overwrite="True"
WriteOnlyWhenDifferent="True" />
<!-- Switch to detect when we switch from linking to not linking and viceversa --> <!-- Switch to detect when we switch from linking to not linking and viceversa -->
<WriteLinesToFile <WriteLinesToFile
@ -260,6 +290,7 @@
<ItemGroup> <ItemGroup>
<FileWrites Include="$(BlazorBuildLinkerSwitchInputsCache)" /> <FileWrites Include="$(BlazorBuildLinkerSwitchInputsCache)" />
<FileWrites Include="$(BlazorBuildCommonInputsCache)" /> <FileWrites Include="$(BlazorBuildCommonInputsCache)" />
<FileWrites Include="$(BlazorLocalReferencesOutputPath)" />
</ItemGroup> </ItemGroup>
</Target> </Target>
@ -337,7 +368,7 @@
<ItemGroup> <ItemGroup>
<_BlazorLinkerInput Include="@(IntermediateAssembly)" /> <_BlazorLinkerInput Include="@(IntermediateAssembly)" />
<_BlazorLinkerInput Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll'))" /> <_BlazorLinkerInput Include="@(_BlazorDependencyInput)" />
<_BlazorLinkerInput Include="@(BlazorLinkerDescriptor)" /> <_BlazorLinkerInput Include="@(BlazorLinkerDescriptor)" />
<_BlazorLinkerInput Include="$(AdditionalLinkerOptions)" /> <_BlazorLinkerInput Include="$(AdditionalLinkerOptions)" />
</ItemGroup> </ItemGroup>
@ -363,7 +394,7 @@
Condition="$(_BlazorShouldLinkApplicationAssemblies) != ''" Condition="$(_BlazorShouldLinkApplicationAssemblies) != ''"
Inputs="$(BlazorBuildLinkerInputsCache); Inputs="$(BlazorBuildLinkerInputsCache);
@(IntermediateAssembly); @(IntermediateAssembly);
@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')); @(_BlazorDependencyInput);
@(BlazorLinkerDescriptor)" @(BlazorLinkerDescriptor)"
Outputs="$(BlazorIntermediateLinkerResultFilePath)" Outputs="$(BlazorIntermediateLinkerResultFilePath)"
> >
@ -380,7 +411,7 @@
4) Add the file we just created to the list of file writes, to support incremental builds. 4) Add the file we just created to the list of file writes, to support incremental builds.
--> -->
<ItemGroup> <ItemGroup>
<_BlazorAssembliesToLink Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')->'-a &quot;%(FullPath)&quot;')" /> <_BlazorAssembliesToLink Include="@(_BlazorDependencyInput->'-a &quot;%(Identity)&quot;')" />
<_BlazorAssembliesToLink Include="@(IntermediateAssembly->'-a &quot;%(FullPath)&quot;')" /> <_BlazorAssembliesToLink Include="@(IntermediateAssembly->'-a &quot;%(FullPath)&quot;')" />
<_BlazorFolderLookupPaths Include="@(MonoBaseClassLibraryFolder->'-d &quot;%(Identity)&quot;')" /> <_BlazorFolderLookupPaths Include="@(MonoBaseClassLibraryFolder->'-d &quot;%(Identity)&quot;')" />
<_BlazorAssemblyDescriptorFiles <_BlazorAssemblyDescriptorFiles
@ -469,11 +500,11 @@
Condition="'$(_BlazorShouldLinkApplicationAssemblies)' == ''" Condition="'$(_BlazorShouldLinkApplicationAssemblies)' == ''"
Inputs="$(BlazorBuildCommonInputsCache); Inputs="$(BlazorBuildCommonInputsCache);
@(IntermediateAssembly); @(IntermediateAssembly);
@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll'))" @(_BlazorDependencyInput)"
Outputs="$(BlazorResolvedAssembliesOutputPath)" Outputs="$(BlazorResolvedAssembliesOutputPath)"
> >
<ItemGroup> <ItemGroup>
<_DependenciesParameter Include="@(ReferenceCopyLocalPaths->WithMetadataValue('Extension','.dll')->'--reference &quot;%(FullPath)&quot;')" /> <_DependenciesParameter Include="@(_BlazorDependencyInput->'--reference &quot;%(Identity)&quot;')" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<_BclParameter>--base-class-library &quot;$(MonoBaseClassLibraryPath)&quot; --base-class-library &quot;$(MonoBaseClassLibraryFacadesPath)&quot;</_BclParameter> <_BclParameter>--base-class-library &quot;$(MonoBaseClassLibraryPath)&quot; --base-class-library &quot;$(MonoBaseClassLibraryFacadesPath)&quot;</_BclParameter>
@ -564,7 +595,7 @@
<_CssReferences Include="@(BlazorPackageCssRef->'_content/%(SourcePackage)/%(RecursiveDir)%(FileName)%(Extension)')" /> <_CssReferences Include="@(BlazorPackageCssRef->'_content/%(SourcePackage)/%(RecursiveDir)%(FileName)%(Extension)')" />
</ItemGroup> </ItemGroup>
<Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; @(_AppReferences->'--reference %(Identity)', ' ') @(_JsReferences->'--js %(Identity)', ' ') @(_CssReferences->'--css %(Identity)', ' ') --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" /> <Exec Command="$(BlazorBuildExe) build @(IntermediateAssembly) --html-page &quot;$(BlazorIndexHtml)&quot; @(_AppReferences->'--reference &quot;%(Identity)&quot;', ' ') @(_JsReferences->'--js &quot;%(Identity)&quot;', ' ') @(_CssReferences->'--css &quot;%(Identity)&quot;', ' ') --output &quot;$(BlazorIndexHtmlOutputPath)&quot;" />
<ItemGroup Condition="Exists('$(BlazorIndexHtmlOutputPath)')"> <ItemGroup Condition="Exists('$(BlazorIndexHtmlOutputPath)')">
<_BlazorIndex Include="$(BlazorIndexHtmlOutputPath)" /> <_BlazorIndex Include="$(BlazorIndexHtmlOutputPath)" />

View File

@ -12,7 +12,9 @@
<IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled> <IsWebConfigTransformDisabled>true</IsWebConfigTransformDisabled>
</PropertyGroup> </PropertyGroup>
<Target Name="BlazorGetCopyToPublishDirectoryItems" BeforeTargets="GetCopyToPublishDirectoryItems"> <Target Name="BlazorGetCopyToPublishDirectoryItems"
BeforeTargets="GetCopyToPublishDirectoryItems"
DependsOnTargets="PrepareBlazorOutputs">
<ItemGroup> <ItemGroup>
<!-- Don't want to publish the assemblies from the regular 'bin' dir. Instead we publish ones from 'dist'. --> <!-- Don't want to publish the assemblies from the regular 'bin' dir. Instead we publish ones from 'dist'. -->
<ResolvedAssembliesToPublish Remove="@(ResolvedAssembliesToPublish)" /> <ResolvedAssembliesToPublish Remove="@(ResolvedAssembliesToPublish)" />