ILMerge question

坚强是说给别人听的谎言 提交于 2019-12-20 02:37:11

问题


I'm trying to merge multiple assemblies into one as my 'Proxy' assembly for a WCF service. Currently, users of the Proxy need to reference the assembly containing the data contracts, and also my domain assembly because of my inheritance schemes.

I'd like to use ILMerge for this. In particular, the ILMerge-Tasks project looks promising, especially this line from their project home:

ILMerge-Tasks Project Home:

...It even includes a post-build event that merges ILMerge and the task dll so that you can use the task without ILMerge.exe being present.

This is precisely what i'd like to accomplish, but i really have no idea how to go about it. Please help!

Other relevant (perhaps) info:

  • We are using automated builds in TFS, so not having ilmerge.exe present will be a big plus

Update:

So I included the ILMerge.MSBUild.Tasks.dll in my project and added the following to my build file (taken from ilmerge project home):

<Target Name="AfterBuild">

    <UsingTask TaskName="ILMerge.MSBuild.Tasks.ILMerge" 
        AssemblyFile="ILMerge.MSBuild.Tasks.ILMerge"/>
    <ItemGroup>
       <MergeAsm Include="BarProject.dll" />
       <MergeAsm Include="FooProject.dll" />
    </ItemGroup>

    <ILMerge InputAssemblies="@(MergeAsm)" OutputFile="FooBar.dll" />
</Target>

But now I get the following error:

The "UsingTask" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.


回答1:


Solved.

  • I did NOT use the configuration above
  • I did NOT use the ILMerge.MSBuild.Tasks.dll

Here's the steps I took:

  • Added a reference to ILMerge.exe (the one from Microsoft Research) to my project
  • Added this PostBuild entry to my MSBuild file (.csproj):

    ILMerge /out:FooBar.dll Bar.dll Foo.dll



来源:https://stackoverflow.com/questions/7502179/ilmerge-question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!