Create a complete solution, but add global compilation symbols for only one project

I have a rather complicated solution containing 10 projects in addition to test projects. It is a network of distributed applications and services that exchange data using remote access; therefore, the availability of appropriate referenced assemblies (& versions) is crucial. That is why I want all this to be compiled and threshed in the ONE assembly.

One application is a demo / analytic tool that performs a subprocess of another - much larger - application based on user input and displays the results; Thus, the engineers have a tool that will help them configure their settings for "big computing." Obviously, the subprocess is contained in a different assembly, and most of the results presented to the engineers are generated

#if ENABLE_TRACE_MATCHING Trace.WriteLine("Some engineering output"); #endif 

My problem is that the conditional compilation symbols in the project settings are limited to this project assembly and do not propagate to reference assemblies. How can I customize my assembly so that all projects are built without defining ENABLE_TRACE_MATCHING, with the exception of one debug / analysis-app project, where all reference projects / assemblies must be compiled using ENABLE_TRACE_MATCHING

I also cannot replace #if ENABLE_TRACE_MATCHING with #if DEBUG, as this would allow us to get many different results that our engineers would not know how to handle.

Thanks in advance.

PS: If you think my code smells, I agree. Optional: basically this is not my code;)

+6
c # compilation build
source share
1 answer

You need to learn more about Microsoft Build, which is a ready-made Microsoft.NET tool present in any installation.

Using MSBuild, you can define these "characters" (properties) and a package of commands (goals).

To create an MSBuild script that imports the default Visual Studio goals from all the projects in your solution and declares these properties (“characters”) in the script.

In fact, the property to set such characters already exists: "DefineConstants".

So, since you have this, you can have this MSBuild script that provides this property value by re-declaring it there, so all MSBuild targets will know about these characters.

EDIT: Check out this other question: msbuild defining conditional compilation characters

+1
source share

All Articles