Command line to install/upgrade .NET Core - asp.net-core

Are there command line commands to install or upgrade .NET Core?
I checked to see if I had .NET Core was installed on my computer using dotnet --version only to notice that I still had the preview version installed on my computer. I was wondering if I could issue some commands to upgrade it to the latest version.

There is no dotnet command to update .Net Core. Instead, you should use the same approach you used to install it in the first place, which depends on your OS.

Not promoted officially but it looks like there are approved packages on Chocolatey for .NET Core SDK.
https://chocolatey.org/packages/dotnetcore-sdk
Example:
> choco install dotnetcore-sdk
Or:
> choco upgrade dotnetcore-sdk
Update (December 2020): For .NET 5 the chocolatey package has changed since it's not technically branded as .NET Core any longer.
https://chocolatey.org/packages/dotnet-sdk/
Example:
> choco install dotnet-sdk
Or:
> choco upgrade dotnet-sdk

If you have WinGet, then you can use it to install (or update) .NET:
winget install Microsoft.DotNet.SDK.Preview # currently .NET 7
winget install Microsoft.DotNet.SDK.6
winget install Microsoft.DotNet.SDK.5
winget install Microsoft.DotNet.SDK.3_1
Run from an admin prompt

For those who find this on search, there are dotnet-install scripts you can use. For example:
# Windows PowerShell
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile "$env:temp/dotnet-install.ps1"; powershell -executionpolicy bypass "$env:temp/dotnet-install.ps1"
# PowerShell Core
Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile "$env:temp/dotnet-install.ps1"; pwsh "$env:temp/dotnet-install.ps1"
# Shell
wget https://dot.net/v1/dotnet-install.sh && chmod +x ./dotnet-install.sh && sudo ./dotnet-install.sh
* Note the default install location for these is different than the official installers; as said in another answer the easiest path to update is to use the same method you first installed with.
Edit: apt packages for Ubuntu 22.04+ now includes dotnet6 for the SDK. Other dotnet packages, such as just the runtime (dotnet-runtime-6.0, aspnet-runtime-6.0) can be installed as well.
sudo apt update
sudo apt install dotnet6

Just a heads up so you (or other people) don't struggle for hours as I did.
.NET Core 1.1.0 ships with SDK 1.0.0 Preview 2 (when this is written), but you need SDK 1.0.0 Preview 3.
Download and install .NET Core 1.1.0 as #svick suggested, then download and install SDK Preview 3 from: https://github.com/dotnet/core/blob/master/release-notes/preview3-download.md

Related

how to update meson version in flatpak builder

I'm trying to work on a gnome project (Aisleriot). It requires meson, so I installed it using
sudo apt install meson
That installed version 0.61.2. Unfortunately, the project requires version >= 0.62.0. Next, I ran the following command:
sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build
Now meson is at version 0.64.0. Unfortunately, when I run Builder
flatpak run org.gnome.Builder
and load my project, it still uses meson version 0.61.2. Why is it using this earlier version and how do I tell Builder to use the system version instead?
There is a similar question from 4 years ago, but it talks about a build settings panel, which I couldn't find. Does the build settings panel still exist and how do I display it?

Building VS 2017 MSBuild csproj Projects with Mono on Linux

I have .NET Core projects I am trying to build using Travis CI on Mac and Linux using the latest Mono and .NET Core 1.0.1 tooling (MSBuild based csproj tooling). They target netstandard1.6.1, net45 and net461. The error I get from Travis CI is:
/usr/share/dotnet/sdk/1.0.1/Microsoft.Common.CurrentVersion.targets(1111,5):
error MSB3644: The reference assemblies for framework
".NETFramework,Version=v4.5" were not found. To resolve this, install
the SDK or Targeting Pack for this framework version or retarget your
application to a version of the framework for which you have the SDK
or Targeting Pack installed. Note that assemblies will be resolved
from the Global Assembly Cache (GAC) and will be used in place of
reference assemblies. Therefore your assembly may not be correctly
targeted for the framework you intend.
Does Mono not support VS 2017 MSBuild based csproj projects? How can I get my projects to build?
There are two options here, as far as I'm aware:
Use the FrameworkPathOverride environment variable as described in this issue to point to them.
Restrict your Travis build to only build against .NET Core. This is significantly simpler in my experience.
Here's the Noda Time .travis.yml file I'll be using for Noda Time when I can migrate - it's preliminary to say the least, but it does build...
language: csharp
mono: none
dotnet: 1.0.1
dist: trusty
script:
- dotnet restore src/NodaTime
- dotnet restore src/NodaTime.Test
- dotnet restore src/NodaTime.Serialization.Test
- dotnet build src/NodaTime -f netstandard1.3
- dotnet build src/NodaTime.Test -f netcoreapp1.0
- dotnet build src/NodaTime.Serialization.Test -f netcoreapp1.0
- dotnet run -p src/NodaTime.Test/*.csproj -f netcoreapp1.0 -- --where=cat!=Slow
- dotnet run -p src/NodaTime.Serialization.Test/*.csproj -f netcoreapp1.0
A few notes on this:
Unlike earlier SDKs, we now need to restore each project separately - no big "dotnet restore at the top level" :(
I was surprised when this didn't run on dist: xenial, but it didn't. (It claims the environment doesn't support .NET Core.) My guess is this will change.
We're using NUnit, and at the moment the only way of testing in the new SDK is to use NUnitLite, hence dotnet run to run tests
I'm slightly surprised I can't just specify the directory name for dotnet run (as per dotnet restore and dotnet build) but that seems to be the way of things. I'll hunt down a bug report...
In either case, I'd recommend also having a Windows-based CI build to check that everything builds and works on Windows (ideally testing each framework you support).
As of yesterday (May 5th), #dasMulli pointed out that Mono released Mono 5.0 Beta 2 (5.0.0.94) that works with .NET Core! Here is his post on dotnet/sdk#335. Here is a link to the latest beta release
My .travis.yml file looks like:
sudo: required
dist: trusty
language: csharp
solution: MySolution.sln
mono:
- beta
dotnet: 1.0.3
install:
- nuget restore MySolution.sln
- dotnet restore MySolution.sln
script:
- msbuild /t:Rebuild MySolution.sln
Mono DOES support building VS2017 .Net Framework projects as it now uses msbuild.
To get it working on Travis CI is a bit tricky but this should do the trick:
- wget -q https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb
- sudo dpkg -i packages-microsoft-prod.deb
- wget -q http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/gcc-5-base_5.4.0-6ubuntu1~16.04.9_amd64.deb
- sudo dpkg -i gcc-5-base_5.4.0-6ubuntu1~16.04.9_amd64.deb
- wget -q http://security.ubuntu.com/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.9_amd64.deb
- sudo dpkg -i libstdc++6_5.4.0-6ubuntu1~16.04.9_amd64.deb
- wget -q http://security.ubuntu.com/ubuntu/pool/main/i/icu/libicu55_55.1-7ubuntu0.4_amd64.deb
- sudo dpkg -i libicu55_55.1-7ubuntu0.4_amd64.deb
- sudo apt-get install apt-transport-https
- sudo apt-get install -y libicu55
- sudo apt-get install dotnet-runtime-deps-2.1
- sudo apt-get install dotnet-runtime-2.1
- sudo apt-get install aspnetcore-runtime-2.1
- sudo apt-get install dotnet-sdk-2.1
Basically, you need to manually install the dotnet-sdk manually and all of it's dependencies.
Then simply call msbuild:
- msbuild /p:Configuration=Release Solution.sln
.NET Framework Targeting Pack Nuget Packages
You can now build new style csproj projects with Mono on Linux by adding a NuGet package:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Build">
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference
Include="Microsoft.NETFramework.ReferenceAssemblies"
PrivateAssets="All"
Version="1.0.0-preview.2" />
</ItemGroup>
</Project>
More information can be found on the Microsoft/dotnet GitHub page. At the time of writing it's in preview but I've found that it does work. The only gotcha I discovered is that dotnet test with xUnit projects does not work and is not a supported scenario according to the xUnit author.

Launching latest version of MonoDevelop on Ubuntu 14.04 LTS

I installed MonoDevelop using following commands:
sudo add-apt-repository ppa:ermshiperete/monodevelop
sudo apt-get update
sudo apt-get install monodevelop-current
because I wanted latest version.
sudo apt-get install monodevelop
results in installing 4.x version which I wasn't interested in.
Now I can launch application via terminal using:
/opt/monodevelop/bin/monodevelop-launcher.sh
but "monodevelop" command results in following information:
The program 'monodevelop' is currently not installed. You can install it by typing:
sudo apt-get install monodevelop
and creating monodevelop.desktop file doesn't result in having program icon in launcher. Any ideas what I should do to be able to run MonoDevelop using "monodevelop" command?
I installed MonoDevelop using following commands:
sudo add-apt-repository ppa:ermshiperete/monodevelop
Do you realize that when adding a repository, you're trusting this user (what he decides to package in his repository), and that the version you get is the one that he himself alone decided to package?
I recommend you to add the repository of the official developers/packagers instead. Follow the instructions here (but uninstall any old packages first).

dnx is not recognize to run asp.net 5 application

try to run Asp.Net 5 Application through command prompt by using command
C:\asp.net5App\src\asp.net5>dnx .web
error message that I am getting.
'dnx' is not recognized as an internal or external command,
operable program or batch file.
Run dnvm upgrade.
If dnvm is not recognized, follow the instructions on the Home repo to install it, then do the previous step.
I am tied of this thread, because it has so many misleading answers that happen to work for some people and not for others. But anyway this is what worked for me.
Install visual studio 2015 (Enterprise)
open Developer Command Prompt for VS2015 and ran the following commands
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
the above installs .NET Version Manager (DNVM)
Then i cd into the folder where dnvm has been installed e.g
cd /Users/johnny/.dnx/bin
there i ran these commands
dnvm upgrade -r coreclr (To install DNX for .NET Core)
dnvm upgrade -r clr (To install DNX for the full .NET Framework)
then i ran
dnvm setup (to firmly setup the path)
then i got out of /Users/johnny/.dnx/bin and ran
where dnvm = C:\Users\johnny.dnx\bin\dnvm.cmd
dnvm = produced a batch of commands options to be used
Check that you've got an active runtime before you can use dnx.
dnvm use

How can I get Mono 2.11+ installed on Travis-CI?

I build my C# project on Travis-CI like this:
# .travis.yml
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq mono-devel gtk-sharp2
install:
- xbuild Source/Pash.sln
Travis uses Precise (Ubuntu 12.04 LTS) which seems like a good choice for them, but it includes Mono 12.10. My C# project hits a bug in Mono 2.10. The bug appears to be fixed in Mono 2.11+.
I read that Ubuntu is slow to pick up new builds of Mono because so much depends on it, and it can break so much. That's fine, but for Travis dependencies aren't really a problem - the machine goes away at the end of the build!
I have considered
compiling a new Mono in .travis.yml but I don't want to put that much burden on the Travis servers.
Building a MCS (Mono C# compiler) with just this fix.
Downloading and installing a newer Mono from somewhere (where?)
Checking a recent Mono in to my GIT repo.
Suggestions?
If you're going to use something higher than what standard distro packages provide, I recommend you to go all the way and not use unstable 2.11.x series, but official/beta 3.x ones.
So, grab yourself some preview Debian/Ubuntu 3.0.6 packages from this PPA:
http://www.meebey.net/posts/mono_3.0_preview_debian_ubuntu_packages/
The best way I've found to get a full up to date mono environment is to use an OS X travis profile
language: objective-c
before_install:
# Make sure mono is installed,
- wget http://download.mono-project.com/archive/3.0.10/macos-10-x86/MonoFramework-MDK-3.0.10.macos10.xamarin.x86.dmg
- hdid MonoFramework-MDK-3.0.10.macos10.xamarin.x86.dmg
- sudo installer -pkg "/Volumes/Mono Framework MDK 3.0.10/MonoFramework-MDK-3.0.10.macos10.xamarin.x86.pkg" -target /
install:
- xbuild Source/Pash.sln