2009-10-13 75 views
4

我正在开发一个中型企业应用程序。 有很多项目/解决方案。 例如:何时以及如何在Visual Studio项目/解决方案中使用ILMerge

  • Company.Data
    • Company.Data.LinqToSql
  • Company.Entities(业务对象)
  • Company.BLL

然后我有一些应用程序 - 例如Windows服务: MyWindow sService。

当我部署这个(通过创建安装项目)它从上述项目的输出安装DLL的负载。

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

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

+0

http://stackoverflow.com/questions/9376/ilmerge-best-practices – 2009-10-13 17:05:25

回答

7

问题ILMerge Best Practices 有很好的信息为什么

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

至于如何,我定义了一个单独的自定义VS项目“Converged.csproj”,如果你喜欢。在那个.csproj文件中我定义了一个自定义的编译目标。它是样板代码,在项目的所有引用程序集上执行ILMerge。

它看起来像这样:

<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> 
+0

我有写作的MSBuild脚本没有经验。这是否也包括本地化卫星组件? – Wouter 2011-09-15 11:59:28

相关问题