Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 569
ryudice Avatar asked Apr 22 '26 04:04

ryudice


1 Answers

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.

like image 115
Matt Ward Avatar answered Apr 25 '26 11:04

Matt Ward