title: Sharing configuration file among the projects in asp.net core
body: <p>I have a solution in <code>asp.net core</code> and multiple API projects are present inside and that is a kind of micro services architecture. My solution structure looks like below.</p>
  
  <pre><code>ABC.API
  DEF.API
  GHI.API and so on....
  </code></pre>
  
  <p>I also have one more class library project that is having some common functionalities and can be used by all above API projects.</p>
  
  <p>And I want to keep the connection string inside the class library project using <code>json</code> file or <code>config</code> file because all of the above are connecting to same database and i don't want to repeat those in all the projects.</p>
  
  <p>Problem:</p>
  
  <ul>
  <li>How to keep the file (json/config) in library project. If placed then after publishing the project how the values will store because it will generate a .dll file.</li>
  <li>How to access the connection string in API projects the reason is I am initializing the connection in API projects.</li>
  <li><p>I tried by keeping the file in a upper folder and then added the below settings in <code>Program.cs</code>.</p>
  
  <pre><code>var sharedFolder = Path.Combine(env.ContentRootPath, "..\\..", "Shared");
  config..AddJsonFile(Path.Combine(sharedFolder, "SharedSettings.json"), optional: false)
  </code></pre>
  
  <p>But this is not working as after publishing the project separately the folder will not be found.</p></li>
  </ul>
  
  <p>Can anyone guide me how to achieve this and am I on the right track ?</p>