Is it possible to make elements in a Visual Studio .sln file conditional?
Asked Answered
A

1

6

Is it possible to make elements in a Visual Studio .sln file conditional?

Although the .sln file is oddly not in MSBuild or even XML format, I would love to use a similar syntax.

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloProj", 
    "HelloProj.csproj",
    "{61729087-EEA0-4C80-BF72-4205970239F9}"
EndProject

would become:

Project( Condition="Some Condition Stuff"
    "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloProj", ...

So, if "Some Condition Stuff" evaluated to false, the project HelloProj would not be included when you open the solution. I doubt this is feasible, I'm not even sure if the solution file has a concept of properties/variable, but I thought I would ask anyway.

Ardeliaardelis answered 27/10, 2015 at 16:3 Comment(0)
T
1

Nothing exists that I am aware of that will fully remove a project from being loaded when you open a solution. I don't think that is the intent of the solution file, rather if you need to include/exclude projects based on some criteria at open time it's probably safe to consider using multiple solution files where each solution contains the correct projects for a situation.

However, for C#/C++/C projects you can use the Configuration Manager to modify the build and deploy behaviour for each project in your solution based on the Platform and Configuration chosen. In the solution explorer, right-click on your solution and choose 'Configuration Manager...'.

Screen capture of the Configuration Manager in use to turn off building a project in a solution for the Any CPU platform and Debug configuration

Tassel answered 30/10, 2015 at 9:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.