Skip to content

Commit f5c7cc1

Browse files
committed
Ensure dotnet-ilrepack is installed before IL merging
This simplifies consumption and avoids having to create custom CI build steps to install the right tool. If the PR to include this global tool in the main ILRepack distribution is merged (see gluck/il-repack#364), we can remove the --add-source and --prerelease switches.
1 parent 9905644 commit f5c7cc1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

samples/dotnet/SponsorLink.targets

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ partial class SponsorLink
115115
</ItemGroup>
116116
</Target>
117117

118+
<Target Name="EnsureILRepack" BeforeTargets="ILRepack" Condition="'$(MergeAnalyzerAssemblies)' == 'true'">
119+
<Exec Command="ilrepack --version" StandardErrorImportance="high" StandardOutputImportance="low" ConsoleToMSBuild="true" IgnoreExitCode="true" ContinueOnError="true">
120+
<Output TaskParameter="ConsoleOutput" PropertyName="ILRepackOutput" />
121+
<Output TaskParameter="ExitCode" PropertyName="ExitCode" />
122+
</Exec>
123+
<Message Importance="high" Text="Using installed dotnet-ilrepack v$(ILRepackOutput)" Condition="$(ExitCode) == '0'" />
124+
<Exec Command="dotnet tool install -g dotnet-ilrepack --prerelease --add-source https://kzu.blob.core.windows.net/nuget/index.json"
125+
Condition="$(ExitCode) != '0'" />
126+
<Exec Command="ilrepack --version" Condition="$(ExitCode) != '0'" ConsoleToMSBuild="true">
127+
<Output TaskParameter="ConsoleOutput" PropertyName="ILRepackInstalledOutput" />
128+
</Exec>
129+
<Message Importance="high" Text="Installed dotnet-ilrepack v$(ILRepackInstalledOutput)" Condition="$(ExitCode) != '0'" />
130+
</Target>
131+
118132
<Target Name="ILRepack" AfterTargets="CoreCompile" BeforeTargets="CopyFilesToOutputDirectory"
119133
Inputs="@(IntermediateAssembly -&gt; '%(FullPath)')"
120134
Outputs="$(IntermediateOutputPath)ilrepack.txt"

0 commit comments

Comments
 (0)