microsoft / dotnet

This repo is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
https://devblogs.microsoft.com/dotnet/
MIT License
14.34k stars 2.21k forks source link

4.7.2 and VS2013 issue with string interpolation #754

Open StewUK opened 6 years ago

StewUK commented 6 years ago

Hi

We're still using VS2013 here. And I'm getting

Unexpected character '$' when trying to compile a 4.7.2 project developed in VS2017.

It's to do with string interpolation.

throw new Exception($"Blah blah {name}");

Any pointers? Or is VS2013 now deprecated?

Thanks

svick commented 6 years ago

String interpolation is a C# 6.0 feature. VS2013 only supports C# 5.0, so it's not surprising the code doesn't compile.

Is there anything preventing you from upgrading to VS2017?

StewUK commented 6 years ago

Cost benefit mostly.

10 environments to upgrade is a significant cost to a small business for the benefit. Personally, I'd do it in a flash.

Thanks anyway for the information :)

0xfeeddeadbeef commented 6 years ago

@StewUK You can install Microsoft.Net.Compilers package into your project and be able to compile interpolated strings, but syntax highlighting and IntelliSense will be broken.

dasMulli commented 6 years ago

Do note that recent versions of Microsoft.Net.Compilers require MSBuild 15.

You could also use JetBrains' MSBuild distribution to get all the necessary bits without needing any VS license (when you can't use Community and Build Tools require that you have a license).

You can also use VS Code with the C# extension to get an editing experience.