NuGet Project > Add Library Package Reference not appearing - asp.net-mvc

I have installed NuGet.
When I try to go to Project > Add Library Package Reference
"Add Library Package Reference" is not under the project menu. If I try to install NuGet again it says it is already installed. My application is an MVC 3 application targeting .net 4.
How can I get this option to appear?

You might also run VS as Admin (Ctrl-Shift-Click) then uninstall NuGet from the package manager dialog. Then update to NuGet 1.1 from http://nuget.codeplex.com and see if that fixes it. ASP.NET MVC is not needed.

Is it possible that some of the extensions of your Visual Studio are causing NuGet to not show the menu or crash? You could try to disable/remove them and then install NuGet from here: http://nuget.codeplex.com/
Besides, there is also a PowerShell-based Package Manager Console. You could take a look on that in case everything fails.

Make sure you have the project selected and not the solution in the solution explorer.

As of May 2012, it's now called "Manage NuGet Packages".
Especially confusing because the screenshots in the NuGet Docs have not been updated.
https://stackoverflow.com/a/9844659/24267

Normally NuGet is installed with ASP.NET MVC 3 so it should appear automatically. Try removing the NuGet package that you have installed and reinstall ASP.NET MVC 3.

Had this same issue, just realized that if you're not on the project (i.e., you have the solution highlighted in solution explorer) that the option for the Add Library Package Reference won't show. Select the project and it's there.
Whoops: Didn't notice that was already mention.

I've just had a similar problem, after trying to install a package over dial-up, which timed out.
To fix it, I renamed the registry key (so that I could rename it back if it didn't work) HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\NuGet, then restarted visual studio and opened a project. The Add Library Package Reference now works and the registry key has been recreated.

Related

I am not able to add insigths telemetry to new Asp .NET framework project

I want to test the Azure Insights telemetry and for this purpose, I have created a new free Azure account and a new MVC Web App Application (Framework 4.7.2)
The App runs correctly.
After that, I tried to add the telemetry: project -> Add Application Insights telemetry
Following the wizard. I get the following error that I am not able to solve.
System.NotImplementedException: The method or operation is not
implemented. at EnvDTE.SourceControl.CheckOutItem(String ItemName) at
Microsoft.WebTools.Shared.VS.VisualStudio.Wrappers.VsSourceControlWrapper.d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown
I tried to update the NuGet packages too. But nothing to do.
I have followed step by step the official Microsoft docs.
Some details for the installation process:
I'm having problems only with the .NET framework.
With .NET Core, anything works correctly.
Googling I didn't find any solution.
There are some other dependencies you need to install as well,
Install-Package Microsoft.ApplicationInsights.DependencyCollector -Version 2.6.4
Install-Package Microsoft.ApplicationInsights.PerfCounterCollector -Version 2.6.4
Install-Package Microsoft.ApplicationInsights.Web -Version 2.6.4
Install-Package Microsoft.ApplicationInsights.WindowsServer -Version 2.6.4
Install-Package Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel -Version 2.6.4
Try as mentioned here
Choose the first option when adding insights, Application Insights SDK. That will install all the necessary packages.
Once that's done, you will need to add instrumentation key to the config file. Add that on top.
Your error looks more of source control rather that the project.
If you trying to work in source control and adding insights to already checked-in project, may be try creating a dummy project, and add insights to it. That will give more clarity on error, as well as help to pin-point exact issue.
I had the same issue with adding microsoft identity platform in VS 2022:
System.NotImplementedException: The method or operation is not implemented.
at EnvDTE.SourceControl.CheckOutItem(String ItemName)
When I changed Tools/Options/Source Control from "None" to "git" (also when I am using Git with an external tool, the error was gone.
To me it looks just like one of a VS bug on a certain configuration. Try to uninstall whole VS and then install latest version again. Try another PC if you can.
I encountered this problem also. The work around that eventually worked for me was to add Application Insights in Visual Studio 2017, instead of in 2019 which I normally use.
Your error looks more of source control rather that the project. If you trying to work in source control and adding insights to already checked-in project, may be try creating a dummy project, and add insights to it. That will give more clarity on error, as well as help to pin-point exact issue.
That does not seem to be the case for me. I completely disabled source control and the problem still persisted. When I got the issue "fixed" by using VS2017 source control was running.
To me it looks just like one of a VS bug on a certain configuration. Try to uninstall whole VS and then install latest version again. Try another PC if you can.
I tried this, did not work for me.

Update 2 Error Adding MVC View

Last night, I updated Visual Studio 2015 on my system from RTM to Update 2. I now get an error message when I try to add a new View to an ASP.Net MVC application I am working on:
There was an error running the selected code generator:
'Expected 1 export(s) with contract name "NuGet.VisualStudio.IVs.PackageInstaller" but found 0 after applying applicable constraints.'
Any ideas on how to fix this? I had no trouble adding a few views to this project yesterday before I installed the update.
tl;dr - Reinstall NuGet Package Manager
I know this is an old thread. But I encounter the same error message today and found no solution online that works for me. So I decided to answer on this old thread for future devs that will encounter the same error message.
The reason for my case is that my NuGet Package Manager was missing.
I recently installed Wekan and it required me to install Visual C++ 2015 Build Tools, and I think that might be the culprit why NuGet was removed.
So, my solution is to download and reinstall NuGet Package Manager:
In Visual Studio open Extensions and Updates Tools > Extensions and Updates (or by pressing ALT+T+U)
On the left pane click Online and search for keyword NuGet Package Manager for Visual Studio 2015, download/install
Restart VS
These are the other solution that worked for some (didn't work for me):
Try clearing the ComponentModelCache, the cache will rebuild next time VS is launched.
Delete NuGet.Config at C:\Users\UserName\AppData\Roaming\NuGet, and restart VS
Unload/Reload project, Clean solution, Rebuild then restart VS
Updating the VS2015 will force you to update after that the whole work you have done so far. Most of the references specially NuGet are changed or outdated in 2015. I am currently using vs2013 with MVC5. I would suggest you to update the references and find a solution about this NuGet package. It might be no longer available for this view you want to add. In addition, there is a similar topic with Q&A to your and it is accessible right here: Unable to Install Any Package in Visual Studio 2015 . Take a look but VS2015 the free version is not that good for coding. Better download visual studio 2013 with update 5 and you will be much better. If you still want to keep it with VS2015, take a look at this and download it.
VS2015 NuGet Manager:
https://visualstudiogallery.msdn.microsoft.com/5d345edc-2e2d-4a9c-b73b-d53956dc458d

Can't run solution from TFS as all references are missing

I have a project which works fine. This morning, I created a new TFS project and published all the code from Visual Studio 2015.
On another computer, also via VS2015, I've logged into Visual Studio Team Services to grab the same project and downloaded all the code
When I try to build, there are over 100 errors, but the cause appears to be the same. It can't find resources, and the error messages all appear to be
The type of namespace name 'some name' does not exist in '....' (are you missing an assembly reference?)
So, I expand the References and I'm missing pretty much all of them. In fact, other than the references within my own project, the rest are not there
Looking at the properties shows no path. Back on the original PC I see the path to any of the .dlls is similar too
C:\Users\Me\Documents\Visual Studio 2015\Projects\MyProj\ToT\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll
Is the issue that since this path doesn't match on the 'faulty' machine it can't show... Therefore what is the solution to this
I checked and noted that the files do appear to exist when I look at them in File Explorer.
All system references missing Visual Studio 2013 NuGet Async did not help
Please note, this happens with all projects in my solution, but not consitently. For example, EntityFramework is missing from all, but System is missing from my UI layer, but not from my BLL layer
Is there a way to fix this?
You need to run the update-package -reinstall command to reinstall all referenced packages.
I had the same problem, there are lots of answers by now but I will still post it here:
1.Close Visual Studio
2.Manually delete the local “packages” folder
3.Reopen the solution, and rebuild. (Nuget should restore the packages)
Source:
http://robertgreiner.com/2013/09/team-foundation-service-build-error-nuget/
Go to TOOLS -> nuget package manager -> package manager console -> and run to the console : UPDATE-PACKAGE -REINSTALL .
Clean your solution, rebuild and you are ready!
Sounds trivial but your missing references to system.xxxx could imply a problem with the .NET Framework, what version are you using and is it installed properly on your 'faulty' machine. Might be worth a re-install/repair? I'd check what versions are actually referenced too.
As for NuGet, make sure that Enable package restore is set as:
Also, I had a problem similar to this once and I had to upgrade the NuGet package manager to version 3 in Tools -> Extensions and Updates (You need to uninstall and then re-install as update won't work)
Finally if that doesn't work, check in File Explorer in the packages path and delete all packages. They should not be included in source control as this is what NuGet will download. If they are there or partially there, sometimes it will not download them.
Verify the .NET version:
Open the project properties pane and check the Target Framework:
Ensure this version of .NET is installed. OR change the target framework to a suitable version
First, go to VS--Tools--Extensions and Updates to check whether there are updates, install all updates. Then select one reference with a warning icon, check the Specific Version property, if the value is True, change it to False.
If the issue persists, check the Reference Assemblies of .Net framwork on your two computers, to see whether they are under the same location (the .Net framework is supposed to be under *C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework*).
=========================================================================
11/5: To avoid references missing, you can either check in all references to source control and reference from the source controlled ones, or use Nuget Package Manager to install packages. The previous is not recommended now, try Nuget Package Manager.
Before hitting your head against the wall with the million of Nuget 'fixes' you need to make sure you are getting ALL the DLLs that are in your Bin folder under source control. For some reason a simple "Get Latest Version" is not enough. Visual Studio will keep telling you all files are up to date but apparently this doesn't mean all the files under source control are downloaded (or it does and what happened to me is just a sassy bug). Anyways, to make sure you are truly "getting all" you need to force an update by using the "Get Specific Version" command with the "Overwrite all" option checked as VS suggests. To do this:
Go to your Bin folder in Source Control Explorer (Or w.e folder you truly want to get all)
Right Click > Advanced > Get Specific Version
Check the "Overwrite all files even if the local version matches the specified version" checkbox
Click Get
By doing this I ensured all the referenced DLLs were downloaded from TFS and for me that solved the problem. I'm using Visual Studio Enterprise 2015.

NuGet package messed up project

I installed this NuGet package through the Package Manager Console. It messed up my project and since System.Net.Http is missing so it is impossible to build my ASP MVC WebApi project anymore.
I tried removing references to System.Web.Http.WebHost.dll from the project and adding the previous one (that used to work) and regardless of which I used now, the Http part of the namespace can't be found.
Have you ever had this problem ? I read trashing the project and starting from scratch solved it for others, but that's not really a solution in my book.
Any ideas ?
Try to run this in Package Manager Console:
Update-Package Microsoft.AspNet.WebApi.Cors -Reinstall
If you get any errors, comment below.
I trashed the project and restarted a new one (Web API). I'm just drag and dropping class files back in the new one.
It wasn't under source control. That'll teach me.

this template attempted to load component assembly Microsoft.VisualStudio.Web.Project

I just installed Visual Studio 2013 Ultimate trial version for completing the MVC5 tutorial by Rick Anderson, which worht doing it.
The tutorial: http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started.
However, I created a blank solution first and then try to add an ASP.Net Application project, which is going to be my MVC5 tutorial project. And I got this weird message:
Error: this template attempted to load component assembly
'Microsoft.VisualStudio.Web.Project, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. For more information on this problem
and how to enable this template, please see documentation on
Customizing Project Templates.
But I´m not customizing, I´m just creating a project out of a built in template.
Do you know how can I solve it?
Here is the solution:
In Visual Studio 2013, select Tools > Extensions and Updates
Check for updates. You should have the Azure SDK update available.
Download and install the Azure SDK. After this, everything should work fine.
If your updates are not turned on, enable your auto detection of updates in Tools > Options > Environment > Extensions.
If you have unspecified error related to E_fail(code), try this:
When creating a new MVC 5 application, change the framework version from 4.5.1 to 4.5, if that did not work change it to 4. Check the below image if it is not clear.
Another approach:
This is really important if you are installing Visual Studio 2013 on un-updated Windows 7.
there reason i am calling out "not updated is",
The reason that 'un-updated' matters is because Visual studio 2013 does not update the powershell that is required by VS2013 for most of the stuff.
The simple solution is to update Powershell to the latest version.
If you are not sure how to update powershell, you can use this tutorial.
So I stumbled upon this issue as well and would like to share how I was able to resolve this problem.
Tools -> Extensions and Updates -> Online -> NGet Package Manager: Click the download button once you have the NGet Package Manager selected. Make sure to restart your Visual Studio after you have downloaded the Manager.
This should do the trick
Close Visual Studio, run the VS executable with the command line option as shown below (you will likely have to supply the full path), and relaunch VS normally. This should re-initialize the templates, including the one that you are having problems with.
devenv.exe /installvstemplates
So I faced the same problem with Visual Studio 2013, and I don't know what's the problem but it appears that it only occurs when creating a new project, and choosing "Web" from the panel.
What I did was simply clicking on "Visual Studio 2012" just below it, and it worked !

Resources