Visual Studio 2015 does not respect nuget's repository path for ASP.NET Core projects
<p>I have Visual Studio 2015 Enterprise with Update3. In one VS solution i have 3 different projects. 2 projects are <code>ASP.Net Core</code> and 3rd project is classic <code>.Net 4.6.2</code></p>

<p>All 3 projects have nuget packages and i want to store them at one location relative to solution file. <code>(eg C:Root\Lib\packages)</code> Certain packages will shared between 2 <code>ASP.Net Core</code> projects. However note that i am <strong>NOT</strong> trying to share a package between <code>ASP.Net Core</code> projects and classing <code>.net 4.6.2</code> project.   </p>

<p>So i put <code>nugget.config</code> file as shown below at the <code>C:\root</code>.</p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;configuration&gt;
    &lt;config&gt;
        &lt;add key="repositoryPath" value=".\Lib\packages" /&gt;
    &lt;/config&gt;  
  &lt;/configuration&gt;
</code></pre>

<p>The above settings stores the nugget packages for <code>.Net 4.6.2</code> project into <code>C:\Root\Lib\packages\</code> folder. Exactly where i wanted.</p>

<p>However the <code>ASP.NET Core</code> projects does not respect repositoryPath. I found discussion <a href="https://github.com/NuGet/Home/issues/626" rel="nofollow noreferrer">here</a>  that says</p>

<blockquote>
  <p>project.json project doesn't support repositoryPath config now, if you
  want to change packages default location, you can set "NUGET_PACKAGES"
  environment variable to do that.</p>
</blockquote>

<p>So on both the <code>ASP.NET Core</code> projects i added <strong>NUGET_PACKAGES</strong> environment variable and set the value to <code>.\Lib\packages</code> and clicked on restore  packages. However that still restores <code>ASP.NEt Core</code> packages to <strong>C:\Users{user-name}\ .nuget\packages</strong></p>

<p><strong>Update1</strong><br>
I set environment variable in <code>ASP.NET Core</code> project's property page.<br>
Right Click on Project ->Properties->Debug->Add</p>

<p><a href="https://i.stack.imgur.com/JvTqk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JvTqk.png" alt="enter image description here"></a></p>

<p><strong>Update2</strong>  </p>

<p>so based on the suggestions below I added <code>NUGET_PACKAGES</code> environment variable via windows at user level. and sets its value to <code>C:\Root\Lib\packages</code> folder. and also deleted <code>'nuget.config</code> file from <code>C:\root</code>
I noticed only <code>asp.net core</code> projects which has <code>package.json</code> file honors the environment variable. The <code>classic .Net 4.6.2</code> project restore packages to their default location, it does not honor <code>NUGET_PACKAGES</code> variable.</p>

<p><strong>2nd approach I tried</strong><br>
Also as per the documentation <a href="http://docs.nuget.org/consume/nuget-config-file" rel="nofollow noreferrer">here</a> under <code>Environment variables in configuration</code> section, we can now use environment variable in <code>nuget.config</code> file. I am not able to get this working for any project.<br>
 1. I removed <code>NUGET_PACKAGES</code> environment variable from windows.<br>
 2. Add new variable 'MyPath' with value <code>C:\Root</code><br>
 3. Add <code>nuget.config</code> file at <code>c:\Root</code>  </p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;configuration&gt;
    &lt;config&gt;
        &lt;add key="repositoryPath" value="%MyPath%\Lib\packages" /&gt;
    &lt;/config&gt;  
&lt;/configuration&gt;
</code></pre>

<p>Doing so <code>asp.net core</code> projects restored the package to <strong>C:\Users{user-name}\ .nuget\packages</strong> that is not what i have configured.<br>
While <code>classic .net 4.6.2</code> project gives error <code>The given path format is not supported</code></p>