2009-10-13 42 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

相關問題