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

时间:2023-01-22 08:46:47

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执行相同的操作?

3 个解决方案

#1


2  

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.

或者,您可以将一个项目始终构建为中间二进制文件,然后进行后构建步骤,根据标志将其复制到最终二进制文件。

#2


0  

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).

普通视觉工作室可以在一个解决方案中拥有多个项目,我认为有一种方法可以将其转化为Express版本(可能通过打开其他地方创建的解决方案)。

Really,though, you may have to settle for keeping two instances of Visual Studio open at at a time. You can always set one of them to build right into the /bin/Release/ folder of the other project if you want.

但实际上,您可能不得不满足于一次打开两个Visual Studio实例。如果需要,您始终可以将其中一个设置为另一个项目的/ bin / Release /文件夹。

#3


0  

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. What I typically do in these situations is use NAnt with a continuous integration tool like CruiseControl.Net. You can also build the project outputs locally with the same NAnt script.

当我有复杂的构建输出场景时,我发现visual studio很容易使用。我在这些情况下通常做的是使用NAnt和CruiseControl.Net这样的持续集成工具。您还可以使用相同的NAnt脚本在本地构建项目输出。

A NAnt script is essentially an Xml build file with heaps more functionality.

NAnt脚本本质上是一个Xml构建文件,其中包含更多功能。

#1


2  

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.

或者,您可以将一个项目始终构建为中间二进制文件,然后进行后构建步骤,根据标志将其复制到最终二进制文件。

#2


0  

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).

普通视觉工作室可以在一个解决方案中拥有多个项目,我认为有一种方法可以将其转化为Express版本(可能通过打开其他地方创建的解决方案)。

Really,though, you may have to settle for keeping two instances of Visual Studio open at at a time. You can always set one of them to build right into the /bin/Release/ folder of the other project if you want.

但实际上,您可能不得不满足于一次打开两个Visual Studio实例。如果需要,您始终可以将其中一个设置为另一个项目的/ bin / Release /文件夹。

#3


0  

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. What I typically do in these situations is use NAnt with a continuous integration tool like CruiseControl.Net. You can also build the project outputs locally with the same NAnt script.

当我有复杂的构建输出场景时,我发现visual studio很容易使用。我在这些情况下通常做的是使用NAnt和CruiseControl.Net这样的持续集成工具。您还可以使用相同的NAnt脚本在本地构建项目输出。

A NAnt script is essentially an Xml build file with heaps more functionality.

NAnt脚本本质上是一个Xml构建文件,其中包含更多功能。