2

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"
        }
}
J86
  • 14,345
  • 47
  • 130
  • 228
  • I just dealt with this myself. I never was able to get it working by targeting a specific instance of MSBuild but adding `Framework "4.5.1"` (replace with your framework version) to the top of my build script magically made everything work. That does not answer your question but maybe that will at least get you up and running. – Jason Boyd Jul 30 '17 at 21:36

0 Answers0