Ghasan غسان
Ghasan غسان

Reputation: 5857

NuGet does not recognize $(SolutionDir) variable at solution root folder

I have been using a central packages folder for a quite time now (using %AppData%/NuGet/NuGet.config), but for some requirements I need to use solution-level packages repository now for a certain solution.

For this I created this NuGet.config and placed it at the solution root.

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />

    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
  </packageRestore>

  <config>
    <add key="repositoryPath" value="$(Solutiondir)\Packages" />
  </config>

  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>

</configuration>

However, the funny thing is that a folder named $(Solutiondir) is created which contains the Packages folder where the packages are stored.

What am I doing wrong here?

Upvotes: 0

Views: 1120

Answers (1)

Matt Ward
Matt Ward

Reputation: 47937

This is not supported by NuGet. The path is either a full directory path or a path relative to the NuGet.Config file itself.

You can get the desired behaviour by having a NuGet.Config file for each solution either in its .nuget directory or the solution directory. Then specify the directory relative to the NuGet.Config file.

Upvotes: 2

Related Questions