简体   繁体   中英

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. I want this project to be executed from the testExecutive project. How do I go about doing this?

I tried adding build dependencies and also added {using Buildserver} in my testExecutive.cs file. But when I click run only the testexecutive project runs, not the 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.

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.

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. Or just build the whole solution with F6. Project dependency will ensure that BuildServer is built before testExecutive project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM