Home: nuget.exe update doesn't work with project.json based projects.

Created on 13 May 2016  路  17Comments  路  Source: NuGet/Home

Tried with xproj + project.json & csproj + project.json
Gives one of the following error:
Unable to locate the packages folder. Verify all the packages are restored before running 'nuget.exe update'.
No packages.config, project or solution file specified. Use the -self switch to update NuGet.exe

On providing a packages directory explicitly with a -PackagesDirectory option, gives the following error:
Unknown option: '-PackagesDirectory'

Update NuGet.exe Bug

Most helpful comment

Most bugs seem to be assigned a milestone pretty quickly and are then taken care of. But this one has been around for more than a month now with no apparent action. This is a pretty nasty bug/problem. It is the reason that we cannot migrate to using project.json. And we really need the benefits to merging etc that that would give us.

It would be greatly appreciated if fixing this could at least be scheduled for a Milestone...

All 17 comments

@rohit21agrawal - can you please confirm if this worked in 3.3 or 3.4.4. Sounds like it didn't, but I want to be sure.

I checked with 3.4.3-rtm-0855, got the exact same behavior. I feel safe to say this has existed for quiet some time.

This also breaks badly when calling nuget.exe update MY.sln.
Only projects using packages.config have any updates applied to them. If there are no such projects you just get the message:

Scanning for projects...
No projects found with packages.config.

confirming again that nuget.exe update doesn't work on xproj

Is there a way to update nuget packages in project.json without using visual studio?

Most bugs seem to be assigned a milestone pretty quickly and are then taken care of. But this one has been around for more than a month now with no apparent action. This is a pretty nasty bug/problem. It is the reason that we cannot migrate to using project.json. And we really need the benefits to merging etc that that would give us.

It would be greatly appreciated if fixing this could at least be scheduled for a Milestone...

considering how csproj + p.j (in a UWP project) could work is great.
Making xproj work here is not something we are going to invest in, as xproj->csproj move will take major investment, and we need to focus on future.

@rrelyea
I'm not really clear on how to interpret your last comment. Are you saying that we should not expect a combination of .csproj and project.json to ever be fully supported? If so I would consider that very unfortunate. The advantages to moving dependencies out of the csproj files are huge and we really need them for our current solutions. Migrating entirely to some future project format is not likely to happen overnight for us. Nor for any other organisation with a ton of code to maintain.

@mlidbom I think what he meant is that we would work to support csproj + project.json . However, we will not invest in making this work for xproj + project.json, unless it's a very trivial fix.

Rob - correct me if I understood something wrong.

@rohit21agrawal
Ahem. I seem to have some egg on my face. Without any real thought I assumed that xproj was just a way to say (vb/cs)proj. The comments @rrelyea made makes perfect sense now that I realize that is not so. Mea culpa.

@rohit21agrawal any workaround for that? How can I update it from outside of VS?

@MistyKuu you could use floating versions in project.json (https://docs.nuget.org/consume/projectjson-dependency#floating-versions ). Every time you restore, all packages will be updated to their latest versions.

Alternatively, you can use our BuildIntegratedProjectUtility class (https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.ProjectManagement/Utility/BuildIntegratedProjectUtility.cs) to get the dependencies of your project, and use NuGet Core APIs ( http://blog.nuget.org/20130520/Play-with-packages.html) to write out updated versions to your project.json file, and do a nuget restore on your project.

In any case, if you edit your project.json files to include your updated versions, nuget restore will do the rest for you.

@rohit21agrawal floating versions are bugged https://github.com/NuGet/Home/issues/3067.
I will try the second solution, thanks

There doesn't seem to be way to get an instance of BuildIntegratedNuGetProject outside of Visual Studio.

@adamhathcock @MistyKuu I am sorry..I gave out the wrong approach (i was thinking of something else). This is what you are looking for : https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.ProjectManagement/Utility/JsonConfigUtility.cs

Thanks again for the pointer, @rohit21agrawal

The link above http://blog.nuget.org/20130520/Play-with-packages.html is for the old api. Is there a good example of something just taking a Nuget Feed URL and package info then returning if there's a new package or even just any data about a package from a feed?

I tried inspecting the RestoreCommand area but there's a lot going on.

any eta on this one?

as the PackageReference tooling is now RTM, closing this as won't fix since it only applies to project.json.

Was this page helpful?
0 / 5 - 0 ratings