I Created a Powershell script for deploying my web application following Scott Guthrie's example explained here Automate Everything (Building Real-World Cloud Apps with Azure) Which uses this MSBuild invocation to build and publish the web app
& "$env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" $ProjectCsproj `
/p:VisualStudioVersion=12.0 `
/p:DeployOnBuild=true `
/p:PublishProfile=$PublishXmlFile `
/p:Password=$Password
As you can see this sample assumes .Net framework version 4.0.30319 and will fail for other versions (or in the future .Net installations)
Is there a way to run this MSBuild command without assuming any specific .Net version ?
You might desire to find the required .NET builder from Powershell itself, since it has enough instruments in basic command set. There can be tricks if you'd use another version of .NET Framework to build your project, such as absent or obsolete/deprecated classes, properties, methods, or possibly the changes in syntax or class dependencies that will make your project unable to be built correctly under a new .NET version. You can, however, try enumerating builders and find the one that's closest to v4.0.30319. An example:
This will display available
MSBuild.exe
filenames that can qualify to build your project. Then you parse forFramework
andFrameWork64
to get either a 64-bit or a 32-bit builder, then select from the list by whatever algorithm you fancy. (I doubt it that you'll need this trick ever.)