Using new C# 7 tuple

I have read the blog from Microsoft who explain the new feature of C#

https://blogs.msdn.microsoft.com/dotnet/2017/03/09/new-features-in-c-7-0/

For my experiment I would like use the new c# tuple on a MVC project build on .Net Framework 4.6.2

For this after some google time I have discovered the need of:

Add NUGET package System.ValueTuple

Add NUGET pakage Microsoft.CodeDom.Providers.DotNetCompilerPlatform

All works when use the designer all works fine but when I try to build my MVC project I receive the error :

CS0012: The type ‘System.Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

So I’m looking and the solution is:

Update the NUGET package Microsoft.Net.Compilers to version 2.0.1

After that you need to tell Visual Studio 2017 use c# 7. To do that right click on the project, select properties.

VS2017ProjectProperties

Go to the menu on the right of the properties windows and chose Build. Scroll down and on the bottom right of the windows click on the button “Advanced…”

Now you can choose the language version:

VS2017ProjectPropertiesBuildAdvanced

 

Leave a comment