本文介绍了什么时候如何在Visual Studio项目/解决方案中使用ILMerge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发中型企业应用程序.有很多项目/解决方案.例如:

I'm developing a medium sized enterprise application.There are many projects / solutions to this.For example:

  • 公司数据
    • Company.Data.LinqToSql
    • Company.Data
      • Company.Data.LinqToSql

      然后我有一些应用程序-例如Windows服务:MyWindowsService.

      I then have some applications - for example a windows service:MyWindowsService.

      当我通过创建安装项目来部署它时,它会从上述项目的输出中安装DLL的负载.

      When i deploy this (by creating a setup project) it installs a load of DLL's from the output of the above mentioned projects.

      这是我应该使用ILMerge的地方吗?创建一个程序集....例如Company.dll?

      Is this where i should be using ILMerge? to create one assembly.... Company.dll for example?

      我该如何将其集成到我的构建过程中?

      How would i go about integrating this into my build process?

      推荐答案

      问题 ILMerge最佳做法为什么上有很好的信息.

      The question ILMerge Best Practiceshas good info on why.

      使用ILMerge时,我使用它来构建单个DLL,以简化部署.

      When I use ILMerge, I use it to build a single DLL, to simplify deployment.

      关于操作方式,如果愿意,我定义了一个单独的自定义VS项目"Converged.csproj".在该.csproj文件中,我定义了一个自定义的编译目标.它是样板代码,在项目的所有引用程序集上执行ILMerge.

      As to How, I define a separate, custom VS project, "Converged.csproj" if you like. In that .csproj file I define a custom Compile target. It is boilerplate code, that performs an ILMerge on all the referenced assemblies for the project.

      它看起来像这样:

      <Target Name="Compile">
        <!-- Outputs="$(IntermediateOutputPath)$(TargetFileName)" -->
        <!-- Outputs="$(TargetPath)" -->
        <Message Text="Performing the Ilmerge." />
        <!-- in this CreateItem stanza, we collect all the DLLs for the referenced projects -->
        <CreateItem Include="@(_ResolvedProjectReferencePaths)">
          <Output TaskParameter="Include" ItemName="AssembliesToMerge" />
        </CreateItem>
        <!-- This weird bit of hieroglyphics is the assemblies to merge, quoted, and separated by spaces -->
        <!-- Example:  "c:\foo\project1\bin\Debug\ProjectOne.dll"   "c:\foo\project2\bin\Debug\ProjectTwo.dll"  -->
        <Message Text="AssembliesToMerge= @(AssembliesToMerge -> '&quot;%(Fullpath)&quot;', ' ')" />
        <!-- Message Text="TargetPath= $(TargetPath)" / -->
        <Message Text="TargetFileName= $(TargetFileName)" />
        <!-- produce the merged assembly - putting the output in the "IntermediateOutputPath" eg obj\Debug. -->
        <!-- it will be copied later by the CopyFilestoOutputDirectory task defined in Microsoft.Common.Targets -->
      
        <Error
           Text="ILMerge cannot be found. You need to download and install ILMerge in order to build DotNetZip."
           Condition="!Exists('$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe')" />
      
        <Exec Command="&quot;$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe&quot;  /t:library  /xmldocs /out:&quot;$(IntermediateOutputPath)$(TargetFileName)&quot;  @(AssembliesToMerge -> '&quot;%(Fullpath)&quot;', ' ') " />
      
        <!-- for some reason the XML doc file does not get copied automatically from obj\Debug to bin\Debug. -->
        <!-- we do it here explicitly. -->
        <Copy SourceFiles="$(IntermediateOutputPath)$(AssemblyName).XML" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)" />
      </Target>
      

      这篇关于什么时候如何在Visual Studio项目/解决方案中使用ILMerge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 06:44