I have used NuGet Package Package Manager for some years now. And following are all the problems it presented to me in my projects & their solutions when used in Visual Studio
- Package manager console is your friend. It will solve a lot of problems that NuGet package manager UI will give up on. Having problems uninstalling a package that is also a dependency of another NuGet package & UI won't cut it for you, No problems just run below command on package manager console.
uninstall-package newtonsoft.json -force
- Another note about package version mismatches: If you are installing a package X that depends on package Y, Installing X will install Y too with the specific version of Y it needs for X. Then if you install package Z that also depends on Y, package Y's version will get overwritten with version that Z needs for it. Understanding this process can help resolve most version conflicts between NuGet packages.
- I used Nlog package and faced issues issues with Nlog NuGet package not installing the correct dependent dll packages like Commons.Logging or Commons.Logging.Nlog[Any version number]. Quick way to solve all dependency problems with NuGet package is to install the highest dependency which will automatically install the correct versions of all dependent NuGet packages. As explained here.
- Getting a version conflict or mismatch errors. No worries use below command to install the specific version you are looking for to resolve the conflict.
install-package newtonsoft.json -version "5.0.6"
- if a package's dll is missing you will usually get errors like "cannot find dll vx.0...". Use below command to get the dll back into your project.
Update-Package –reinstall Newtonsoft.Json.
- If getting an error stating "nuget exited with code 1"
- Remove the .nuget folder from the solution in Visual Studio
- Delete the .nuget folder from disk (keep Visual Studio open)
- Right-click on the solution in the Visual Studio solution explorer and re-enable NuGet package restore
- if your application can't find a NuGet package's correct version make sure in app.config the following entry for the package has the correct version.
<bindingredirect newversion="3.2.0.0" oldversion="0.0.0.0-3.2.0.0"> </bindingredirect></div>
- Last one, simple but annoying, Just published a NuGet package & can't find the correct version in the UI when installing it. Sometimes the UI will show two different entries for same NuGet package with different versions.
No comments:
Post a Comment