How do I enable NuGet Package Restore in Visual Studio?
Asked Answered
M

25

313

There's a similar post on stack but it doesn't help with my issue possibly because I am using Visual Studio 2015.

How do I get the "Enable NuGet Package Restore" option to appear in VS2015?

I chose File > New Project and created an empty ASP.NET Web Application. I'm looking for this menu option.

enter image description here

I should mention that I have looked for any pre-existing nuGet files in my project folder and there are none.

Mariellemariellen answered 12/1, 2015 at 4:54 Comment(8)
Make sure you're trying this against your Solution and not the Web project. By default the solution is not displayed when there is only one projectPepito
Yeah, that's definitely an easy mistake to make but I did make sure to check against the solution, i think it may be 2015 related. The Enable option is available in VS2013 when I follow the same steps.Mariellemariellen
Same here. I even tried deleting the .nuget folder which reactivates the Enable NuGet Package Restore option in VS 2013 but still no dice. I am trying to open an existing MVC application which was created in VS 2013.Heimlich
I came across this while searching to see if this option has been disabled in VS2015. I am glad that it is gone. We should all learn to use the new workflow (where applicable).Florineflorio
@Florineflorio It would be useful if you provided a reference to the new workflow to make your comment a bit more productive.Teacake
No point in doing this anymore. The new workflow is much nicer: blog.davidebbo.com/2014/01/…Davin
I hd not seen David Ebbo's article referenced by oligofren so I just opened the sln & csproj files in Notepad++ and deleted the sections he illustrated. I had the solution open in VS2015 and, once I saved the files, VS prompted me to reload them and my solution references are now fine and my solution compiles. Thanks so much, Vinney!Quickfreeze
This is the wrong way to do it in 2015.Hobbema
H
261

It took far too long but I finally found this document on Migrating MSBuild-Integrated solutions to Automatic Package Restore and I was able to resolve the issue using the methods described here.

  1. Remove the '.nuget' solution directory along from the solution
  2. Remove all references to nuget.targets from your .csproj or .vbproj files. Though not officially supported, the document links to a PowerShell script if you have a lot of projects which need to be cleaned up. I manually edited mine by hand so I can't give any feedback regarding my experience with it.

When editing your files by hand, here's what you'll be looking for:

Solution File (.sln)

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F4AEBB8B-A367-424E-8B14-F611C9667A85}"
ProjectSection(SolutionItems) = preProject
    .nuget\NuGet.Config = .nuget\NuGet.Config
    .nuget\NuGet.exe = .nuget\NuGet.exe
    .nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject

Project File (.csproj / .vbproj)

  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>
Heimlich answered 15/5, 2015 at 23:6 Comment(4)
I'm totally missing something here. When I use this method, I get a boatload of packages installed in every solution I have. I've got one solution with 10 packages and another solution with the exact same packages: two different directories are created each containing the 10 packages. Using this method, how do you consolidate all your packages into a single directory (like the old VS2013 method allows by editing the NuGet.Config file)?Vincevincelette
Don't see a .nuget folder? Go check out the solutions about deleting folders in the packages folder. It's possible your package half restored, and that garbage is blocking it from restoring fully.Gambol
Indeed this was the solution. Additionally to this - I've added "nuget restore" before starting to build the project. nuget packages gets auto downloaded, and project build works ok after this.Armbrecht
To save a bit of time, the script to execute from the GitHub repository mentioned by @VinneyKelly is migrateToAutomaticPackageRestore.ps1, its magic, works!Clubman
P
74

As already mentioned by Mike, there is no option 'Enable NuGet Package Restore' in VS2015. You'll have to invoke the restore process manually. A nice way - without messing with files and directories - is using the NuGet Package Management Console: Click into the 'Quick start' field (usually in the upper right corner), enter console, open the management console, and enter command:

Update-Package –reinstall

This will re-install all packages of all projects in your solution. To specify a single project, enter:

Update-Package –reinstall -ProjectName MyProject

Of course this is only necessary when the Restore button - sometimes offered by VS2015 - is not available. More useful update commands are listed and explained here: https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages

Planarian answered 17/8, 2017 at 4:21 Comment(3)
Thanks a lot, I had the similar problem. I just have solved my problem via your procedure. Thanks you very muchRepast
Same here, the only one that worked and doesn't need a bunch of things written all over the placeReceipt
Most useful answer here!Rife
V
63

Microsoft has dropped support for the 'Enable NuGet Package Restore' in VS2015 and you need to do some manual changes to either migrate old solutions or add the feature to new solutions. The new feature is described pretty well in NuGet Package Restore.

There is also a migration guide for existing projects (as previously mentioned) here: NuGet Migration Guide

When upgrading:

  1. do not delete the .nuget directory.
  2. Delete the nuget.exe and nuget.targets files.
  3. Leave the nuget.config.
  4. Purge each of the project files of any reference to the NuGet targets by hand. The Powershell script mentioned seemed to do more damage than good.

When creating a new project:

  1. In your Visual Studio 2015 solution, create a Solution Directory called .nuget.

  2. Create an actual directory of the solution directory (where the .sln file lives) and call it .nuget (note that the solution directory is not the same as the actual file system directory even though they have the same name).

  3. Create a file in the .nuget directory called nuget.config.

  4. Add the 'nuget.config' to the solution directory created in step #2.

  5. Place the following text in the nuget.config file:

    <?xml version="1.0" encoding="utf-8"?>
     <configuration>
      <config>
        <add key="repositorypath" value="$\..\..\..\..\Packages" />
      </config>
      <solution>
        <add key="disableSourceControlIntegration" value="true" />
      </solution>
    </configuration>
    

This configuration file will allow you to consolidate all your packages in a single place so you don't have 20 different copies of the same package floating around on your file system. The relative path will change depending on your solution directory architecture but it should point to a directory common to all your solutions.

You need to restart visual studio after doing step 5. Nuget won't recognize the changes until you do so.

Finally, you may have to use the 'Nuget Package Manager for Solutions' to uninstall and then re-install the packages. I don't know if this was a side-effect of the Powershell script I ran or just a method to kick NuGet back into gear. Once I did all these steps, my complicated build architecture worked flawlessly at bringing down new packages when I checked projects out of TFVC.

Vincevincelette answered 4/8, 2015 at 14:3 Comment(6)
Why delete the nuget.targets file, will I get a consistent build when that is missing?Pieeyed
The targets appear to be integrated into the IDE now, as well as the function that the 'nugget.exe' used to provide. The only thing you still need is the configuration.Vincevincelette
In addition to the steps mentioned by DRAirey, I had to do the following: 1) Instead of $\..\..\..\..\Packages, used ../../ (windows parent path convention, no $ at the start 2) Save the solution, close and reopen for the nuget.config to be read and honoured by package installPlacidia
This helped for my new VS2015 project where I comitted packages dir, and other team members couldn't rebuild because of NuGet dependencies.Scorpaenoid
You need to restart visual studio after doing step 5. Nuget won't recognize the changes until you do so.Malca
In Windows 10, for the new projects step 2, I had to create .nuget. with a period at the end. Otherwise it doesn't allow the folder to be created.Theresiatheresina
S
41

Optionally you can remove all folders from "packages" folder and select "Manage NuGet Packages for Solution...". In this case "Restore" button appears on NuGet Packages Windows.

Significs answered 26/6, 2015 at 10:47 Comment(5)
Try to close and reopen NuGet Packages Window after removing folders inside "packages" folder.Significs
+1 This worked for me, note that the restore button pops up at the top of the window, just below the tab. Says: "Some NuGet packages are missing from this solution. Click to restore from your online package sources."Dede
So simple and easy.. this worked for me.. Guess this should be more voted answer :)Sublease
So simple and easy. This should be the answer.Gamester
Worked for me. :)Ferrigno
D
24

Use this command to restore all packages

dotnet restore
Darren answered 5/12, 2018 at 5:35 Comment(1)
Run the "dotnet restore" in the "Package Manager Console".Kozlowski
H
14

If you have any problems or are missing any packages you can simply right-click in your project and select "Manage NuGet Packages for Solution...". After clicking on this a screen will open where you see a menu bar saying "Restore": Restore

Click on it and the required packages will be installed automatically.
I believe this is what you're looking for, this solved my problems.

Harvin answered 17/3, 2015 at 8:1 Comment(6)
But that only helps if that alert bar shows up, it does not in my case.Fielder
A step that manually installs a package completely misses the point of an automated restore.Vincevincelette
I believe this should probably be the accepted answer, it is the same functionalityAlarmist
I was able to see the option to restore by right clicking on the solution. It was there under "Manage NuGet packages for solution". Did the trick for me.Disqualification
Doesn't work for me - I see warnings in the solution regarding missing nuget packages, but manage nuget packages does not present me an option to download them. I also cannot build and restore. Also the restore command does nothing.Darsey
Closing the solution and re-opening it worked for me.Transmarine
K
6

When upgrading projects with nuget packages from Vx20XX to VS2015, you might have a problem with nuget packages.

Example of error message: This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.

Update 2016-02-06: I had a link to the information but it does not work anymore. I suspect that a recent path has solved the problem ???

I fixed my problem writing a little program that do MSBuild-Integrated package restore vs. Automatic Package Restore

You can download executable of the tool here.

Please let me know the result :-) !

enter image description here

Code as reference:

<Window x:Class="FixNuGetProblemsInVs2015.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:FixNuGetProblemsInVs2015"
        mc:Ignorable="d"
        Title="Fix NuGet Packages problems in Visual Studio 2015 (By Eric Ouellet)" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="10"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0">Root directory of projects</TextBlock>
        <Grid Grid.Row="0" Grid.Column="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <TextBox Grid.Column="0" Name="DirProjects"></TextBox>
            <Button Grid.Column="1" VerticalAlignment="Bottom" Name="BrowseDirProjects" Click="BrowseDirProjectsOnClick">Browse...</Button>
        </Grid>

        <!--<TextBlock Grid.Row="1" Grid.Column="0">Directory of NuGet Packages</TextBlock>
        <Grid Grid.Row="1" Grid.Column="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <TextBox Grid.Column="0" Name="DirPackages"></TextBox>
            <Button Grid.Column="1"  Name="BrowseDirPackages" Click="BrowseDirPackagesOnClick">Browse...</Button>
        </Grid>-->

        <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Name="TxtLog" IsReadOnly="True"></TextBox>

        <Button Grid.Row="3" Grid.Column="0" Click="ButtonRevertOnClick">Revert back</Button>
        <Button Grid.Row="3" Grid.Column="2" Click="ButtonFixOnClick">Fix</Button>
    </Grid>
</Window>


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;
using Application = System.Windows.Application;
using MessageBox = System.Windows.MessageBox;

/// <summary>
/// Applying recommanded modifications in section : "MSBuild-Integrated package restore vs. Automatic Package Restore"
/// of : http://docs.nuget.org/Consume/Package-Restore/Migrating-to-Automatic-Package-Restore
/// </summary>

namespace FixNuGetProblemsInVs2015
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            DirProjects.Text = @"c:\prj";
            // DirPackages.Text = @"C:\PRJ\NuGetPackages";
        }

        private void BrowseDirProjectsOnClick(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            dlg.SelectedPath = DirProjects.Text;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                DirProjects.Text = dlg.SelectedPath;
            }
        }

        //private void BrowseDirPackagesOnClick(object sender, RoutedEventArgs e)
        //{
        //  FolderBrowserDialog dlg = new FolderBrowserDialog();
        //  dlg.SelectedPath = DirPackages.Text;
        //  if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        //  {
        //      DirPackages.Text = dlg.SelectedPath;
        //  }
        //}

        // private string _dirPackages;

        private void ButtonFixOnClick(object sender, RoutedEventArgs e)
        {
            DoJob(false);
        }

        private void ButtonRevertOnClick(object sender, RoutedEventArgs e)
        {
            DoJob(true);
        }

        private void DoJob(bool revert = false)
        {
            TxtLog.Text = "";

            string dirProjects = DirProjects.Text;
            // _dirPackages = DirPackages.Text;

            if (!Directory.Exists(dirProjects))
            {
                MessageBox.Show("Projects directory does not exists: " + dirProjects);
                return;
            }

            //if (!Directory.Exists(_dirPackages))
            //{
            //  MessageBox.Show("Packages directory does not exists: " + _dirPackages);
            //  return;
            //}

            RecurseFolder(dirProjects, revert);
        }

        private void RecurseFolder(string dirProjects, bool revert = false)
        {
            if (revert)
            {
                Revert(dirProjects);
            }
            else
            {
                FixFolder(dirProjects);
            }

            foreach (string subfolder in Directory.EnumerateDirectories(dirProjects))
            {
                RecurseFolder(subfolder, revert);
            }
        }

        private const string BackupSuffix = ".fix_nuget_backup";

        private void Revert(string dirProject)
        {
            foreach (string filename in Directory.EnumerateFiles(dirProject))
            {
                if (filename.ToLower().EndsWith(BackupSuffix))
                {
                    string original = filename.Substring(0, filename.Length - BackupSuffix.Length);
                    if (File.Exists(original))
                    {
                        File.Delete(original);                                          
                    }
                    File.Move(filename, original);
                    Log("File reverted: " + filename + " ==> " + original);
                }
            }
        }

        private void FixFolder(string dirProject)
        {
            BackupFile(System.IO.Path.Combine(dirProject, "nuget.targets"));
            BackupFile(System.IO.Path.Combine(dirProject, "nuget.exe"));

            foreach (string filename in Directory.EnumerateFiles(dirProject))
            {
                if (filename.ToLower().EndsWith(".csproj"))
                {
                    FromProjectFileRemoveNugetTargets(filename);
                }
            }
        }

        private void BackupFile(string path)
        {
            if (File.Exists(path))
            {
                string backup = path + BackupSuffix;
                if (!File.Exists(backup))
                {
                    File.Move(path, backup);
                    Log("File backup: " + backup);
                }
                else
                {
                    Log("Project has already a backup: " + backup);
                }
            }
        }

        private void FromProjectFileRemoveNugetTargets(string prjFilename)
        {
            XDocument xml = XDocument.Load(prjFilename);

            List<XElement> elementsToRemove = new List<XElement>();

            foreach (XElement element in xml.Descendants())
            {
                if (element.Name.LocalName == "Import")
                {
                    var att = element.Attribute("Project");
                    if (att != null)
                    {
                        if (att.Value.Contains("NuGet.targets"))
                        {
                            elementsToRemove.Add(element);
                        }
                    }
                }

                if (element.Name.LocalName == "Target")
                {
                    var att = element.Attribute("Name");
                    if (att != null && att.Value == "EnsureNuGetPackageBuildImports")
                    {
                        elementsToRemove.Add(element);
                    }
                }
            }

            if (elementsToRemove.Count > 0)
            {
                elementsToRemove.ForEach(element => element.Remove());
                BackupFile(prjFilename);
                xml.Save(prjFilename);
                Log("Project updated: " + prjFilename);
            }
        }

        private void Log(string msg)
        {
            TxtLog.Text += msg + "\r\n";
        }

    }
}
Kaenel answered 22/10, 2015 at 18:15 Comment(2)
The program worked fine for converting a ton of projects in my solution. The latest version has a "Directory of NuGet Packages" field as well but didn't seem to affect the output. What does it do?Topless
Sorry, I have no idea. I suspect that it will depends on the content of the file. Perhaps you can track the function: "FromProjectFileRemoveNugetTargets" and see if your file could be affected? Sorry for that bad answer, I don't remember what I coded :-( ! I just know that I used twice on 2 different computer with success.Kaenel
P
5

I faced the same issue while trying to build sample project gplus-quickstart-csharp-master.

I looked closely error message and found a workaround from overcoming this error, hopefully, this will help.

  • Right click on solution file and open in windows explorer.
  • Copy .nuget folder with NuGet.Config, NuGet.exe, NuGet.targets (download link or simply copy from other project and replaced)
  • Try to rebuild solution.

Enjoy !!

Potpourri answered 7/9, 2016 at 11:51 Comment(0)
O
4

I suppose that for asp.net 4 project we're moving to automatic restore, so there is no need for this. For older projects I think a bit of work to convert is needed.

http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore

Oppression answered 12/1, 2015 at 6:53 Comment(1)
You're probably right. I just tried creating the project using the exact same steps in VS2013 and the "Enable Nuget Package Restore" was there. Thanks for the link, I'll check it out now.Mariellemariellen
G
4

Ivan Branets 's solution is essentially what fixed this for me, but some more details could be shared.

In my case, I was in VS 2015 using Auto Package restore and TFS. This is all pretty default stuff.

The problem was that when another developer tried to get a solution from TFS, some packages were not fully getting restored. (Why, that I'm not quite sure yet.) But the packages folder contained a folder for the reference and the NuGet package, but it wasn't getting expanded (say a lib folder containing a .dll was missing.) This half there, but not really quite right concept was preventing the package from being restored.

You'll recognize this because the reference will have a yellow exclamation point about not being resolved.

So, the solution of deleting the folder within packages removes the package restore blocking issue. Then you can right click at the top solution level to get the option to restore packages, and now it should work.

Gambol answered 5/11, 2015 at 15:30 Comment(0)
C
4

Go at References in visual studio and look at which packages are missing. Now right click on Solution in Visual and click on open folder in file explorer. Now open packages folder and delete missing packages folder. Open visual studio and just build the solution. all the missing packages will be restore. Please mark this as answer if I helped.

Cockatoo answered 15/5, 2016 at 11:20 Comment(0)
P
4

This approach worked for me:

  • Close VS2015
  • Open the solution temporarily in VS2013 and enable nuget package restore by right clicking on the solution (i also did a rebuild, but I suspect that is not needed).
  • Close VS2013
  • Reopen the solution in VS2015

You have now enabled nuget package restore in VS2015 as well.

Padnag answered 11/8, 2016 at 17:3 Comment(0)
O
4

Package Manager console (Visual Studio, Tools > NuGet Package Manager > Package Manager Console): Run the Update-Package -reinstall -ProjectName command where is the name of the affected project as it appears in Solution Explorer. Use Update-Package -reinstall by itself to restore all packages in the solution. See Update-Package. You can also reinstall a single package, if desired.

from https://learn.microsoft.com/en-us/nuget/quickstart/restore

Ozonosphere answered 16/10, 2017 at 10:2 Comment(0)
E
4

Close VS. Delete everything under packages folder. Reopen your solution. Right click on your project, select 'Manage nuget packages...'. You will see a yellow bar appear on top of 'Nuget Package Manager' window, asking you to restore packages. This has worked for me.

Eat answered 22/10, 2017 at 21:11 Comment(0)
S
2

In case anyone else finds this problem in Visual Studio 2017, make sure the project is opened by the .sln file and not the folder, as visual studio won't pick up the settings if it's opened by folder. This happens by default if you're using Visual Studio online services for git.

Skirr answered 18/7, 2017 at 20:56 Comment(0)
P
2

I used msbuild /t:restore.


Credit and source:

My problem was with MSBuild So I followed @Vinney Kelly's link: Migrating MSBuild-Integrated solutions to Automatic Package Restore

and...

That worked LIKE A CHARM =]

MSBuild: use the msbuild /t:restore command, which restores packages packages listed in the project file (PackageReference only). Available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017. nuget restore and dotnet restore both use this command for applicable projects.

Partite answered 27/6, 2018 at 13:46 Comment(1)
In my case /t:restore does not build the project for that I had to use /restore commandClerissa
D
2

If all else fails (or perhaps before then) you may want to check and see if NuGet is a package source. I installed VS2017, and it was NOT there by default. I thought it was kind of odd.

  1. Tools - NuGet Package Manager - Package Manager Settings
  2. Click 'Package Sources' on left nav of dialog.
  3. Use plus sign (+) to add Nuget URL: https://api.nuget.org/v3/index.json
Delisadelisle answered 31/12, 2018 at 15:33 Comment(0)
B
2

VS 2019 Version 16.4.4 Solution targeting .NET Core 3.1

After having tried almost all the solutions proposed here, I closed VS. When I reopened it, after some seconds all was back to be OK...

Bathyscaphe answered 5/2, 2020 at 15:9 Comment(0)
S
1

Could also be a result of running the program while you're trying to install the package. it's grayed out if you try to click it while the built in IIS is running in the background.

Sample answered 13/3, 2017 at 18:59 Comment(0)
M
1

For .NET Core projects, run dotnet restore or dotnet build command in NuGet Package Manager Console (which automatically runs restore)

You can run console from

Tools > NuGet Package Manager > Package Manager Console

Mutilate answered 29/11, 2018 at 8:56 Comment(0)
S
0

I had to remove packages folder close and re-open (VS2015) solution. I was not migrating and I did not have packages checked into source control. All I can say is something got messed up and this fixed it.

Sewellyn answered 4/1, 2017 at 23:48 Comment(0)
M
0

Helped me through Tools >>> Nuget Package Manager >>> General then tick option Allow Nuget to download missing package and Automatically check for missing packages during build in visual studio.

enter image description here

Maniple answered 6/7, 2018 at 17:3 Comment(2)
This will increase build time every time.Koel
If you have already installed then uncheck the options.Maniple
B
0

I am facing the same problem. I am trying to add a MVC project which was created on Visual Studio 2015 to a solution that I made on Visual Studio 2019.

There are already existing projects on Visual Studio 2019, so adding this existing project which I created on VS 2015 triggers this same error. I've tried all the answers here but it doesn't fixes the problem.

What I did is just put the .nuget folder on the solution folder. Originally the hierarchy of the folder is this:

Solution Folder (VS 2019)
  -> MVC 1 Project
  -> MVC 2 Project
  -> MVC 3 Project (Project that I am adding)
         -> .nuget folder (It contains a .nuget folder)

So the issue was fixed when I moved the .nuget folder on the solution folder itself:

    Solution Folder (VS 2019)
  -> MVC 1 Project
  -> MVC 2 Project
  -> MVC 3 Project (Project that I am adding)
  -> .nuget folder (It contains a .nuget folder)
Boggess answered 21/1, 2020 at 7:37 Comment(0)
L
0

If package restore dosn't automatically happen while building an application from visual studio or by trying to restore it from visual studio UI or from package manager console try it from command line.

Check if nuget is installed in your machine, if not, try installing it from here, or you can just download the nuget.exe and place it in root directory of your project/solution.

once done, cd to the path where the projects/solutions package.config file exists, and run the below command.

nuget.exe restore <projectname>\packages.config -PackagesDirectory .\Packages

here, -PackagesDirectory .\Packages together implies that the output of the restore will be saved in the new folder called Packages at projects root level.

for more read have a look at microsoft doc reference

Leatri answered 11/10, 2022 at 3:36 Comment(0)
E
-4

Even simpler, add a .nuget folder to your solution and the 'Restore Nuget Packages' will appear (not sure whether nuget.exe needs to be present for it to work).

Engender answered 6/12, 2015 at 23:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.