Add existing project in a solution - cause reference namespace error - entity-framework

I just create a new project. And then add an existing project in that new project.
The problem is after finish to add that existing project. All the reference are missing error.
Just to know. The existing project i added, was already added in another project and use the "restore nuget package"
The following error appear :
"Some NuGet packages are missing from this solution. Click to restore from your online package sources"
But after try to restore the package i get the new following message :
"All packages are already installed and there is nothing to restore."
Both use the same Framework version - 4.5.2

I finally find the solution. It's was because i open the solution with VS 2015 but the project i added was created with Visual Studio 2013 , i think nuget package have some bug for restore package from VS 2013 to VS 2015
First open my solution with (Visual Studio 2013),software that I created the referenced project
Click on the option "Restore the nuget package" from the solution
Re-open the solution on Visual Studio 2015 and then enjoy ^^

Related

VS Code cant find references to some Unity Classes

So, i just upgraded my Visual Studio Code Package from 1.2.3 to 1.2.4 and then it cant find the references to Cinemachine, UI and TextMeshPro anymore. With any other code editor it works well, even with Visual Studio 2019.I'm using Unity 2021.1.3f, and i cant find were to downgrade the version of the VS Code package.
Use the Unity Package Manager window (in Unity’s top menu: Window > Package Manager) to view which packages are available for installation or already installed in your project. In addition, you can use this window to install, remove, or update packages for each project.
Ok, so i found a solution, but its kinda weird and i hope they fix it by the next unity update.
for Unity 2021.1.3f1
First you need to create another Unity project. The VS Code package already come in the 1.2.3 version from default.
Close Unity after the project is created.
After that you need to copy the "Assets" folder and the "Project Settings" folder to your new project. Unfortunatly you have to manually install any package that you project depends on manually (Because i dont know how to copy/paste any package from one project to another) and after that dont update the VS Code package again.
I higly recomend creating a copy of your project (or having it in a git repository) before updating any package because Unity dont let you downgrade packages anymore.

How to enable nugets package restore in Visual Studio 2015?

How do I enable the nuget package restore feature in Visual Studio 2015?
The feature is just missing in my context menu (Yes - I've double checked that I try it on the solution instead of a project)
My only project is a .NET 4.5 console application - there is no .nuget folder yet. There is an actual nuget package installed.
I had the same problem as you and the way I solved it was to delete the packages folder from my solution and also bin and obj folders from every project in the solution and give it a rebuild.
As it turns out, the real solution is to migrate to Automatic Package Restore. We experienced issues with NuGet after upgrading to VS 2015 after working in 2013 for a while. Turns out the old way of doing NuGet completely hoses the new way of doing it.
The solution is simple, though tedious. Apparently the NuGet.targets file signals VS to use the old NuGet way of doing things, and it's absence means that you are now using "Automatic Package Restore". You can migrate to Automatic Package Restore by following these steps:
Delete .nuget/NuGet.exe
Delete .nuget/NuGet.targets
For each project:
Unload the project
Right click -> Edit the project
Delete all references to the NuGet.targets file, i.e. the following:
<RestorePackages>true</RestorePackages>
...
<Import Project="$(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>
There is also a powershell script that will perform the migration for you, if you are feeling bold. You can find it on github.
For others this option is available in the Nuget settings section in Visual Studio Options
I had problem with restoring package with error 401 unauthorised. I found the solution by unchecking available local package sources.
Debug > Options > NuGet Package Manager > Package Sources
Only allow nuget.org packages
My Visual Studio 2015 Professional was installed using the default settings. The options for "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" were already checked by default, but I still could not download the packages. I was getting an error that a package version could not be found.
I needed to click a checkbox under Tools > Options > NuGet Package Manager > Package Sources to enable NuGet Package Restore to work as expected.
I had a problem with accessing the packages folder after starting Visual Studio 2015 in Administrator mode, so I deleted it with the intention of performing a restore.
But no restore was performed when rebuilding the solution, and there was no Restore Packages to be found at the solution level or in the Nuget window.
However, if you right-click the References nodes on the projects in the solution, there is a Restore Packages option. Running this on all projects fixed it for me.
enter image description here
Well it is pretty simple with VS2015, all i had to do was to right click on my project solution and click on restore nuget.

NuGet Source Control Integration

I checked out my project using git and saw the assembles I installed with NuGet as missing. I tried building and got a missing assembly error so I tried to re-add it with NuGet but NuGet says I have added that dll/reference to my project (it has a green checkmark).
I went into the options and checked get missing ref during build and did a rebuild and I am still getting missing asm errors.
How do I use NuGet with source control?
Right Click Solution (and projects) -> Enable NuGet Package Restore
or...
Check the packages folder into source control.
YMMV, NuGet is terrible at integrating with source control.
What exact error are you seeing with package restore ?
http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages - has more details around enabling package restore.
[For the benefit of those who land here via a web search]
As of NuGet 2.0, "Restore Packages" is a step that can be performed by the build before attempting to build your solution:
See this from official NuGet docs
Enabling package restore for a solution can be done through Visual Studio GUI and the changes made to the project are similar to what #Precipitous suggests in his comment. In essence you do this:
Right click on the solution in Visual Studio and click "Enable NuGet Package restore".

How do I delete NuGet packages that are not referenced by any project in my solution?

Somehow during the upgrade to VS2012 and .NET 4.5, I've managed to get NuGet confused. There are packages that appear in the package manager (and the packages folder) that I cannot delete (I believe they are legacy ASP.NET NuGet packages that have been replaced with new package names with the new version. They each have only a Manage button -- but no uninstall button. And when you look to see where they are used, you can see that they are referenced by none of the solution's projects? They are NOT displaying an Uninstall?
I've found a workaround for this.
Enable package restore and automatic checking (Options / Package Manager / General)
Delete entire contents of the packages folder (to Recycle Bin if you're nervous!)
Manage Nuget Packages For Solution
Click the restore button.
NuGet will restore only the packages used in your solution. You end up with a nice, streamlined set of packages.
You can use Package Manager Console with command: Uninstall-Package PackageId to remove it, or just delete package folder from 'packages' folder under solution folder.
More information about Package Manager Console you can find here: http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference
First open the Package Manager Console. Then select your project from the dropdown list. And run the following commands for uninstalling nuget packages.
Get-Package
for getting all the package you have installed.
and then
Uninstall-Package PagedList.Mvc
--- to uninstall a package named PagedList.MVC
Message
PM> Uninstall-Package PagedList.Mvc
Successfully removed 'PagedList.Mvc 4.5.0.0' from MCEMRBPP.PIR.
If you want to delete/uninstall Nuget package which is applied to multiple projects in your solutions then go to:
Tools-> Nuget Package Manager -> Manage Nuget Packages for Solution
In the left column where is 'Installed packages' select 'All', so you'll
see a list of installed packages and Manage button across them.
Select Manage button and you'll get a pop out, deselect the checkbox across project name and Ok it
The rest of the work Package Manager will do it for you.
VS2019 > Tools > Options > Nuget Package Manager > General > Click on "Clear All Nuger Cache(s)"
If you have removed package using Uninstall-Package utility and deleted the desired package from package directory under solution (and you are still getting error), just open up the *.csproj file in code editor and remove the tag manually. Like for instance, I wanted to get rid of Nuget package Xamarin.Forms.Alias and I removed these lines from *.csproj file.
And finally, don't forget to reload your project once prompted in Visual Studio (after changing project file). I tried it on Visual Studio 2015, but it should work on Visual Studio 2010 and onward too.
Hope this helps.
An alternative, is install the unused package you want to delete in any project of your solution, after that, uninstall it and Nuget will remove it too.
A proper uninstaller is needed here.
Solution 1
Use the powershell pipeline to get packages and remove in single statement like this
Get-Package | Uninstall-Package
Solution 2
if you want to uninstall selected packages follow these steps
Use GetPackages to get the list of packages
Download Nimble text software
Copy the output of GetPackages in NimbleText(For each row in the list window)
Set Column Seperator to ( if required
Type Uninstall-Package $0 (Substitute using pattern window)
Copy the results and paste them in Package Manage Console
That be all folks.
One NuGet package can reference another NuGet package. So, please be very careful about inter-package dependencies. I just uninstalled a Google map package and it subsequently uninstalled underlying packages like Newtonsoft, Entity Framework, etc.
So, manually deleting particular package from packages folder would be safer.
From the Package Manager console window, often whatever command you used to install a package can be used to uninstall that package. Simply replace the INSTALL command with UNINSTALL.
For example, to install PowerTCPTelnet, the command is:
Install-Package PowerTCPTelnet -Version 4.4.9
To uninstall same, the command is:
Uninstall-Package PowerTCPTelnet -Version 4.4.9
If you want to use Visual Studio option, please see How to remove Nuget Packages from Existing Visual Studio solution:
Step 1:
In Visual Studio, Go to Tools/NuGet Package Manager/Manage NuGet Packages for Solution…
Step 2:
UnCheck your project(s) from Current solution
Step 3:
Unselect project(s) and press OK

NuGet Package Manager Console Default Project dropdown is empty

I recently upgraded to Visual Studio 2012 RTM Ultimate from MSDN. I'm using EF Code First Migrations to build my database in my app, and I recently added a new entity and want to scaffold the migration for it.
To do this, you need to open the Package Manage Console window in VS, and type add-migration "some name here". This will scaffold any changes to your database since the last time it was updated.
The Problem
This issue did not occur on VS 2012 RC
The problem I'm encountering is the "Default Project" dropdown in the Package Manager Console is not populated, despite having several projects in my solution. The default project that is used when I just type the command above is the wrong project (my migrations are in another project). I get the following error when I do this:
No migrations configuration type was found in the assembly 'ProjectA'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
What I've Tried
I have tried setting the correct project (ProjectB) as the startup project, only to get this error:
Could not load assembly 'ProjectA'. (If you are using Code First Migrations inside Visual Studio this can happen if the startUp project for your solution does not reference the project that contains your migrations. You can either change the startUp project for your solution or use the -StartUpProjectName parameter.)
The Question
How can I manually specify which project migrations are added to, or force the Default Project dropdown to populate?
In VS 2015, I just restarted the IDE and the dropdown was filled again.
I was able to manually specify the project by using the following:
add-migration "Locations" -StartupProjectName "ProjectA" -ProjectName "ProjectB"
The documentation for this command is sparse, so here's what I assume is happening:
-StartupProjectName specifies the project where the database configuration is stored (an MVC4 project in my case)
-ProjectName specifies the project where the migrations are to be scaffolded.
I had ProjectB set as the startup project in my app due to testing for this question, but I think you can omit -StartupProjectName if the correct project is set as a startup project in VS.
Close the IDE and open again may help. It worked on my VS2015
Close the solution and open it again. Closing IDE sometimes takes more time. This works in VS 2017
If anyone is experiencing this issue with Visual Studio 2019 and .NET Core projects this is because the interface lacks a method of adding solution files to the project.
I was able to resolve the issue by using the command line tool as follows:
First navigate to the folder that holds the project and open a (git) bash console window.
Then add a solution file to the folder.
dotnet new sln
Then add a reference to each project to the solution (* will find all solutions)
dotnet sln *.sln add <project-folder-1>/<project-name-1>.csproj
dotnet sln *.sln add <project-folder-2>/<project-name-2>.csproj
N.B. Remember to replace the project folder and the name with what you need.
Close Visual Studio 2019 and reopen.
Nuget Package Manager and console will work as expected.
I had to open the solution.
To view to the solutions, look at the bottom of the "Solution Explorer" pane. There should be a "Team Explorer" tab. Click it. Then in the bottom half of the pane, your solutions should be listed. Double-click on the solution that you want to install things for, or right-click on it and select "Open".
That should open up the Package Manager Console with the correct project pre-selected.
I had to Restore NuGet packages first. Then it showed.
I had a similar issue with Visual Studio 2013. Right clicking on [Solution]->[Properties]->[Startup Project] make sure [Single startup project] is selected. I previously had multiple projects selected for Azure worker role testing.
After existing VS, Package manager worked fine.
first close vs,
then go to setting of your computer, apps & features, microsoft-visual-studio-installer,
modify, In the second tab you will get an option to define which parts of vs you want to use, select whatever belong to nuget.
when it is finished, open the vs again. now it is supposed to work
success!!!
You can select the projects under the Solution explorer .Then it showed up on package manager console . It worked for me
If you see projects under Solution explorer, but default project dropdown is empty, then my 100% precise solution is:
Select all projects under Solution explorer, right click, and REMOVE
Click in SAVE ALL
Now, select Solution explorer and ADD each project to Solution again
After that, You will see all projects added in Package Manager Console's Default Project DropDown.
That's it.