I have an issue with compilation of SSDT SQL Server Database Project by using Visual Studio 2015. I want to use C# 6 features inside my database project, but it seems like it is unsupported. For example, I have added the next class in my db project:
namespace Database1
{
class ClassFile1
{
public string Str { get; } = string.Empty;
}
}
I have tried to compile this, but I got the error:
CS1519: Invalid token '=' in class, struct, or interface member declaration
I have found out that the reason of this error is wrong version of compiler that used by VS 2015. The next compilation line is generated by VS:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /preferreduilang:en-US /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\mscorlib.dll" /debug+ /debug:full /optimize- /out:obj\Debug\Database2.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output ClassFile1.cs
As you can see, C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe is used and it is wrong.
I have tried compile db project from Developer Command Prompt for VS 2015 and this was done successfully, because inside this prompt csc.exe is Roslyn compiler (C:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe) that support C# 6 features. You can check question How to run Roslyn instead csc.exe from command line?
I tried to compile the project by using MSBuild 14.0 and it was successfully done too.
The question is: how can I change/override version of compiler that my VS used for compilation of SSDT DB project from old C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe to new Roslyn compiler (C:\Program Files (x86)\MSBuild\14.0\Bin\csc.exe)?