如何从一个 Visual C# 项目构建两个不同的应用程序?
我有一个源库,根据构建时定义的标志,创建两个不同的应用程序。 我可以使用 Makefile 来构建这两个应用程序,方法是指定两个不同的目标,一个使用标志进行编译,另一个不使用标志进行编译,并有一个构建这两个目标的聚合目标。
如何在 Windows 上的 Visual C# Express 中执行相同的操作?
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.
How do I do the equivalent thing from Visual C# Express on Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建一个解决方案,在同一文件夹中包含两个项目文件。 在您的解决方案中设置两种不同的配置,其中一种构建其中一个项目,另一种构建另一个项目。
或者,您可以拥有一个始终构建为中间二进制文件的项目,然后进行构建后步骤,根据标志将其复制到最终二进制文件。
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.
发布与调试? 您也可以创建自己的自定义配置。 但根据配置构建一个完全不同的应用程序似乎是一个坏主意。
普通的视觉工作室可以在一个解决方案中包含多个项目,我认为有一种方法可以将其硬塞到 Express 版本中(也许通过打开其他地方创建的解决方案)。
但实际上,您可能不得不满足于同时打开两个 Visual Studio 实例。 如果需要,您始终可以将其中一个设置为直接构建到另一个项目的 /bin/Release/ 文件夹中。
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).
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.
我不太清楚 Express 版本,但在 Visual Studio 中,有一个菜单项
Build->Batch Build
可以一次性构建所有配置。当我有复杂的构建输出场景时,我发现 Visual Studio 不太好用。 在这些情况下,我通常所做的是将 NAnt 与持续集成工具(如 CruiseControl.Net。 您还可以使用相同的 NAnt 脚本在本地构建项目输出。
NAnt 脚本本质上是一个具有更多功能的 Xml 构建文件。
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.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.
A NAnt script is essentially an Xml build file with heaps more functionality.