Until now I’ve been getting by right enough running .net version 6.0 on Ubuntu.
However, today I wanted to use raw string literals, aka
""" quoted multi line strings:
This involved installing .net 7.0 on Ubuntu, which was pretty easy honestly:
wget https://packages.microsoft.com/config/ubuntu/22.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb rm packages-microsoft-prod.debCode language: Shell Session (shell)
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0 aspnetcore-runtime-7.0Code language: Shell Session (shell)
With that done:
➜ ~ dotnet -v Welcome to .NET 7.0! --------------------- SDK Version: 7.0.102Code language: Shell Session (shell)
I then restarted Rider, and saw that it had picked up the change:
The problem was that the text remained underlined in red, and I was still seeing the error:
Feature ‘raw string literals’ is not available. Please use language version 11.0 or greater.
This led me to the JetBrains docs, which didn’t solve my problem:
To set the C# version for all projects in your solution, specify it in a Directory.Build.props file in your solution directory as described hereJetBrains Rider docs: Change language version
The reason the text remains red underlined is because whilst you have updated the dotnet runtime to v7, the project you had the issue with remains at whatever version of dotnet it was previously using.
So here I’m building for dotnet 5.0:
The fix is to right click on your project name, and select Properties:
That pops up another box where you need to click on Target framework:
And then select the version of C# that gives access to the language version that matches the one the prompt was asking for. In my case, that’s dot net 7.0 / net7.0:
With that done, you should be able to select a newer language version, such as C# v11:
Press the big blue OK button, and your problem should be resolved: