I´m trying to add System.Management.Automation to my project.
My project uses the .Net framework 4.5.
In my last project, I was able to add this reference easily by the NuGet manager console where I just had to type "Install Package" + the package name.
This time I tried the same but without any success.
I also already tried the following steps but still no success:
Reinstall the package by "Update-Package"
Delete the NuGet package so VS will reinstall it
Clear Nuget Manager Cache
Change the .Net framework
Clear project
I don´t have any other options left so hopefully someone of you can help me.
Related
I can get my .net standard 2.0 package working in a .net framework 4.7.2 dll if I do the following steps
In my standard project VS2019 61.4.4 right click the project and select pack to create the .nupkg
Then I set up a nuget package source for the package
In my framework project I install nuget package
I get the following dialog
I choose PackageReference in project file
I answer yes to accept licensing
Then I can see the following
And I can get my project working.
However on a different machine running VS2019 16.5.0 Preview 2.0, I do not get the dialog asking me to choose the package manager format.
Instead the references look like
and I can not get my project working.
[Update]
After following Lance's link to migrate packages.config to PackageReference
The project looks like
I was able to remove the unwanted packages by right clicking references and choosing Remove Unused References
The program worked!
Go Tools=>Nuget Package Manager =>General => Package Management You can control the behavior by Allow format selection on first package install. Enable the checkbox and restart VS, this change will take effect.
And note the dialog only appears when we install first package in current project. So if you create a new project and install package, it will appear. And since you once installed packages in that project, the dialog won't appear in WindowsFormApp2 any more.
(But you can easily migrate packages.config to PackageReference, see this).
Using VS 2017, v15.1, Win 7, have many projects running no problem. I simply
New, Project, Web C#, .NET Core Web App (.NET Core)
ASP.NET Core 1.1 Templates
F5, see "Hello World" in IE
Tool, NuGet, Browse, try to add Microsoft.AspNetCore.StaticFiles, Install got "Package restore failed. Rolling back package changes".
Maybe something is not up to date? Nuget again, it prompts me to update on AspNetCore and ApplicationInsights.AspNetCore. Okay, let's update them. Click on the Update button yielding the same message.
This is a brand new, I haven't added any code yet. Read these, no help
Console app, Serilog, MVC Core
It seems to me your visual studio cannot access your package source. Check if the Nuget.Org source has been added here Tools > nuget package manager > package manager settings > Package Sources if not, add source: https://api.nuget.org/v3/index.json. If the package source already exists then just clear the cache.
enter image description here
I'm using NuGet within Visual Studio 2017 to try to install a package on an older Web Forms project, and it is failing with the following error:
Invalid URI: The Authority/Host could not be parsed
This only happens when trying to install the package on a website that is mapped in IIS (other types of projects work fine), so the project name is http://localhost..., etc., which is what I think it's having trouble parsing. It worked fine until just a few days ago and I'm not sure what caused it to change. Here is the full message I am receiving:
Resolved actions to install package 'Newtonsoft.Json.10.0.3'
Found package 'Newtonsoft.Json 10.0.3' in 'd:\packages'.
Package 'Newtonsoft.Json.10.0.3' already exists in folder 'd:\packages'
Install failed. Rolling back...
Package 'Newtonsoft.Json.10.0.3' does not exist in project 'http://localhost:89/'
Executing nuget actions took 71.95 ms
Failed to add reference to 'Newtonsoft.Json'.
Invalid URI: The Authority/Host could not be parsed.
Another related clue is that when I open "Manage NuGet Pacakges..." on the website project, it is not showing anything as being installed, even though the packages.config file clearly exists in this project with several references defined.
My environment is as follows:
Visual Studio Professional 2107 Version 15.5.2,
Microsoft.NET Framework Version 4.7.02556,
NuGet Package Manager Version 4.5.0, and my NuGet repository is set to install in D:\packages
Does anyone have any advice on what setting I might be able to change to get this working again?
NuGet does not appear to be working for local IIS Web Site projects in VS 15.5.1 to 15.5.5 (inclusive).
The workaround is:
Close VS
(Just in case) make a backup copy of the .sln (solution file)
In a text editor open the .sln file and find the line:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://www.devsite.com", "http://www.devsite.com", "{A8837508-9BC1-482A-86EF-4B3156CAFDBE}"
Amend the second parameter and save:
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://www.devsite.com", "DevWebsiteFolderName", "{A8837508-9BC1-482A-86EF-4B3156CAFDBE}"
Open your solution.
Use NuGet as you wish :-)
Optional:
Close VS
Reverse your .sln change.
Open VS
For credit and further reference:
NuGet fails for website projects hosted on local IIS
Nuget looking in wrong location for packages.config in web forms web site running on IIS
This was driving me nuts... I spent hours trying to install the Authorize.net nuget package in VS2017 and it kept throwing the same error.
I finally opened my project up in VS2015 and installed it without any issues.
Hope this helps.
Jason
Given that we haven't gotten any help from Microsoft on this, we've adopted the convention of doing something like what Barry Kaye suggested, but for the second parameter, just replacing it with a single period "."
This issue appears to be fixed in 15.6.0. Try upgrading to that version, if you can.
I encountered the same problem and I solve it this way:
Right-click on the project -> Properties -> Debug -> App URL
(The app URL was not the correct one)
I am in a new ASP.NET MVC 4 project and I want to make use of Entity Framework v5.
So I opened up my package installer console in Visual Studio 2013 RC and I typed in the following:
Install-Package EntityFramework -Version 5.0.0
But I get an error! Here is what I get:
What can be causing this? I'm confused.
The message says that you can't upgrade EF6 to EF5. This tells you that EF6 is already installed. The only way to downgrade to EF5 is to remove EF6 first and then install the EF5 NuGet package.
The easiest way to remove a Nuget package is through the Visual Studio menu, Tools > Library Package Manager > Manage NuGet Packages for Solution...
Open the VS 2013
Go to TOOLS=>NuGet Package Manager=>Package Manage Console.
Copy and paste the below code and enter
PM>Install-Package EntityFramework
Right click the project you want to install EF v5 in, and click on Manage NuGet Packages. Search for "Entity Framework" and select it to install it. This simply another way to install NuGet packages but it could possibly work as opposed to typing it into the console.
Also, if this doesn't help, try it again after launching Visual Studio in Administrator mode.
Can anyone share with me how to (or where I can find how to) install NuGet packages automatically when I create a new project based on my custom project template in Visual Studio 2010?
I am creating a new project template for a project that uses a couple NuGet packages by default. I've read the documentation on the NuGet site but this is not acceptable in that I want to reference an existing package if it's already installed in the project.
In other words, if I embed package v1 in my template (VSIX) but version 1.1 has already been installed in the solution, I want NuGet to reference version 1.1 instead of putting v1 into the solution and forcing the developer to update the package.
Is this possible? And, if so, how?
NuGet 1.5 now supports this feature without requiring that you build an ASP.NET MVC 3 project template.
http://blogs.msdn.com/b/marcinon/archive/2011/07/08/project-templates-and-preinstalled-nuget-packages.aspx
This supersedes the post that I wrote. :)
Check out this post here:
http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
The article mentioned that the NuGet packages need to be on your machine, however this should change in the future (if it hasn't already).