dotnet / ILMerge

ILMerge is a static linker for .NET Assemblies.
MIT License
1.22k stars 169 forks source link

Instructions for MSBuild in the main readme.md are wrong. #52

Open BrainSlugs83 opened 5 years ago

BrainSlugs83 commented 5 years ago

Per the current readme.md:

<ItemGroup>
    <PackageReference Include="ILMerge" Version="2.15.0" />
  </ItemGroup>

  <Target Name="ILMerge">
    <!-- the ILMergePath property points to the location of ILMerge.exe console application -->
    <Exec Command="$(ILMergeConsolePath) /out:Merged.dll File1.dll File2.dll" />
</Target>

This has multiple problems... :-/ 1.) The latest version of the package on the NuGet gallery is only 2.14.1208 -- so, the package reference fails.

2.) Even after updating the package reference, the ILMerge target will fail, because $(ILMergeConsolePath) is not defined (is there a targets file we need to import??)

3.) The comment refers to the property is the "ILMergePath" property (instead of ILMergeConsolePath) -- which is also not defined.

moh-hassan commented 5 years ago

It's nice if you describe the msbuild as a task after build.

franzeal commented 5 years ago

Concerning 2 and 3, at least in my case I could see from the output console that the ILMergeConsolePath was correctly defined. You can also reconcile the discrepancy between the comment and the code with a look at the package's build\ILMerge.props which defines ILMergeConsolePath.

What worked for me was following the readme, updating the version, and making my paths absolute:

<Exec Command="$(ILMergeConsolePath) /out:&quot;$(TargetDir)Merged.dll&quot; &quot;$(TargetDir)File1.dll&quot; &quot;$(TargetDir)File2.dll&quot;" />

Similar to above, I do this task post build. Not sure if there's a means to set the working directory, as that would be preferred.

replaysMike commented 4 years ago

I too am seeing this issue - ILMergeConsolePath isn't populated. If I look at ILMerge.props it's defined as <ILMergeConsolePath>$(MSBuildThisFileDirectory)..\tools\net452\ILMerge.exe</ILMergeConsolePath>

EDIT: I switched to using ILRepack and it worked perfectly.