How do I update nuget.exe version used by dotnet cli - .net-core

I have installed the dotnet core sdk and it all works. I want to update the nuget version though so that when I run dotnet pack it uses the latest nuget. With normal nuget.exe I can run nuget.exe update -self and it updates itself. However with dotnet cli there doesnt seem to be any equivalent command. I also cant find which nuget.exe path its referencing to update it there manually.
Any ideas on where its located or how to update this? Or do I need to just update the entire .net core SDK to get a newer nuget version?

I am pretty sure you can't upgrade the nuget version shipped in .NET Core. It's a core part of the .NET Core SDK and no individual component of SDK can be upgraded.
Why do you want to use a newer NuGet version?

Related

How can we bundle and install lower version of dotnet core using Wix Sharp?

We developed our application and tested over DotNet core 3.1.101 and it was working fine but what happened is Microsoft updated dotnet core to 3.1.111 and it breaks our application and we are asking customer to downgrade the core version manually that doesn't seem to be good idea.
Can somebody Wixsharp/.Net expert suggest, how can we avoid this problem? Can we have side by side installation of dotnet core and use the desired on with our application? If yes, How can we do it?
If you are really dependent of the specific net core version, the best solution to you will be to use self-containing publishing (https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained). This will create the solid bundle from your code and the your current net core version. On the client machine your app will use the net core, which is bundled with app. User may have other versions of net framework/net core installed, but these versions will not affect your app in any way.
For example, the following will create 64-bit executable for Windows
dotnet publish -r win-x64.
After you got your bundle from publish command, you need just pack the whole bundle with wix as usual. Not need to perform additional steps to install net core.

Bamboo NuGet Restore command is running older version of SDK

I have a .net core 2.2 web app that has been building successfully in Bamboo for several months. Recently someone rebuilt the new Bamboo server (we're on premise, not in cloud) as the first step in a Bamboo upgrade and my build began failing. The error is:
C:\Program Files\dotnet\sdk\2.1.509\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.
My original post incorrectly asserted that this error was occurring in a Script task running dotnet publish. I realize now that it is actually occurring in the previous task - a Bamboo Command task running NuGet Restore. And I can reproduce the problem at the command line, so it does not appear to be a Bamboo issue.
So, in summary, I have a .NET Core solution with four projects. All four projects target .NET Core 2.2. I have NuGet 5.3.1 installed on my Bamboo build server. I navigate to the solution directory and run
nuget restore
And I first get the following informational message:
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
Followed by four instances of the following error, one per project:
C:\Program Files\dotnet\sdk\2.1.509\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 2.2. Either target .NET Core 2.1 or lower, or use a version of the .NET SDK that supports .NET Core 2.2.
What is causing the nuget restore operation to be working with .NET Core 2.1 instead of 2.2? Is there a problem with the msbuild auto-detection?
I initially found that .net core 2.2 had not been installed on the new server, so I installed it, so both are now installedre. But the error above persists and continues to reference .net core 2.1.
Instead of running nuget restore use dotnet restore.
A cleaner way to set this up would be to configure a dotnet executable as a Command in Bamboo. By doing this you can ensure that you are running the correct executable every time. Additionally you will gain the following benefits:
The command will show what version it is
This scale to other build agents
Adds clarity to the Bamboo task (will show as dotnet 2.2 instead of a script).
Then you can have dedicated tasks for each step (e.g., restore, build, test)

Publishing a Self-contained Console app fails

I installed the .NET SDK 2.1.301-win-x64.exe and afterwards updated all the nuget packages to 2.1.1.
In my WebApp I have the Nuget Package Microsoft.AspNetCore.All 2.1.1 and Microsft.NETCore.App 2.1.0. In the Nuget Window I see that there's also the Version 2.1.1, but I can't select it (Blocked by Project)
Same story in my Console App: Microsft.NETCore.App 2.1.0
My first question: Is here already something wrong? Or is this expected behavior?
If I build the WebApp as self contained App, that works well.
If I biuld the Console App as self contained App (Self-contained / win-x64). I get the follwoing Error:
The project was restored using Microsoft.NETCore.App version 2.1.1,
but with current settings, version 2.1.0 would be used instead. To
resolve this issue, make sure the same settings are used for restore
and for subsequent operations such as build or publish. Typically
this issue can occur if the RuntimeIdentifier property is set during
build or publish but not during restore."
The source of this error is a referenced project.
What do I do wrong? Let me know if you need additional information, then I will add it.
This is a known issue for the moment. In your referenced project's csproj file, set the TargetLatestRuntimePatch property:
<PropertyGroup>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
</PropertyGroup>
This only happens when a .NET Core application references another .NET Core application and self-contained roll-forward only partially kicks in during publish.
For portable applications, it is enough to target 2.1.0 version of Microsoft.NETCore.App and when run on a target machine, the latest patch available on the machine will be used automatically. In recent tooling, a change was made so that the tooling would use the latest known patch version for self-contained applications so you automatically bundle the latest patch release with your application. However, this doesn't flow over project-to-project references.
See Self-contained deployment runtime roll forward for more information.

Not able to see .NET Core 2.1.4 even after installing SDK

I had installed VS2017 Professional last year which came with ASP.NET Core version 1. I wanted to use features of Core version 2 so installed the latest SDK. Now in my Command line when I check version dotnet --version the it comes fine. Means it is Installed.
But when i try to start the a new project then the framework list it gives does not contain version 2 templates.
Please can anyone help me with it?
You will need to update your Visual Studio 2017 version. Latest is as of today is 15.5.6.

Removing complete ASP.net 5 RC1 environment before moving to DOTNET Core RC2 from OSX

Recently, there is RC2 release for donet core tools. Previously, I have been using RC1 for asp.net 5. It was installed using .pkg file provided at get.asp.net.
Now, I am planning to try out dotnet core release. The instructions provided at get.asp.net ask to unistall the previous versions of dotnet core using this script.
I have 2 questions here.
Is it required to remove the RC1 release (dnvm,dnx and dnu etc) before installing dotnet core?
If it is required to uninstall, what is preferred way of doing it (something like above script) without damaging the required/shared files?
Ad 1. Yes. As you can read in ASP.NET Core installation guide:
Before you start
Remove all previous versions of .NET Core from your system.
Ad 2. In my case I just use Add/Remove programs, but it's Windows.
I have no experience with Linux, but you do not need DNX any more so no worries about required files - after a while you will install new RC2 with all required files ;)

Resources