Sameer
Sameer

Reputation: 137

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. enter image description here

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?

Upvotes: 0

Views: 2481

Answers (1)

z m
z m

Reputation: 1503

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.

Upvotes: 2

Related Questions