NuGet Can't Install Packages - visual-studio

I created a new .NET core Web App and I am trying to add packages Microsoft.EntityframeworkCore and Microsoft.AspNetCore and I am getting the error:
package restore failed rolling back packages
I have tried clearing the NuGet Caches reinstalling VS 2017 and the problem persists, note the project is brand new.

Please make sure your VS 2017 already upgraded to 15.3.5, you can re-run the VS 2017 installer as administrator and if there has the ‘Update’ button, click it to update. Then check you also installed the latest .NET Core 2.0 SDK and then create a new ASP.NET core web application, choose ‘ASP.NET Core 2.0’ as below to create:
Then you can successfully install those 2 packages through Manage Nuget Packages like the following:

Related

Nuget packages does not get install properly in freshly installed VS

I have freshly install and update VS Community version 16.10.0 in a freshly installed Windows 10.
Now I have created a small console app and added a unit test project both in .Net Core 3.1 LTS. After that nothing else is done. What I see is that nuget packages for test project is not properly installed although when you check in the nuget package manager, all the package are installed, all of those are installed.
Then I open an old application but the issue is same. Unit test packages are showing with error and same for EF core.
I tried to tweak/build etc. but non fixed the issue.
The issue was due to missing nuget source link in Package Source under NuGet Package Manager.
As soon as I added the package source everything stated to work.
https://api.nuget.org/v3/index.json
The above source link suppose to already be added by default in Package Source but for some unknown reason it was missing. So whatever packages needed such as EFCore and MS Test framework etc. could not be downloaded, hence the problem was.

Visual Studio 2019 where to find WebAssembly template for .net core 3.1

I'm using very latest (16.4.2, dated 8th Jan 2020) Visual Studio 2019.
When I tried to create a Blazor WebAssembly solution, although the description for 'blazor app' included the words 'server or webassembly', when I got to the create page, only Server option was available and it successfully creates Core 3.1 application.
I assumed latest version would be there, so I went to the Visual Studio marketplace website and there were no Blazor extensions to be found, so looking on the internet I found running this command:
dotnet new -i
Microsoft.AspNetCore.Blazor.Templates::3.1.0-preview2.19528.8
(found via Missing visual studio 2019 blazor webassembly app template)
And it worked, I got web assembly option. However, when I look at my project created using WebAssembly it is using .net Core 2.0 and the options only go as far as 2.1. I presumed by the '3.1.0' section in the name it would be the latest.
Any idea how I get the latest template rather than random searching and use .net core 3.1?
If there is a better way, can anyone let me know how to uninstall templates as I failed to find out how.
Run the following in a CLI or in Tools -> Nuget package Manager -> Package Manager Console:
dotnet new --install Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-preview3.20168.3
The NuGet package for above is here.
Get started with ASP.NET Core Blazor here.
Update
The latest release is now an RC and can be installed with the following:
dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-rc1.20223.4
The latest preview release as of April 30th can now be installed with the following:
dotnet new -i Microsoft.AspNetCore.Components.WebAssembly.Templates::3.2.0-preview5.20216.8
This requires the latest dotnet core SDK 3.1.201.
To check for the latest preview you can check the ASP.NET blog.

Team City Build Failure Restoring .NET Standard

I'm trying to set up a build configuration for an ASP.NET Core (built on .NET full framework 4.6.2) project.
I'm Using TeamCity Enterprise 2017.2.3 (build 51047)
The .NET Core SDK is installed on the build server, along with 4.6.2 of the .NET Framework.
I am getting the following Build Error Message:
... This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets.
Anyone come across this error before?
I added the latest recommended Nuget exe (4.6.2) as well.
The build step upon which it is failing is a .NET CLI (dotnet) step.
I've set the Command to build
and the Projects to the Solution file.
Dotnet CLI is definitely installed and is version 2.1.300
Yeah update the build tools on the TeamCity server, you're probably using the latest Visual Studio version on your local machine but your build tools on the build server are slightly out of date, probably earlier than v15.5.
https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=15
Also ensure that you have selected to add the .NET Core 2(+) build tools as they include the .NETStandard and aren't selected by default. See https://github.com/dotnet/standard/issues/458#issuecomment-323845208

NuGet doesn't show items in feed, but can list via console

I recently upgraded to TeamCity 9, at first everything was okay. Then, for some unknown reason, I was unable to get a full list of available packages via the NuGet GUI. At first it appeared that all the portable class libraries where missing, then all of them went missing.
What I've tried:
I've removed all old artifacts from TeamCity,
I've deleted and reset TeamCity's cache
I've restarted TeamCity and its NuGet v1 service
I've rebuilt some basic class libries (PCL) with no dependencies.
I've cleared NuGet cache in my Visual Studio options.
I've ran VS as admin.
When I click on my TeamCity Feed in the package manager, it immediately returns no results with a very brief flash of "retrieving result".
Okay so the very odd thing is I can manually list (and install) my packages via the console:
PM> Get-Package -ListAvailable
Id Version Description/Release Notes
-- ------- -------------------------
RobGeoLtd.Core 1.0.2 Core Framework Portable Class Library
RobGeoLtd.Measurement 0.1.36 Defines units of measurement and conversion methods between them
PM> Install-Package RobGeoLtd.Core
Installing 'RobGeoLtd.Core 1.0.2'.
Successfully installed 'RobGeoLtd.Core 1.0.2'.
Adding 'RobGeoLtd.Core 1.0.2' to Logger.
Successfully added 'RobGeoLtd.Core 1.0.2' to Logger.
PM>
So yeah, I'm at a loss. NuGet bug? I'm all up-to-date as far as I can tell. :/
For anyone experiencing a similar issue:
I also tried all of the above. It turned out that my built packages were targeting .NET 4.5.2 and my project was targeting .NET 4.5.
It would appear to be a TeamCity issue. I reverted to a back up of the CI server running 8.1.4 and the old feed items have returned. I will attempt the upgrade again.
Update: Yup, its defiantly the upgrade from 8.1.4 to 9.0.3 that caused it. Will file a bug. https://youtrack.jetbrains.com/issue/TW-40589

NuGet Package Manager errors when trying to update

Opening VS2010 today, the extension manager notified me of an update for NuGet Package Manager.
During the install, I get an 'Installation Failed' with an option to view the log.
The key error message I see in that log file is:
The signature on the update version of 'NuGet Package Manager' does not match
the signature on the installed version. Therefore, Extension Manager cannot
install the update.
The version numbers I am upgrading from/to are as follows.
Current Version: 1.5.20902.9026
New Version: 1.6.21205.9031
I have also tried to install it while VS2010 is closed via this page:
here
Update: The recently released NuGet 2.0 also may require uninstalling an older version of NuGet first.
From the NuGet 2.0 Release Notes: (http://docs.nuget.org/docs/release-notes/nuget-2.0)
Known Installation Issue
If you are running VS 2010 SP1, you might run into an installation error when attempting to upgrade NuGet if you have an older version installed.
The workaround is to simply uninstall NuGet and then install it from the VS Extension Gallery. See http://support.microsoft.com/kb/2581019 for more information, or to go directly to the VS hotfix.
Note: If Visual Studio won't allow you to uninstall the extension (the Uninstall button is disabled), then you likely need to restart Visual Studio using "Run as Administrator."
Here is the VisualStudio/Express hotfix for this issue...
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=38654
There's not much on the page describing what it's for, but it's linked to from here that does provide some description...
http://connect.microsoft.com/VisualStudio/Downloads
I have installed this hotfix on both the Professional (on Win 7 Pro 32 bit) and Express versions (on Windows 7 Ultimate 64 bit) and the NuGet update behaves as it should.
When i originally had the problem, Joe Doyle's answer solved it.
However, going to version 1.8, I cannot see a listing for nuget in Programs and Features.
So from within Visual Studio / Tools / Extension Manager.
Uninstalled NUGET.
Restarted VS
Return to the Extension manager and install NUGET.
After uninstalling Nuget from Control panel, Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft Corporation\NuGet Package Manager\ or the location matching similar pattern based upon windows bit version, and delete the folder 1.0.11220.104. And, if you install it now, you wont' get the same problem.

Resources