Restoring NuGet packages to the latest version










1















In the project I've been using some custom NuGet sources. Apparently some of them are no longer available but I do have the newer (and only newer) versions of the packages on the other (still working) server. Is there a way to restore the packages directly to the newest versions without manually replacing all the references in the .csproj and packages.config files?



I've tried running Updade-Package -Reinstall but I only get the following error message:



Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.










share|improve this question


























    1















    In the project I've been using some custom NuGet sources. Apparently some of them are no longer available but I do have the newer (and only newer) versions of the packages on the other (still working) server. Is there a way to restore the packages directly to the newest versions without manually replacing all the references in the .csproj and packages.config files?



    I've tried running Updade-Package -Reinstall but I only get the following error message:



    Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.










    share|improve this question
























      1












      1








      1


      1






      In the project I've been using some custom NuGet sources. Apparently some of them are no longer available but I do have the newer (and only newer) versions of the packages on the other (still working) server. Is there a way to restore the packages directly to the newest versions without manually replacing all the references in the .csproj and packages.config files?



      I've tried running Updade-Package -Reinstall but I only get the following error message:



      Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.










      share|improve this question














      In the project I've been using some custom NuGet sources. Apparently some of them are no longer available but I do have the newer (and only newer) versions of the packages on the other (still working) server. Is there a way to restore the packages directly to the newest versions without manually replacing all the references in the .csproj and packages.config files?



      I've tried running Updade-Package -Reinstall but I only get the following error message:



      Some NuGet packages are missing from the solution. The packages need to be restored in order to build the dependency graph. Restore the packages before performing any operations.







      nuget nuget-package nuget-package-restore






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 2 '18 at 7:49









      DoroDoro

      508517




      508517






















          1 Answer
          1






          active

          oldest

          votes


















          0














          If some packages you use (and still want to use) are no longer available, I suggest you to make a backup of them.



          Find the Nuget cache on your server. On Windows this is located at




          %userprofile%.nugetpackages




          Spot the packages (and version) you want to backup and copy the .nupkg files in their respective folders.



          Then you have two choices:



          1. Create a private Nuget feed


          2. Create a local Nuget feed on your development machine

          The 1st option has the advantage to be a single source that can be used on any machine you want (development machine, build server...etc) but you will have more set-up, especially for the authentication/authorization (because it's a private feed)



          For the 2nd option: Simply create a C:/Nuget folder and put any .nupkg you want.
          Then in Visual Studio go to:




          Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources




          Click on the green + button to add a new source, simply give it the name Local and browse to your C:/Nuget to set the source.



          From now on when you want to restore your Nuget packages, Visual Studio will first look into the nuget.org feed and if it doesn't find the referenced packages, will then look into your Local feed and cache the installed package to the %userprofile%.nugetpackages of your machine.



          I hope that answer to your question, I was not quite sure about what you asked and your knowledge about Nuget.



          UPDATE:



          I think I understand your question better now.



          First of all, I think your misunderstand the Update-Package -Reinstall command. It will reinstall the packages with the SAME version as already referenced but simply reinstalling them. It's a useful command for example when you change the target framework of your project. Then you can reinstall the same versions of the packages and they will retarget this .NET Framework version.



          So if a nuget restore isn't working then Update-Package -Reinstall will obviously fail too.



          With Nuget, when something isn't working, you shouldn't insist but instead, find the tweak that will make it working again. I can't count how many times I went to the different caches to delete some cached packages.



          I think you should try to use nuget restore and see what packages are causing issues, then uninstall these packages (this will just remove the reference from the .csproj and packages.config if they aren't installed in the project yet), then you can finally install the newest version of these packages.






          share|improve this answer

























          • It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

            – Doro
            Oct 15 '18 at 11:35











          • @Doro I didn't have enough characters in a simple comment so I edited my answer.

            – Jérôme MEVEL
            Oct 16 '18 at 2:03











          • @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

            – Jérôme MEVEL
            Nov 1 '18 at 1:19







          • 1





            that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

            – Doro
            Nov 2 '18 at 9:18











          • @Doro I totally agree with you

            – Jérôme MEVEL
            Nov 3 '18 at 10:11










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52604035%2frestoring-nuget-packages-to-the-latest-version%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          If some packages you use (and still want to use) are no longer available, I suggest you to make a backup of them.



          Find the Nuget cache on your server. On Windows this is located at




          %userprofile%.nugetpackages




          Spot the packages (and version) you want to backup and copy the .nupkg files in their respective folders.



          Then you have two choices:



          1. Create a private Nuget feed


          2. Create a local Nuget feed on your development machine

          The 1st option has the advantage to be a single source that can be used on any machine you want (development machine, build server...etc) but you will have more set-up, especially for the authentication/authorization (because it's a private feed)



          For the 2nd option: Simply create a C:/Nuget folder and put any .nupkg you want.
          Then in Visual Studio go to:




          Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources




          Click on the green + button to add a new source, simply give it the name Local and browse to your C:/Nuget to set the source.



          From now on when you want to restore your Nuget packages, Visual Studio will first look into the nuget.org feed and if it doesn't find the referenced packages, will then look into your Local feed and cache the installed package to the %userprofile%.nugetpackages of your machine.



          I hope that answer to your question, I was not quite sure about what you asked and your knowledge about Nuget.



          UPDATE:



          I think I understand your question better now.



          First of all, I think your misunderstand the Update-Package -Reinstall command. It will reinstall the packages with the SAME version as already referenced but simply reinstalling them. It's a useful command for example when you change the target framework of your project. Then you can reinstall the same versions of the packages and they will retarget this .NET Framework version.



          So if a nuget restore isn't working then Update-Package -Reinstall will obviously fail too.



          With Nuget, when something isn't working, you shouldn't insist but instead, find the tweak that will make it working again. I can't count how many times I went to the different caches to delete some cached packages.



          I think you should try to use nuget restore and see what packages are causing issues, then uninstall these packages (this will just remove the reference from the .csproj and packages.config if they aren't installed in the project yet), then you can finally install the newest version of these packages.






          share|improve this answer

























          • It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

            – Doro
            Oct 15 '18 at 11:35











          • @Doro I didn't have enough characters in a simple comment so I edited my answer.

            – Jérôme MEVEL
            Oct 16 '18 at 2:03











          • @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

            – Jérôme MEVEL
            Nov 1 '18 at 1:19







          • 1





            that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

            – Doro
            Nov 2 '18 at 9:18











          • @Doro I totally agree with you

            – Jérôme MEVEL
            Nov 3 '18 at 10:11















          0














          If some packages you use (and still want to use) are no longer available, I suggest you to make a backup of them.



          Find the Nuget cache on your server. On Windows this is located at




          %userprofile%.nugetpackages




          Spot the packages (and version) you want to backup and copy the .nupkg files in their respective folders.



          Then you have two choices:



          1. Create a private Nuget feed


          2. Create a local Nuget feed on your development machine

          The 1st option has the advantage to be a single source that can be used on any machine you want (development machine, build server...etc) but you will have more set-up, especially for the authentication/authorization (because it's a private feed)



          For the 2nd option: Simply create a C:/Nuget folder and put any .nupkg you want.
          Then in Visual Studio go to:




          Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources




          Click on the green + button to add a new source, simply give it the name Local and browse to your C:/Nuget to set the source.



          From now on when you want to restore your Nuget packages, Visual Studio will first look into the nuget.org feed and if it doesn't find the referenced packages, will then look into your Local feed and cache the installed package to the %userprofile%.nugetpackages of your machine.



          I hope that answer to your question, I was not quite sure about what you asked and your knowledge about Nuget.



          UPDATE:



          I think I understand your question better now.



          First of all, I think your misunderstand the Update-Package -Reinstall command. It will reinstall the packages with the SAME version as already referenced but simply reinstalling them. It's a useful command for example when you change the target framework of your project. Then you can reinstall the same versions of the packages and they will retarget this .NET Framework version.



          So if a nuget restore isn't working then Update-Package -Reinstall will obviously fail too.



          With Nuget, when something isn't working, you shouldn't insist but instead, find the tweak that will make it working again. I can't count how many times I went to the different caches to delete some cached packages.



          I think you should try to use nuget restore and see what packages are causing issues, then uninstall these packages (this will just remove the reference from the .csproj and packages.config if they aren't installed in the project yet), then you can finally install the newest version of these packages.






          share|improve this answer

























          • It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

            – Doro
            Oct 15 '18 at 11:35











          • @Doro I didn't have enough characters in a simple comment so I edited my answer.

            – Jérôme MEVEL
            Oct 16 '18 at 2:03











          • @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

            – Jérôme MEVEL
            Nov 1 '18 at 1:19







          • 1





            that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

            – Doro
            Nov 2 '18 at 9:18











          • @Doro I totally agree with you

            – Jérôme MEVEL
            Nov 3 '18 at 10:11













          0












          0








          0







          If some packages you use (and still want to use) are no longer available, I suggest you to make a backup of them.



          Find the Nuget cache on your server. On Windows this is located at




          %userprofile%.nugetpackages




          Spot the packages (and version) you want to backup and copy the .nupkg files in their respective folders.



          Then you have two choices:



          1. Create a private Nuget feed


          2. Create a local Nuget feed on your development machine

          The 1st option has the advantage to be a single source that can be used on any machine you want (development machine, build server...etc) but you will have more set-up, especially for the authentication/authorization (because it's a private feed)



          For the 2nd option: Simply create a C:/Nuget folder and put any .nupkg you want.
          Then in Visual Studio go to:




          Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources




          Click on the green + button to add a new source, simply give it the name Local and browse to your C:/Nuget to set the source.



          From now on when you want to restore your Nuget packages, Visual Studio will first look into the nuget.org feed and if it doesn't find the referenced packages, will then look into your Local feed and cache the installed package to the %userprofile%.nugetpackages of your machine.



          I hope that answer to your question, I was not quite sure about what you asked and your knowledge about Nuget.



          UPDATE:



          I think I understand your question better now.



          First of all, I think your misunderstand the Update-Package -Reinstall command. It will reinstall the packages with the SAME version as already referenced but simply reinstalling them. It's a useful command for example when you change the target framework of your project. Then you can reinstall the same versions of the packages and they will retarget this .NET Framework version.



          So if a nuget restore isn't working then Update-Package -Reinstall will obviously fail too.



          With Nuget, when something isn't working, you shouldn't insist but instead, find the tweak that will make it working again. I can't count how many times I went to the different caches to delete some cached packages.



          I think you should try to use nuget restore and see what packages are causing issues, then uninstall these packages (this will just remove the reference from the .csproj and packages.config if they aren't installed in the project yet), then you can finally install the newest version of these packages.






          share|improve this answer















          If some packages you use (and still want to use) are no longer available, I suggest you to make a backup of them.



          Find the Nuget cache on your server. On Windows this is located at




          %userprofile%.nugetpackages




          Spot the packages (and version) you want to backup and copy the .nupkg files in their respective folders.



          Then you have two choices:



          1. Create a private Nuget feed


          2. Create a local Nuget feed on your development machine

          The 1st option has the advantage to be a single source that can be used on any machine you want (development machine, build server...etc) but you will have more set-up, especially for the authentication/authorization (because it's a private feed)



          For the 2nd option: Simply create a C:/Nuget folder and put any .nupkg you want.
          Then in Visual Studio go to:




          Tools -> Nuget Package Manager -> Package Manager Settings -> Package Sources




          Click on the green + button to add a new source, simply give it the name Local and browse to your C:/Nuget to set the source.



          From now on when you want to restore your Nuget packages, Visual Studio will first look into the nuget.org feed and if it doesn't find the referenced packages, will then look into your Local feed and cache the installed package to the %userprofile%.nugetpackages of your machine.



          I hope that answer to your question, I was not quite sure about what you asked and your knowledge about Nuget.



          UPDATE:



          I think I understand your question better now.



          First of all, I think your misunderstand the Update-Package -Reinstall command. It will reinstall the packages with the SAME version as already referenced but simply reinstalling them. It's a useful command for example when you change the target framework of your project. Then you can reinstall the same versions of the packages and they will retarget this .NET Framework version.



          So if a nuget restore isn't working then Update-Package -Reinstall will obviously fail too.



          With Nuget, when something isn't working, you shouldn't insist but instead, find the tweak that will make it working again. I can't count how many times I went to the different caches to delete some cached packages.



          I think you should try to use nuget restore and see what packages are causing issues, then uninstall these packages (this will just remove the reference from the .csproj and packages.config if they aren't installed in the project yet), then you can finally install the newest version of these packages.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 1:38

























          answered Oct 12 '18 at 2:15









          Jérôme MEVELJérôme MEVEL

          1,5151838




          1,5151838












          • It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

            – Doro
            Oct 15 '18 at 11:35











          • @Doro I didn't have enough characters in a simple comment so I edited my answer.

            – Jérôme MEVEL
            Oct 16 '18 at 2:03











          • @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

            – Jérôme MEVEL
            Nov 1 '18 at 1:19







          • 1





            that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

            – Doro
            Nov 2 '18 at 9:18











          • @Doro I totally agree with you

            – Jérôme MEVEL
            Nov 3 '18 at 10:11

















          • It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

            – Doro
            Oct 15 '18 at 11:35











          • @Doro I didn't have enough characters in a simple comment so I edited my answer.

            – Jérôme MEVEL
            Oct 16 '18 at 2:03











          • @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

            – Jérôme MEVEL
            Nov 1 '18 at 1:19







          • 1





            that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

            – Doro
            Nov 2 '18 at 9:18











          • @Doro I totally agree with you

            – Jérôme MEVEL
            Nov 3 '18 at 10:11
















          It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

          – Doro
          Oct 15 '18 at 11:35





          It actually ended up with the option 2. I had to ask other employees to copy me all the packages they have in their /packages folder and then I could recreate the state using the local nuget feed. It still required me to use the packages to which I shouldn't have any access. The question still remains: is there a way to upgrade packages without downloading the currently specified versions of them?

          – Doro
          Oct 15 '18 at 11:35













          @Doro I didn't have enough characters in a simple comment so I edited my answer.

          – Jérôme MEVEL
          Oct 16 '18 at 2:03





          @Doro I didn't have enough characters in a simple comment so I edited my answer.

          – Jérôme MEVEL
          Oct 16 '18 at 2:03













          @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

          – Jérôme MEVEL
          Nov 1 '18 at 1:19






          @Doro just for information, yesterday I cloned one of our project that was referencing a Nuget package I actually renamed long time ago and deleted the old package from our Nuget feed. But the Nuget CLI was giving me a restore error when I was trying Package-Uninstall. The only way was to delete the reference from the .csproj and the packages.json files. That's a bit dumb behavior from Nuget IMO, the CLI could just delete the reference and that's it instead of returning an error but maybe there is a reason for that...

          – Jérôme MEVEL
          Nov 1 '18 at 1:19





          1




          1





          that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

          – Doro
          Nov 2 '18 at 9:18





          that's why I've asked this question :) there's no option to delete/update packages without restoring the versions which are specified in packages.json or .csproj. That's kinda weird. My colleges fortunately had those old packages locally so all I had to do was to copy their files to my coputer and attach local nuget repository. Worked like a charm but still - that's not what I expected from such a huge and old packages manager.

          – Doro
          Nov 2 '18 at 9:18













          @Doro I totally agree with you

          – Jérôme MEVEL
          Nov 3 '18 at 10:11





          @Doro I totally agree with you

          – Jérôme MEVEL
          Nov 3 '18 at 10:11

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52604035%2frestoring-nuget-packages-to-the-latest-version%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo