3
votes

i have some visual studio projects which depend on other projects, which have different configurations.

example:
Project MyProject (Configuration: Release)
  References:
    Project LibA (Configuration: Release_DontLink)
    Project LibB (Configuration: Release

Building using Visual Studio works correctly as the Configurations to be used for the different projects are stored inside the solution file.

But when i use msbuild to build MyProject, it builds the Release configuration of LibA, which is incorrect. Since both LibA and LibB are used by numerous other Projects, i cant change those configurations, i only have control over MyProject.

Is there any way to build MyProject using MsBuild without changing the LibA and LibB projects?

Possibly related question: Configuration for ProjectReference in MSBuild, however i did not fully understand the answer, and i think it would require me to change LibA/LibB

2

2 Answers

2
votes

On the solution level (i.e: MyProject.sln), open the property pages and set the Release configuration to build Release_DontLink configuration for project LibA. If you don't have control over the sln file, you should be able to create a copy of it (i.e: MyProject.Release.sln).

sln properties

Then build the solution with:

msbuild MyProject.sln /p:Configuration=Release

Alternatively (not even remotely a best practice), after building MyProject build LibA while overriding its OutDir property:

msbuild LibA.csproj /p:Configuration=Release_DontLink;OutDir=..LibA\Release
0
votes

I just had the same problem and found that the solution config needed to be done for all configured platforms.