Skip to content

Commit

Permalink
Implement fan-out behavior for publish.
Browse files Browse the repository at this point in the history
Contributes to #22.
  • Loading branch information
alexrp committed Jul 8, 2021
1 parent 782248f commit 6fbd0fb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/sdk/build/Zig.Sdk.Build.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<_RealOrFanOutBuild>_InnerBuild</_RealOrFanOutBuild>
<_RealOrFanOutBuild Condition="'$(_BuildCleanFanOut)' == 'true'">_FanOutBuild</_RealOrFanOutBuild>
<_RealOrFanOutBuild Condition="'$(_RidFanOut)' == 'true'">_FanOutBuild</_RealOrFanOutBuild>
</PropertyGroup>

<Target Name="Build"
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/build/Zig.Sdk.Clean.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<PropertyGroup>
<_RealOrFanOutClean>_InnerClean</_RealOrFanOutClean>
<_RealOrFanOutClean Condition="'$(_BuildCleanFanOut)' == 'true'">_FanOutClean</_RealOrFanOutClean>
<_RealOrFanOutClean Condition="'$(_RidFanOut)' == 'true'">_FanOutClean</_RealOrFanOutClean>
</PropertyGroup>

<Target Name="Clean"
Expand Down
12 changes: 6 additions & 6 deletions src/sdk/build/Zig.Sdk.Overrides.targets
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
</PropertyGroup>

<!--
If a RuntimeIdentifier value has not been set, it means the Build and Clean
targets should fan out and run for every RID supported by the project. That
said, for running and testing, we still need to run natively by default, so
we still have to set a default RID. We use _BuildCleanFanOut to indicate
whether the fan-out behavior is required.
If a RuntimeIdentifier value has not been set, it means the Build, Clean,
and Publish targets should fan out and run for every RID supported by the
project. That said, for running and testing, we still need to run natively
by default, so we still have to set a default RID. We use _RidFanOut to
indicate whether the fan-out behavior is required.
-->
<PropertyGroup Condition="'$(RuntimeIdentifier)' == ''">
<RuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</RuntimeIdentifier>
<_BuildCleanFanOut>true</_BuildCleanFanOut>
<_RidFanOut>true</_RidFanOut>
</PropertyGroup>
</Project>
35 changes: 35 additions & 0 deletions src/sdk/build/Zig.Sdk.Publish.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
<Project>
<PropertyGroup>
<_RealOrFanOutPublish>_InnerPublish</_RealOrFanOutPublish>
<_RealOrFanOutPublish Condition="'$(_RidFanOut)' == 'true'">_FanOutPublish</_RealOrFanOutPublish>
</PropertyGroup>

<Target Name="Publish"
DependsOnTargets="$(_RealOrFanOutPublish)"
Condition="'$(_InvalidConfigurationWarning)' != 'true'" />

<Target Name="_FanOutPublish">
<ItemGroup>
<_RuntimeIdentifiers Include="$(RuntimeIdentifiers)" />
<_InnerProjects Include="$(MSBuildProjectFullPath)"
Properties="RuntimeIdentifier=%(_RuntimeIdentifiers.Identity)" />
</ItemGroup>

<MSBuild Projects="@(_InnerProjects)"
Targets="_InnerPublish"
BuildInParallel="$(BuildInParallel)" />
</Target>

<!--
Unfortunately, the publish logic in the .NET SDK is not factored as well as
the build and clean logic in MSBuild, so we have to duplicate some of the
logic in the default Publish target here.
-->
<Target Name="_InnerPublish"
DependsOnTargets="_PublishBuildAlternative; _PublishNoBuildAlternative">
<Message Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath('$(PublishDir)'))"
Importance="high" />

<AllowEmptyTelemetry EventName="PublishProperties"
EventData="PublishReadyToRun=$(PublishReadyToRun); PublishTrimmed=$(PublishTrimmed); PublishSingleFile=$(PublishSingleFile)" />
</Target>

<!-- TODO: https://github.com/alexrp/zig-msbuild-sdk/issues/16 -->
</Project>

0 comments on commit 6fbd0fb

Please sign in to comment.