我正在尝试将多个程序集合并为一个程序集作为 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
关于c# - ILMerge问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7502179/