DEV Community

Cover image for Using .NET 5 with Rider on Linux
Antonio Falcão Jr.
Antonio Falcão Jr.

Posted on • Updated on

Using .NET 5 with Rider on Linux

A simple and quick approach to use .NET 5 Preview with JetBrains Rider on Linux.

Before install is important to check .NET 5 - Supported OS versions

Installing

1 - Create a directory to use for the download location and change into that directory, for example:

mkdir $HOME/dotnet_install && cd $HOME/dotnet_install
Enter fullscreen mode Exit fullscreen mode

2 - Download the shell script with instructions:

curl -H 'Cache-Control: no-cache' -L https://aka.ms/install-dotnet-preview 
-o install-dotnet-preview.sh
Enter fullscreen mode Exit fullscreen mode

3 - Run the script to begin the install:

sudo bash install-dotnet-preview.sh
Enter fullscreen mode Exit fullscreen mode

The last step will download and unzip all packages and dependencies into dotnet_packages/ and then start the installation.

But if the environment is not "clean", it is possible that packages conflicts happen. In this case, the script will stop the execution, then we can do the installations manually, solving or replacing dependencies on conflicts.

cd dotnet_install

ls -l
  dotnet-5.0.0-preview.5-rpm.tar.gz  
  dotnet_packages/  
  install-dotnet-preview.sh
Enter fullscreen mode Exit fullscreen mode

Use package manager of your preference, and install all the SDK's, Runtimes, and dependencies packages. In this example, we decided to replace files:

cd dotnet_packages

ls -l
  aspnetcore-runtime-5.0.0-preview.5.20279.2-x64.rpm
  aspnetcore-targeting-pack-5.0.0-preview.5.20279.2.rpm
  dotnet-apphost-pack-5.0.0-preview.5.20278.1-x64.rpm
  dotnet-host-5.0.0-preview.5.20278.1-x64.rpm
  dotnet-hostfxr-5.0.0-preview.5.20278.1-x64.rpm
  dotnet-runtime-5.0.0-preview.5.20278.1-x64.rpm
  dotnet-runtime-deps.rpm
  dotnet-sdk-5.0.100-preview.5.20279.10-x64.rpm
  dotnet-targeting-pack-5.0.0-preview.5.20278.1-x64.rpm
  netstandard-targeting-pack-2.1.0-x64.rpm

sudo rpm -i --replacefiles netstandard-targeting-pack-2.1.0-x64.rpm
Enter fullscreen mode Exit fullscreen mode

OR

If you prefer an isolated environment and a more simple setup, you can install it using Snap.

If the dotnet CLI already installed, it's recommended to use an alias to differentiate the versions:

sudo snap alias dotnet-sdk.dotnet dotnet5
Enter fullscreen mode Exit fullscreen mode

And then you can use it this way:

dotnet5 restore

dotnet5 build

...
Enter fullscreen mode Exit fullscreen mode

For more instructions or ways to install SDK/Runtime, use this documentation.

Rider settings

If .NET 5 was installed into the default path, then Rider will detect the MSBuild version 16.0 automatically.

But, if it was in a different folder, as Snap installation, for example, it's necessary to inform .NET Core CLI executable and MSBuild version 16.0 on Rider settings, like this:

If other versions are installed, it may be necessary to change the SDK version in global.json to 5, allowing Rider to automatically detect MS Build 16.

{
  "sdk": {
    "version": "5.0.100-preview.5.20279.10"
  }
}
Enter fullscreen mode Exit fullscreen mode

Projects settings

Now, we can build applications using preview version from .NET 5 just indicating on C Sharp Project (*.CSPROJ) file the respective versions from framework and language:

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <LangVersion>preview</LangVersion>
    </PropertyGroup>

</Project>
Enter fullscreen mode Exit fullscreen mode

Until this moment, Rider's version 2020.1 does not give support for C# 9 syntax and code inspections, so to use new features is necessary flexibility the code inspections.

Enjoy!

Antônio Falcão Jr. 👋

B.Sc & M.Sc student in Computer Science,
Software Architecture Specialist,
Staff Software Engineer.







Top comments (0)