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

标签 .net visual-studio-2008 deployment dll assemblies

我有一个在 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/

相关文章:

C# 如何通过方法中的可选参数解决这个困境?

visual-studio - Visual Studio-我希望“转到定义”打开对象浏览器,而不是“元数据”

vb.net - 超时已过。操作完成前超时时间已过或服务器未响应

c# - 使用 C# 在 LDAP 中搜索标题?

java - 无法将 Grails 应用程序部署到 JDK 不匹配的 Tomcat 8 : 404 The requested resource is not available

c# - 如何解决dotnet核心中的nuget依赖 hell ?

deployment - 什么是查看 puppet 代码的好资源?

.net - Firefox 发送请求两次

c# - .NET Core 1.1 项目启动时 Microsoft.AspNetCore.Server.Kestrel 中的 TypeLoadException

C#:如何访问窗体类外部的按钮