After my last posts about Nuget packaging I wanted to share another useful experience with Nuget.
You can create a local repository to store all the packages you need and not to download those every time.
You can create a local repository to store all the packages you need and not to download those every time.
- To do this I have created a folder C:\NugetConfig\Repo and I have copied there the Newtonsoft.Json.4.5.10.nupkg package file
- To make the both solutions use this local repository all I have to do is to change the following settings in the NuGet.targets file:
<ItemGroup Condition=" '$(PackageSources)' == '' "> <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> <!-- <PackageSource Include="https://nuget.org/api/v2/" /> <PackageSource Include="https://my-nuget-source/nuget/" /> --> </ItemGroup>
and adding s new PackageSource location<ItemGroup Condition=" '$(PackageSources)' == '' "> <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> <!-- <PackageSource Include="https://nuget.org/api/v2/" /> <PackageSource Include="https://my-nuget-source/nuget/" /> --> <PackageSource Include="C:\NugetConfig\Repo" /> </ItemGroup>
And that's it. This will make the solution search for the used packages in the given folder and you will get а meaningful error if the package could not be found. - Furthermore you can add you local repository to the visual studio package sources so that you will be able to search and add packages from it to any new solution:
No comments:
Post a Comment