Skip to content

Commit 6fbd0fb

Browse files
committed
Implement fan-out behavior for publish.
Contributes to #22.
1 parent 782248f commit 6fbd0fb

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

src/sdk/build/Zig.Sdk.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<_RealOrFanOutBuild>_InnerBuild</_RealOrFanOutBuild>
4-
<_RealOrFanOutBuild Condition="'$(_BuildCleanFanOut)' == 'true'">_FanOutBuild</_RealOrFanOutBuild>
4+
<_RealOrFanOutBuild Condition="'$(_RidFanOut)' == 'true'">_FanOutBuild</_RealOrFanOutBuild>
55
</PropertyGroup>
66

77
<Target Name="Build"

src/sdk/build/Zig.Sdk.Clean.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<PropertyGroup>
1212
<_RealOrFanOutClean>_InnerClean</_RealOrFanOutClean>
13-
<_RealOrFanOutClean Condition="'$(_BuildCleanFanOut)' == 'true'">_FanOutClean</_RealOrFanOutClean>
13+
<_RealOrFanOutClean Condition="'$(_RidFanOut)' == 'true'">_FanOutClean</_RealOrFanOutClean>
1414
</PropertyGroup>
1515

1616
<Target Name="Clean"

src/sdk/build/Zig.Sdk.Overrides.targets

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
</PropertyGroup>
1818

1919
<!--
20-
If a RuntimeIdentifier value has not been set, it means the Build and Clean
21-
targets should fan out and run for every RID supported by the project. That
22-
said, for running and testing, we still need to run natively by default, so
23-
we still have to set a default RID. We use _BuildCleanFanOut to indicate
24-
whether the fan-out behavior is required.
20+
If a RuntimeIdentifier value has not been set, it means the Build, Clean,
21+
and Publish targets should fan out and run for every RID supported by the
22+
project. That said, for running and testing, we still need to run natively
23+
by default, so we still have to set a default RID. We use _RidFanOut to
24+
indicate whether the fan-out behavior is required.
2525
-->
2626
<PropertyGroup Condition="'$(RuntimeIdentifier)' == ''">
2727
<RuntimeIdentifier>$(NETCoreSdkPortableRuntimeIdentifier)</RuntimeIdentifier>
28-
<_BuildCleanFanOut>true</_BuildCleanFanOut>
28+
<_RidFanOut>true</_RidFanOut>
2929
</PropertyGroup>
3030
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
<Project>
2+
<PropertyGroup>
3+
<_RealOrFanOutPublish>_InnerPublish</_RealOrFanOutPublish>
4+
<_RealOrFanOutPublish Condition="'$(_RidFanOut)' == 'true'">_FanOutPublish</_RealOrFanOutPublish>
5+
</PropertyGroup>
6+
7+
<Target Name="Publish"
8+
DependsOnTargets="$(_RealOrFanOutPublish)"
9+
Condition="'$(_InvalidConfigurationWarning)' != 'true'" />
10+
11+
<Target Name="_FanOutPublish">
12+
<ItemGroup>
13+
<_RuntimeIdentifiers Include="$(RuntimeIdentifiers)" />
14+
<_InnerProjects Include="$(MSBuildProjectFullPath)"
15+
Properties="RuntimeIdentifier=%(_RuntimeIdentifiers.Identity)" />
16+
</ItemGroup>
17+
18+
<MSBuild Projects="@(_InnerProjects)"
19+
Targets="_InnerPublish"
20+
BuildInParallel="$(BuildInParallel)" />
21+
</Target>
22+
23+
<!--
24+
Unfortunately, the publish logic in the .NET SDK is not factored as well as
25+
the build and clean logic in MSBuild, so we have to duplicate some of the
26+
logic in the default Publish target here.
27+
-->
28+
<Target Name="_InnerPublish"
29+
DependsOnTargets="_PublishBuildAlternative; _PublishNoBuildAlternative">
30+
<Message Text="$(MSBuildProjectName) -> $([System.IO.Path]::GetFullPath('$(PublishDir)'))"
31+
Importance="high" />
32+
33+
<AllowEmptyTelemetry EventName="PublishProperties"
34+
EventData="PublishReadyToRun=$(PublishReadyToRun); PublishTrimmed=$(PublishTrimmed); PublishSingleFile=$(PublishSingleFile)" />
35+
</Target>
36+
237
<!-- TODO: https://github.com/alexrp/zig-msbuild-sdk/issues/16 -->
338
</Project>

0 commit comments

Comments
 (0)