gpt4 book ai didi

.net - Visual Studio 2008 : Creating Single DLL from Solution with Many Projects

转载 作者:行者123 更新时间:2023-12-02 20:12:56 25 4
gpt4 key购买 nike

我有一个在 Visual Studio 2008 中开发的 ASP.NET Web 应用程序,由 3 个不同的项目组成(一个用于 UI,一个用于 BO ,第三个用于 DAL )。

如何生成包含所有 3 个内容的单个程序集文件?现在,它为解决方案中的每个项目生成 3 个 DLL。

最佳答案

为每个项目创建一个网络模块或程序集,并将它们全部编译/合并到一个程序集中。

第一个替代方案。这是由 Jay R. Wren 提出的。 :

This is a cute hack, but with the CSC and VBC both supporting the /target:module and /addmodule options, you could actually do this without ILMerge just by using a shell script or make file.

Visual Studio doesn't support the "netmodule" type, but MSBuild does.

Add the VB project to your solution. Unload the project and edit the project file.

Change OutputType to module:

<OutputType>module</OutputType>

Instead of adding a reference to the desired project, we add a module. Sadly, again VStudio fails here, but MSBUILD works just fine. Unload the project and edit the project file. Add an item group with AddModules include directives.

<ItemGroup><AddModules Include="..\VbXml\bin\Debug\VbXml.netmodule" /></ItemGroup>

This will tell msbuild to tell CSC to use /addmodule directives, just like the Reference Item Group which Studio does manage.

Major Drawback: No Visual Studio Intellisense for the added module. We already have references, it is too bad we don't have modules. [UPDATE: As @Ark-kun pointed out elsewhere, Visual Studio can reference .netmodule projects and have Intellisense. Just add the project reference BEFORE changing the output type.]

SharpDevelop has the first step, but the second step, an "Add Module" gui has been open as a low priority item since SD 2.0.

第二种方式。这个great article (作者:Scott Hanselman)描述了在使用 Visual Studio 时如何自动合并程序集。与第一个替代方案不同的是,它确实为您提供 IntelliSense 支持

第三种方法。使用 scs 手动执行。
如何创建多个模块并将主题链接到单个 dll 中的示例:

csc /t:module RarelyUsedTypes.cs
csc /out:AllTypes.dll /t:library /addmodule:RarelyUsedTypes.netmodule AllTypes.cs

有关更多信息,请参阅 Richter 的书 CLR via C# .

关于.net - Visual Studio 2008 : Creating Single DLL from Solution with Many Projects,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1878807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com