ryudice
ryudice

Reputation: 37366

Specify a directory as package source

I'm trying to add the .nuget directory as a package source, because we dont have a remote feed and we just had the need for one. I'm modifying the Nuget.targets file like this:

<ItemGroup Condition=" '$(PackageSources)' == '' ">
    <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
    <!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
    <!--   -->
    <PackageSource Include="https://nuget.org/api/v2/" />
    <PackageSource Include="../.nuget" />

  </ItemGroup>

However I get a message when building the project that says "Invalid URI cannot determine the format".

Is there a way to add a local folder for packages restore?

Upvotes: 3

Views: 1255

Answers (1)

Matt Ward
Matt Ward

Reputation: 47937

NuGet must be using the Uri class to get the path. Try the following instead:

    <PackageSource Include="$(SolutionDir).nuget"/>

$(SolutionDir) will expand to the full path of the solution directory followed by a forward slash and this seems to work with package restore.

Upvotes: 3

Related Questions