I have a rather large solution consisting of about 10 different projects. Until now we have shipped the entire solution as a whole to customers, but we are looking into shipping a stripped version of our software.
To this end I would like to exclude several projects from the solution. I know that you can prevent projects from being built in the solution configuration manager. Using macros all code references can be disabled when the stripped configuration is chosen. Unfortunately this does not take care of the project references. Can I make these references conditional depending on the chosen configuration?
It should be a pretty simple matter to remove the project references from the project file using a small script - it would just be a case of removing lines adding those references. The project file format is quite simple.
I suspect that's likely to be the easiest solution.
There's lots of info in http://bytes.com/topic/net/answers/444853-conditional-assembly-reference that I found very useful for resolving a similar question (it pertains more to assembly references than project references though). MSBuild get assembly reference from ProjectReference might help with bridging between.
Your best bet is to create separate projects for your "stripped down" solution that references only those other projects you want. Reference the same code. Create a separate solution to hold those projects together.
They can all live together in the same folder structure, too.
For example:
MySolution/MyProject2/MyClass3.cs
MySolution references MyProject1 and MyProject2 and MyProject3
I think that this should be done when you build your projects for production. Simply enclose all code that needs to disappear between a compiler-level IF, that checks for a defined compiler directive. If on, then the code between the IF and ENDIF will not compile. This works for code files only.
For anything other that you need to take out, just make up your own way, depending on the file format, as Jon Skeet mentioned. But once you put that into build scripts, you need not care about it any more - no switching configurations, etc.
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.