I am trying to compile the code for my MVC application via MSBuild.exe
. I was getting errors before, but thanks to this answer, I know what the issue is.
I was using the wrong version of MSBuild.exe
Now that I know what version I should be using, my psake script won't work, I'm not sure how I can target the MSBuild.exe
that sits here
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe
My psake Compile
task now looks like this, but VS is telling me the syntax is wrong on line 7.
task Compile `
-description "Compile the code" `
-requiredVariables $solutionFile, $buildConfiguration, $buildPlatform, $tempOutputDirectory `
-depends Init {
Write-Host $compileMessage
Exec {
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe" $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutputDir=$tempOutputDirectory"
}
}
When I had the below, VS 2017 doesn't complain about the syntax, but I get the WebApplication.targets
error when running the build script, and that must be because the wrong version of MSBuild is being used.
task Compile `
-description "Compile the code" `
-requiredVariables $solutionFile, $buildConfiguration, $buildPlatform, $tempOutputDirectory `
-depends Init {
Write-Host $compileMessage
Exec {
msbuild $solutionFile "/p:Configuration=$buildConfiguration;Platform=$buildPlatform;OutputDir=$tempOutputDirectory"
}
}