简体   繁体   English

如何从一个 Visual C# 项目构建两个不同的应用程序?

[英]How do I build two different apps from one Visual C# project?

I have a source base that, depending on defined flags at build time, creates two different apps.我有一个源代码库,它根据构建时定义的标志创建两个不同的应用程序。 I can build both of these apps using a Makefile by specifying two different targets, one that compiles with a flag and one that compiles without, and having an aggregate target that builds both.我可以使用 Makefile 通过指定两个不同的目标来构建这两个应用程序,一个使用标志进行编译,一个不使用标志进行编译,并且具有一个可以同时构建两者的聚合目标。

How do I do the equivalent thing from Visual C# Express on Windows?如何在 Windows 上从 Visual C# Express 执行等效操作?

Create one solution with two project files in the same folder.使用同一文件夹中的两个项目文件创建一个解决方案。 Set two different configurations in your solution, one of them building one of the projects, the other one building the other project.在您的解决方案中设置两种不同的配置,其中一个构建一个项目,另一个构建另一个项目。

Alternatively, you can have one project which always builds to intermediate binary and then have a postbuild step that copies it to the final binary depending on the flag.或者,您可以拥有一个始终构建为中间二进制文件的项目,然后进行构建后步骤,根据标志将其复制到最终二进制文件。

Release vs Debug?发布与调试? You can create your own custom configurations as well.您也可以创建自己的自定义配置。 But building a completely different app based on the configuration seems like a bad idea.但是基于配置构建一个完全不同的应用程序似乎是一个坏主意。

Normal visual studio can have multiple projects in one solution, and I think there's a way to shoe-horn this into Express edition (perhaps by opening a solution created elsewhere).普通的 Visual Studio 可以在一个解决方案中包含多个项目,我认为有一种方法可以将其硬塞到 Express 版本中(也许通过打开在别处创建的解决方案)。

Really,though, you may have to settle for keeping two instances of Visual Studio open at at a time.不过,实际上,您可能不得不满足于同时打开两个 Visual Studio 实例。 You can always set one of them to build right into the /bin/Release/ folder of the other project if you want.如果需要,您始终可以将其中一个设置为直接构建到另一个项目的 /bin/Release/ 文件夹中。

I don't know exactly about Express versions, but in Visual Studio there is a menu item Build->Batch Build to build all configurations at once.我不完全了解 Express 版本,但在 Visual Studio 中有一个菜单项Build->Batch Build可以一次构建所有配置。


I don't find visual studio easy to work with when I have complex build output scenario's.当我有复杂的构建输出场景时,我不觉得 Visual Studio 很容易使用。 What I typically do in these situations is use NAnt with a continuous integration tool like CruiseControl.Net .在这些情况下,我通常做的是将NAnt与像CruiseControl.Net这样的持续集成工具一起使用。 You can also build the project outputs locally with the same NAnt script.您还可以使用相同的 NAnt 脚本在本地构建项目输出。

A NAnt script is essentially an Xml build file with heaps more functionality. NAnt 脚本本质上是一个 Xml 构建文件,具有更多功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从一个 c# 项目与另一个 c# 项目进行通信 - How do I communicate from one c# project to another c# project 如何从一个Visual Studio项目创建两个不同的可执行文件 - How to create two different executables from one Visual Studio project 如何在项目中使用不同的文件以用于不同的构建配置 - Visual Studio C#.net - How to use different files in a project for different build configurations - Visual Studio C# .net 如何在Visual Studio C中创建“项目概述”# - How do I create a “Project overview” in Visual Studio C# 如何从Visual Studio中找到c#项目的类型? - How do I find type of c# project from Visual Studio? 如何在Visual Studio 2015的C#项目中运行简单的Powershell命令? - How do I run a simple Powershell command from my C# project in Visual Studio 2015? 在一个项目中使用同一个 nuget 的两个不同版本来构建两个不同的应用程序? - Use two different versions of the same nuget in one project to build two different apps? 如何在Visual C#或C ++中正确处理Windows 10应用程序的暂停? - How do I handle suspension of Windows 10 apps correctly in Visual C# or C++? 如何在 Visual Studio 或其他构建工具的一个 C# 项目中生成 dll 和 exe 的混合体? - how to produce a mix of dll and exe in one C# project in visual studio or other build tools? 从同一可视C#项目创建两个(略有不同)可执行文件 - Create two (slightly) different executables from same visual c# project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM