c# - ILMerge问题

标签 c# .net assemblies ilmerge

我正在尝试将多个程序集合并为一个程序集作为 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/

相关文章:

c# - C#/VB.NET using 语句实际上对未实现 IDisposable 的类执行任何操作吗

.net - 将扁平化数据源转换为分层数据源

c# - 我应该如何从另一个解决方案中引用程序集?

c# - 获取音频文件C#的持续时间

c# - IIS 7.5、Web 服务和 HTTP 405 错误

c# - 具有相同接口(interface)但属性类型不同的类

.Net Treeview 事件处理

c# - WebService 客户端将字符串中的数字 1 替换为 _x0031_

c# - 运行时程序集位置更改

c# - 从 C# 可执行文件中扫描 DLL 依赖项