简体   繁体   English

ILMerge问题

[英]ILMerge question

I'm trying to merge multiple assemblies into one as my 'Proxy' assembly for a WCF service. 我正在尝试将多个程序集合并为一个作为WCF服务的“代理”程序集。 Currently, users of the Proxy need to reference the assembly containing the data contracts, and also my domain assembly because of my inheritance schemes. 目前,Proxy的用户需要引用包含数据协定的程序集,以及我的域程序集,因为我的继承方案。

I'd like to use ILMerge for this. 我想使用ILMerge。 In particular, the ILMerge-Tasks project looks promising, especially this line from their project home: 特别是,ILMerge-Tasks项目看起来很有希望,尤其是他们项目主页的这一行:

ILMerge-Tasks Project Home: ILMerge-Tasks项目主页:

...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. ...它甚至包括一个构建后事件,它合并ILMerge和任务dll,以便您可以使用没有ILMerge.exe的任务。

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 我们在TFS中使用自动构建,因此不存在ilmerge.exe将是一大优点

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): 所以我在我的项目中包含了ILMerge.MSBUild.Tasks.dll,并将以下内容添加到我的构建文件中(取自ilmerge项目主页):

<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. 找不到“UsingTask”任务。 Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 请检查以下内容:1。)项目文件中任务的名称与任务类的名称相同。 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 2.)任务类是“public”并实现Microsoft.Build.Framework.ITask接口。 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. 3.)在项目文件中或位于“C:\\ Windows \\ Microsoft.NET \\ Framework \\ v4.0.30319”目录中的* .tasks文件中正确声明了任务。

Solved. 解决了。

  • I did NOT use the configuration above 没有使用上述配置
  • I did NOT use the ILMerge.MSBuild.Tasks.dll 没有使用ILMerge.MSBuild.Tasks.dll

Here's the steps I took: 这是我采取的步骤:

  • Added a reference to ILMerge.exe (the one from Microsoft Research ) to my project 在我的项目中添加了对ILMerge.exeMicrosoft Research的一个)的引用
  • Added this PostBuild entry to my MSBuild file (.csproj): 将此PostBuild条目添加到我的MSBuild文件(.csproj):

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM