[英]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.