简体   繁体   English

如何在同一解决方案中执行另一个项目?

[英]How to execute another project within the same solution?

I have few projects in my solution explorer that I want to build sequentially as shown in the below figure. 我的解决方案资源管理器中有几个项目要按顺序构建,如下图所示。 在此处输入图片说明

The buildserver Project here is trying to build a .dll. 这里的buildserver项目正在尝试构建.dll。 I want this project to be executed from the testExecutive project. 我希望从testExecutive项目执行该项目。 How do I go about doing this? 我该怎么做呢?

I tried adding build dependencies and also added {using Buildserver} in my testExecutive.cs file. 我尝试添加构建依赖关系,并在testExecutive.cs文件中添加了{using Buildserver}。 But when I click run only the testexecutive project runs, not the buildserver. 但是,当我单击运行时,仅运行testexecutive项目,而不运行buildserver。

Can I programmatically command another project to build? 我可以以编程方式命令另一个项目进行构建吗?

Build dependency only ensures that project you specified in the dependencies section (BuildServer) is built before the dependent project (testExecutive) when you build the whole solution. 构建依赖关系仅确保在构建整个解决方案时,在依赖关系部分(BuildServer)中指定的项目先于依赖项目(testExecutive)生成。

If you want to run some action before the build of a specific project, there is a "Build Events" section in the project properties where you can execute any command prior to the build if you specify it in "Pre-build event command line". 如果要在构建特定项目之前运行某些操作,则在项目属性中有一个“构建事件”部分,如果您在“构建前事件命令行”中指定了任何命令,则可以在构建前执行任何命令。 。 To achieve what you described, you could enter here: 要实现您所描述的内容,您可以在此处输入:

MSBuild ..\BuildServer\BuildServer.csproj /verbosity:minimal /target:Rebuild

But I would not recommend that, because that will build it twice when you rebuild the whole solution. 但是我不建议这样做,因为在重新构建整个解决方案时,它将两次构建。

You could maybe define it to work like that only for debug mode: 您可能会定义它仅在调试模式下才能工作:

if $(ConfigurationName) == Debug MSBuild ..\BuildServer\BuildServer.csproj /verbosity:minimal /target:Rebuild

make sure that the csproj path is correct and msbuild.exe is in your environment variable path. 确保csproj路径正确,并且环境变量路径中包含msbuild.exe。

But all this seems unnecessary to me. 但是所有这些对我来说似乎都是不必要的。 You can just right click your BuildServer project and select build any time after you update any code there. 您可以右键单击BuildServer项目,然后在其中更新任何代码后随时选择构建。 Or just build the whole solution with F6. 或者只是使用F6构建整个解决方案。 Project dependency will ensure that BuildServer is built before testExecutive project. 项目依赖性将确保在testExecutive项目之前构建BuildServer。

暂无
暂无

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

相关问题 如何在同一解决方案中导航到另一个项目 - How to navigate to another project inside same solution 如何在相同的解决方案中将menuitem绑定到另一个项目 - how to bind menuitem to another project in same solution 如何在同一解决方案中访问另一个项目的服务 - How to access service of another project in same solution 将用户控件从一个项目复制到同一解决方案中的另一个项目 - Copy User Control from one project to another within same solution Visual Studio - Intellisense 无法识别同一解决方案中另一个项目中的命名空间 - Visual Studio - Intellisense not recognizing namespace in another project within same solution WinRT-如何在同一解决方案中使用来自另一个项目的自定义控件? - WinRT - How to use custom control from another project within the same solution? 在同一项目解决方案中如何在C#中将一个dll的类调用到另一个dll - How to call Class of one dll to another dll in c# within the same project solution 一个项目的class在同一个方案下如何在另一个项目中使用? - How to use a class of one project in another project under the same solution? 如何在项目或解决方案中定义具有相同成员的 static class? - How to define a static class with members which are the same within the project or solution? Visual Studio,在同一解决方案文件中调用另一个项目的Debug项目 - Visual Studio, Debug project that calls another project within the same solution file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM