How to upgrade nuget packages if the installed version is missing? - servicestack

Running into a situation where I deployed an application to production a few months ago and now I need to do some work on it, on an entirely new machine. The first I do is pull source and nuget restore won't restore because it can't find the particular version of the package it was developed under. When I check nuget.org for this package version it is not there. So how do I upgrade my solution to the latest binaries?
Visual Studio 2013 trying to update ServiceStack '4.0.39' to latest, which is '4.0.40' at the time of this post.
Thank you,
Stephen

The best solution I've come up with for this is to manually edit the Packages.config file(s) and set the version number to whatever you want. Restore should then work. It's not a perfect solution but it has dug me out of some holes.

(I know this is an old answer, but it just came up in some Googling)
One issue with the accepted answer (of just updating the version # in packages.config) is that this is just triggering a "package restore"--and will skip any "installation steps" the package might have (things that were done automatically when you first added the package, such as adding assembly references, modifying config files, etc.).
An alternative way would be to edit the packages.config and REMOVE the package in question from there---then start up VS and add the new version. This will trigger the package's usual install routine to do it's thing.

I recommend you to use the NuGet Package Manager Console of Visual Studio:
TOOLS > NuGet Package Manager > Package Manager Console
Command to update a NuGet package to the latest version:
Update-Package ServiceStack
Command to update a NuGet package to a specific version:
Update-Package ServiceStack -version 4.0.40

Related

Azure DevOps Build Solution using wrong version of package

I've got a 'Build Solution' step for a ASP.NET project in Azure DevOps and it's failing because it's trying to use an old version of a package. In my code it's only referenced in the packages.config and I've changed that entry to use version 1.0.7, but in Azure DevOps it's still trying to find 1.0.2 but fails to find it. Any ideas why it's trying to use the wrong package version or how to force it to get the new one? My project in visual studio has no references to the old version.
There were references in the .csproj file that were trying to access the old file path, and that version of the package did not exist at that path. So I took the bad path out and it fixed the issue
Probably one of your NuGet packages requires version 1.0.2 of the package. To figure out which one, delete the local version 1.0.2 and build the solution locally. Then take a look at the build output and see which package is missing that version. Maybe take a look here:
Increase Build Log Verbosity to Get More Details About a Build Problem

Package Manager for VS2012 does not display packages in local feed

I've created a simple package, only consisting of a couple of binaries in the
tools folder. The package is created with NuGet version 4.4.1.4656.
A local folder has been initialized with nuget init and contains said package. VS2017 Package Manager shows the package as expected, whereas VS2012 does not.
There are no available updates for the Package Manager in VS2012, which is at version 2.8.60318.667.
How do I get the feed to work with VS2012, so I can install the package in one of our older solutions? Is this a compatibilty issue?
Any pointers are welcome!

Nuget manager not visible

I am getting following error once i run the project in visual studio 2012.
Warning 1 Some NuGet packages were installed using a target framework
different from the current target framework and may need to be
reinstalled. Visit
http://docs.nuget.org/docs/workflows/reinstalling-packages for more
information. Packages affected: Microsoft.Web.Infrastructure,
SignalR.Hosting.AspNet, SignalR.Server
Reinstalling packages seem pretty straightforward. But, it can get very tricky since the following may affect or be affected by it:
Project retargeting or project upgrade where the target framework of the project gets changed Package dependencies and their versionsDependent packages and their versions.
I suggest you should read this document.
https://docs.nuget.org/consume/reinstalling-packages
read When to Reinstall Packages and What to Watch for section.

NuGet; unable to get package as wrong version reported in Visual Studio 2012

I'm trying to build a solution but I get this error,
he 'Microsoft.Bcl.Build 1.0.14' package requires NuGet client version '2.8.1' or above, but the current NuGet version is '2.6.40619.9041'.
I've just upgraded NuGet package manager in Tools/"Extensions and Updates" which reports the version as 2.8.50313.31.
I've restarted VS2012, restarted the computer, cleaned the project and rebuilt, but I still can't get Visual Studio to recognise the new version and hence can't compile.
Thanks
Run Console (cmd) as Administrator
Locate your .nuget folder that contains the NuGet.exe file (you may check error message to locate the path)
execute this command NuGet.exe update -self
Took me all day to find that NuGet was bound to the individual project.
I had to use the package manager console and run
Install-Package Microsoft.Bcl.Build -Version 1.0.14
to get it to work manually.
Edit (5/11/2014). The problem is actually that Nuget gets bundled with the solution and it is this that needs upgrading. I did this by finding the directory in the project with the nuget.exe file in it (.nuget for me, YMMV) going to that directory and running nuget update -self. If you go with the original solution, you have to do this manually for each package. HTH.
This worked for me in VS 2017 Enterprise-
Right click your solution and go to "Manage NuGet Packages for Solution..."
In the window that opens up, click the gear icon at the top right corner.
Select "General" and click the "Clear Clear All NuGet Cache(s)" button. This will run for a few seconds depending on the size of your
cache.
Clean and rebuild your solution.

NuGet Package restore failed for project myProjectWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'

It's a provider hosted project. It used to work until very recently.
If I create a completely new project/solution, then it works.
If I start the old one, or redownload it from source control, I get the following error:
NuGet Package restore failed for project LocalTheaterWeb: Unable to find version '3.0.1' of package 'AppForSharePoint16WebToolkit'
I tried Update-Package -Reinstall but the problem stays.
Any ideas?
The solution of Scott Hillier did it for me:
http://www.shillier.com/archive/2014/08/05/nuget-package-restore-fails-for-sharepoint-2013-provider-hosted-apps.aspx
I often take advantage of the NuGet Package Restore capability to
reduce the size of my projects when saving or sharing them. Today, I
discovered an issue with this process when building SharePoint 2013
Provider-Hosted Apps against SharePoint Online. Here are the steps to
reproduce and the fix:
Create a Provider-Hosted App in Visual Studio 2013 using a SharePoint Online site for debugging.
Right click solution and "Enable NuGet Package Restore"
Save and Close Project
Delete the “packages” folder from project directory
Open Project in Visual Studio 2013
Rebuild, receive error “Unable to find AppForSharePoint16WebToolkit”
Open Packages.config file
Change “AppForSharePoint16WebToolkit” to “AppForSharePointWebToolkit”
Rebuild – successfully this time. Apparently, the "AppForSharePoint16WebToolkit" package is not available through the
NuGet Package Manager, but the older "AppForSharePointWebToolkit"
package is available.
The error message suggests that NuGet cannot find the AppForSharePoint16WebToolkit package in your package sources. So check the following:
The correct package source is selected whilst doing the Update-Package -Reinstall.
Check the package source that hosts the NuGet package is enabled. If you are using a recent version of NuGet the package restore should use all the enabled package sources.
See if the solution or project has its own NuGet.config which is overriding the package sources.
Without further information my guess is 3. since you say it works for a new project.
You can also run Fiddler to see what package sources NuGet is using as it tries to restore.
For older "locked down" projects with specific package version numbers that you can't update, un-check "Automatically check for missing packages during build in Visual Studio" which is found via:
Nuget Package Manager > Package Manager Settings
This means that if you toggle between newer projects and older projects you need to check and un-check this setting

Resources