Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Nuget Packages From One Project To Another

Tags:

c#

nuget

I am using Visual Studio 2013. I am trying to add all nuget packages from another project into this project. I copied all the folders under packages from one project into this one how do I add to visual studio?

I tried using the Package Manager Console to update the nuget packages but I am not sure what to write?

I tried Update-Package -Reinstall -Solution Babysitter2 [Babysitter2]

What am I doing wrong?

This Is what my project setup looks like.

Here Is What my project looks like

like image 390
N. Sch Avatar asked Feb 09 '17 17:02

N. Sch


People also ask

How do I import a NuGet package from one project to another?

Select the Tools > NuGet Package Manager > Package Manager Console menu command. Once the console opens, check that the Default project drop-down list shows the project into which you want to install the package. If you have a single project in the solution, it is already selected.

How do I add a project to NuGet?

In Solution Explorer, right-click the project and choose Properties. In the Package tab, select Generate NuGet package on build.

Is it possible to change the location of packages for NuGet?

Open %AppData%\NuGet folder, open existing NuGet. Config file. Edit repositoryPath key and set new destination.


Video Answer


2 Answers

Simply copy existing packages.config file to your new project. Include this file into the project. Then follow to Package Manager Console and execute Update-Package -reinstall command. No need to copy packages folder and to add dll references manually.

like image 59
Ivan Gritsenko Avatar answered Sep 21 '22 19:09

Ivan Gritsenko


You can install packages on the new project based on installed packages in another project.

  1. Clique on "Tools/Nuget Package Manager/Package Manager Console" to open the "Package manager Console"
  2. On "Package Manager Console", paste the following command replacing sourceProject and TargetProject by your project names:

    Get-Package -ProjectName sourceProject   | ForEach-Object { Install-Package -Id $_.Id -Version $_.Versions -Projectname targetProject }
    
like image 35
Alvaro Pereira Avatar answered Sep 22 '22 19:09

Alvaro Pereira