I'm installing the AvsAn
(2.1.0) package using the Nuget Package manager. I am expecting the reference path to be to the packages directory, something like:
C:\app\packages\AvsAn.dll
But a reference to the bin directory is added:
C:\app\NameSpace\bin\AvsAn.dll
Confusingly this is happening for some packages but not for others (i.e the reference path is to the packages folder, as expected)
NuGet creates a subfolder for each package identifier, then creates subfolders for each installed version of the package. NuGet installs package dependencies as required. This process might update package versions in the process, as described in Dependency Resolution.
The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).
PackageReference (or "package references in project files") | (NuGet 4.0+) Maintains a list of a project's top-level dependencies directly within the project file, so no separate file is needed.
We found that different projects within the same solution were using different versions from one another. Additionally, a single project might have a version listed in the <Reference>
element from the version listed in the HintPath
.
We simply went through each .csproj file and manually edited them to get everything in sync.
<Reference
that includes the information for the dll in question.<Reference Include="SomeAssembly, Version=4.0.54">
. There may be some additional text after this such as Culture
and/or PublicKey
, etc. We're just interested in the Version attribute.
<HintPath>
element within <Reference
, it will contain the path to that dll that VS will expect (where VS will look first)...\packages\SomePackage.4.0.56\lib\net45\SomeAssembly.dll
(for example - in our case it was Service Stack packages). While this isn't technically a version (it's just a path to a file on your system), it will typically correspond to the version of the dll. In our case we were moving from ServiceStack 4.0.54 to 4.0.56. Some of the Include
references were to 4.0.56 while the path still pointed to the 4.0.54 version. Because the hint path did not point to the expected dll VS looked elsewhere and it found what it believed to be an acceptable match in the project's \bin\debug
directory. This was not the correct version.
It will be up to your specific situation as to which to change and to what.
This was most likely caused by poor merges.
Additionally we cleared out the \bin
and \packages
directories underneath the project folder. Reloaded solution and let Nuget restore. This is just to clear things out so that Nuget can pull down just the packages, and their versions, that it needs. And it prevents VS from using wrong versions that may be located in the project's \bin
directory. Both are safe to delete. The \packages
folder will be recreated and populated via Nuget restor, and the \bin
directory will be recreated and populated upon the next build of the solution.
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