I have following ps script:-
function buildVS
{
param
(
[parameter(Mandatory=$true)]
[String] $path,
[parameter(Mandatory=$false)]
[bool] $nuget = $true,
[parameter(Mandatory=$false)]
[bool] $clean = $true
)
process
{
$msBuildExe = 'C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe'
if ($nuget) {
Write-Host "Restoring NuGet packages" -foregroundcolor green
nuget restore "$($path)"
}
if ($clean) {
Write-Host "Cleaning $($path)" -foregroundcolor green
& "$($msBuildExe)" "$($path)" /t:Clean /m
}
Write-Host "Building $($path)" -foregroundcolor green
& "$($msBuildExe)" "$($path)" /t:Rebuild /m:4 /p:BuildInParallel=true /langversion:7.2
}
}
buildVS .\Backend\Backend.sln $false $true
I can successfully build it by the IDE. I have c# Language version set in my project as 7.2.
I don't know how to set c# language version by command line compiler. I get following error:-
CSC : error CS1617: Invalid option '7.2' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 6. [C:\dev\Backend\source\dev.csproj] 2>Done Building Project "C:\dev\Backend\source\dev.csproj" (Rebuild target(s)) -- FAILED. 1>Done Building Project "C:\dev\Backend\Backend.sln" (Rebuild target(s)) -- FAILED.
Build FAILED.
"C:\dev\Backend\Backend.sln" (Rebuild target) (1) -> "C:\dev\Backend\source\dev.csproj"
(Rebuild target) (2) -> (CoreCompile target) -> CSC : error CS1617: Invalid option '7.2' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 6. [C:\dev\Backend\source\dev.csproj]
0 Warning(s) 1 Error(s)
I am trying to minimize the compile time by the script. I have 7/8 solution to build. It is really time-consuming to do it by IDE. If I can build one solution successfully by the script, I will call the same script function with other solutions.