Closed mamift closed 8 months ago
OK I've solved this on my own.
Instead of putting the key details in it's own ILRepack.Config.Props file:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<KeyFile>$(ProjectDir)key.snk</KeyFile>
</PropertyGroup>
</Project>
It works to put a KeyFile
XML attribute in the <ILRepack />
element inside of the ILRepack.targets file:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="ILRepacker" AfterTargets="Build" Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug'">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)\$(AssemblyName).dll" />
<InputAssemblies Include="$(OutputPath)\XObjectsCore.dll" />
</ItemGroup>
<ItemGroup>
<!--<DoNotInternalizeAssemblies Include="System.ValueTuple.dll" />-->
</ItemGroup>
<ILRepack Parallel="true" Internalize="true" InternalizeExclude="@(DoNotInternalizeAssemblies)" InputAssemblies="@(InputAssemblies)" TargetKind="Dll" OutputFile="$(OutputPath)\$(AssemblyName).dll"
KeyFile="$(ProjectDir)key.snk" />
</Target>
</Project>
Please update the README to indicate this.
As mentioned in the doc, "This configuration option only applies if you are using the default targets file provided in NuGet package." So if you are using custom targets file then it won't work.
Which file do you specifically place the
<KeyFile>$(ProjectDir)key.snk</KeyFile>
element when you need to sign/strong name the resultant merged assembly?I've copied the contents of this file into my project: https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/blob/caf641eab2567434562e37768aba04559e6e0b24/ILRepack.Lib.MSBuild.Task/ILRepack.Config.props
And the SNK file exists (key.snk) under the $(ProjectDir). But my output DLL is still not being signed; when I check the key with the sn.exe tool, it says:
Is it in the csproj file, the ILRepack.Config.props or the ILRepack.targets file?
I've also tried adding it to the ILRepack.targets file, then I get an error:
14/10/2022 12:13:07 PM Critical Project load failed| [MSB4067] The element <#text> beneath element <KeyFile> is unrecognized. C:\Users\mmiftah\source\repos\solution\project\ILRepack.targets at (18:3)
I've also tried adding it to the CSPROJ file, but the build output still doesn't change.