title: How to change code from one project for dependency project in C#
body: <p>ITNOA</p>
  
  <p>I want to learn how should I change code behavior and segment from one project for one of dependency project in C#</p>
  
  <p>I think my question is ambiguous ,so I try to explain my question in another language and ecosystem.</p>
  
  <p>In C++ We can write some library like below</p>
  
  <pre><code>// My library header file
  #ifndef MY_LIBRARY_H_
  #define MY_LIBRARY_H_
  
  #ifdef ML_HOOSHANG
  constexpr bool TEST = true;
  #else
  constexpr bool TEST = false;
  #endif
  
  #endif
  </code></pre>
  
  <p>In this scenario if I have another project that wants to use top library, we can change behavior of top library like below</p>
  
  <pre><code>// Main.cpp this is another project
  
  #include &lt;iostream&gt;
  
  #define ML_HOOSHANG 1
  #include &lt;MyLibrary.h&gt;
  
  int main()
  {
      cout &lt;&lt; ::TEST == true ? "Hoooray" : "Nooo" &lt;&lt; endl;
  }
  
  </code></pre>
  
  <p>And we see this result</p>
  
  <pre><code>Hoooray
  </code></pre>
  
  <p>And if I want to see <code>Nooo</code> we easily can ‍‍<code>#undef ML_HOOSHANG</code> in user library (the library make reference to <code>MyLibrary</code>.</p>
  
  <p>Another mechanism in C++ for doing something between library and very popular mechanism in C++ community that define some constant in build stage ,for example in <a href="https://stackoverflow.com/questions/9017573/define-preprocessor-macro-through-cmake">CMake</a> with <code>add_compile_definitions</code> , and it is very useful approach when we want to change some basic platform or environmental dependent behavior in dependency libraries of our project.</p>
  
  <p>now I want some similar mechanism in C# and <code>msbuild</code> ecosystem to provide same functionality, for example I have many projects and libraries, that all of them reference to one specific our library with nuget mechanism. and I want different behavior of this library depend on each project and library. so my question is How do I do this?</p>
  
  <p>If I want to show similar mechanism in C#, I can refer to <a href="https://stackoverflow.com/questions/5238955/what-is-a-portable-class-library">PCL mechanism</a> in solution to multi target problem. or <a href="http://gigi.nullneuron.net/gigilabs/multi-targeting-net-standard-class-libraries/" rel="nofollow noreferrer">netstandard library</a> mechanism for multi targeting different behavior approach.</p>
  
  <p>My problem is very similar to two top examples, except it is not multi target and those examples solving multi target problem, and I want to do something similar to what they did for solving multi target ,but different. I want to do something like what they did for solving multi target problem , for solving a problem similar to <a href="https://docs.microsoft.com/en-us/visualstudio/msbuild/when-element-msbuild?view=vs-2019#example" rel="nofollow noreferrer"><code>&lt;DefineConstants&gt;</code></a> in <a href="https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-reference?view=vs-2019" rel="nofollow noreferrer">msbuild</a> one project from another project that depend on it.</p>
  
  <p>How do I do this?</p>
  
  <p>How to create nuget package that have multiple output depend on multi define constants value? and how to <a href="https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files" rel="nofollow noreferrer">package reference</a> in <code>csproj</code> to another <code>nuget</code> depend on constatns?</p>