We are developing multiple solutions in Visual Studio 2015. The solutions share some core projects that need nuget packages. The nuget references cannot be resolved when the nuget package is added from one solution and is later opened by another solution.
The folder structure is as follows:
When I install a nuget package to SharedProject1
when SolutionA
is opened, the dll reference shows the path to the packages folder A
. When SolutionB
is opened in another computer, SharedProject1
has a reference error since the packages folder A
doesn't exist.
I have read this solution: Setting up a common nuget packages folder for all solutions when some projects are included in multiple solutions but this doesn't solve the problem since the repositoryPath
key in the .nuget/NuGet.config file is not applied with Visual Studio 2015
and Nuget 3.4.3
Simply copy existing packages. config file to your new project. Include this file into the project. Then follow to Package Manager Console and execute Update-Package -reinstall command.
Set up Visual StudioIn Visual Studio, select Tools, and then select Options. Select NuGet Package Manager, and then select Package Sources. Enter the feed's Name and Source URL, and then select the green (+) sign to add a new package source. If you enabled upstream sources in your feed, clear the nuget.org checkbox.
To resolve the issue, we put a NuGet.config file into the Codebase
directory then deleted all the other Nuget.config files and .nuget folders in the solutions. Since NuGet configurations are propagated to sub folders, the settings in the single NuGet.config file are applied into all the solutions.
Inside the Nuget.config file we put the packageSource
, repositoryPath
settings.
Example NuGet.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<config>
<add key="repositoryPath" value="./SharedPackages" />
</config>
</configuration>
Existing nuget packages need to be uninstalled and reinstalled since the dll references in .csproj files will still show the old packages
folder. Or you can manually edit the .csproj files.
Resulting folder structure:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With