Note that there are some explanatory texts on larger screens.

plurals
  1. POBest practice with .gitignore for connection strings inside App.config or Web.config
    primarykey
    data
    text
    <p>I've tried several approaches with <code>*.gitignore</code> for managing connection strings when working on a larger team.</p> <p>From the official repository of <code>.gitignore</code> files at <a href="https://github.com/github/gitignore" rel="noreferrer">gitignore</a>, I've downloaded <a href="https://github.com/github/gitignore/blob/master/VisualStudio.gitignore" rel="noreferrer">VisualStudio.gitignore</a> and used it as a starting point for all the projects.</p> <p>The same process can be done by visiting <a href="http://gitignore.io/" rel="noreferrer">http://gitignore.io/</a>, typing VisualStudio, then downloading the file.</p> <p><img src="https://i.stack.imgur.com/dCsEN.jpg" alt="enter image description here"></p> <p>The approach I currently use is by leveraging the <a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource.aspx" rel="noreferrer">SectionInformation.ConfigSource Property</a></p> <pre><code>&lt;connectionStrings configSource="myConnectionStrings.config" /&gt; </code></pre> <p>and then adding <strong>myConnectionStrings.config</strong> to <code>.gitignore</code>, which is nice because it doesn't add the entire <code>*.config</code>.</p> <p>Also you can use the same <strong>myConnectionStrings.config</strong> inside another project (your <strong>MyProject.Data</strong> layer)</p> <pre><code>&lt;configuration&gt; &lt;connectionStrings configSource="myConnectionStrings.config"/&gt; &lt;/configuration&gt; </code></pre> <p>Just remember to set <strong>Copy always</strong>!</p> <p><img src="https://i.stack.imgur.com/ANJad.jpg" alt="enter image description here"></p> <p>Also I've tried using <a href="https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_tt_filter_tt" rel="noreferrer"><strong>filters</strong> </a> as described at <a href="https://stackoverflow.com/questions/15150317/git-ignoring-a-specific-modification-to-a-config-file">Git - Ignoring a specific modification to a config file</a>, but I find that to be an overkill.</p> <p>I wonder if there is any other approach that is considered a best practice?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload