我正在尝试将多个程序集合并为一个WCF服务的“代理”程序集.当前,由于我的继承方案,代理服务器的用户需要引用包含数据协定的程序集,以及我的域程序集.
我想为此使用ILMerge.特别是,ILMerge-Tasks项目看起来很有希望,尤其是在其项目主页中的这一行:
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.
这正是我想要完成的工作,但是我真的不知道如何去做.请帮忙!
其他相关(可能)信息:
>我们在TFS中使用自动构建,因此不存在ilmerge.exe将是一个很大的优势
更新:
因此,我将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>
但是现在我得到以下错误:
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.
解决方法:
解决了.
>我没有使用上面的配置
>我没有使用ILMerge.MSBuild.Tasks.dll
这是我采取的步骤:
>在我的项目中添加了对ILMerge.exe(从Microsoft Research开始的引用)的引用
>将此PostBuild条目添加到我的MSBuild文件(.csproj)中:
ILMerge /out:FooBar.dll Bar.dll Foo.dll