31

Further to this question, I have lots of projects inside a solution and I dont want to create a dotsettings file for each project. Can anyone help me set the C# Language Level on a solution level.

This is relevant for me as I downloaded VS2015 today and ReSharper is offering me useful refactor suggestions based on targeting C# 6 and my projects are using C#5.

Community
  • 1
  • 1
Christo
  • 2,330
  • 3
  • 24
  • 37
  • Have you tried setting the language version for the project in Visual Studio? Go to project properties -> Build -> Advanced... -> Language Version – Paulo Morgado Jul 22 '15 at 23:30

2 Answers2

38

I added below settings in .sln.DotSettings

<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp50</s:String>

This line was added to .csproj.DotSettings when I tried to disable c#6 for a particular project. After adding this line in .sln.DotSettings resharper is reporting an error whenever I am trying to use c# 6.0 feature.

Nikita B
  • 3,303
  • 1
  • 23
  • 41
harishr
  • 17,807
  • 9
  • 78
  • 125
  • 1
    this worked great thanks. problem resolved. please refer to this gist for my final dotsetting file. https://gist.github.com/chris-brown/b47ea61ef2c93af50bee – Christo Jul 24 '15 at 08:41
  • Can be applied at project level, solution level, or user level, which is at `%APPDATA%\JetBrains\Shared\vAny\GlobalSettingsStorage.DotSet‌​tings` – Nigel Touch May 03 '17 at 19:37
  • It's also possible to set for each project in solution the C# language version via `Project Properties > Build tab > Advanced...` and ReSharper will detect it by it's own and avoids to suggest greater than configure language features. It is mor eto configure but you will ensure that nobody without ReSharper can use language version features above your defined one. – ChW Nov 15 '17 at 08:05
9

According to Jetbrains documentation about C# default version, you can specify the target C# version explicitly by selecting the project in the Solution Explorer and using the C# Language Level property in the Visual Studio's Properties window.

Afshin
  • 151
  • 1
  • 3
  • Please post relevant section here. – Raúl Mar 08 '16 at 07:35
  • from the link ... "you can specify the target C# version explicitly by selecting the project in the Solution Explorer and using the C# Language Level property in the Visual Studio's Properties window (choose View | Properties Window in the menu). " - it is not the project's properties as in right-click the project, properties. – CAD bloke Oct 14 '17 at 10:58