Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I control which version of an msbuild file is used between .NET4 and 4.5RC?

On my development laptop I have only VS2012 RC installed, and I am successfully able to hook into the new MSDeploy .pubxml plumbing (DeployOnBuild and PublishProfile settings) from powershell (via psake) to deploy my web site to our test server.

However, on my build server, I initially had VS2010 SP1 installed, and I've now additionally installed the 2012 RC (I have other builds on this machine that are still .NET 4).

When running the same script with exactly the same parameters, I see different results between my dev machine and the build server. The command I'm running is

exec { msbuild "Website\WebSite.csproj" /m p:DeployOnBuild=True /p:PublishProfile=MyTestProfile }

On the build server, this does not in fact trigger MSDeploy, but simply the packaging bits that zip the site up and makes a deployment package. My machine successfully picks the pubxml file up and does a successful deployment.

Eventually, I believe I've traced the problem to the file Microsoft.Web.Publishing.targets. On my dev machine I have only

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web

but the server additionally has

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\Web

and it seems like this file (without knowledge of the .pubxml stuff) is what's being used there.

Has anybody got any idea what I need to twiddle (preferably within my own msbuild files so I don't screw up anything else on the build server for the 4.0 builds) to get msbuild to pick up the v11.0 version of the file and thereby use my .pubxml file?

like image 826
Terence Lewis Avatar asked Jun 07 '12 17:06

Terence Lewis


1 Answers

That is interesting it should be picking up the latest (v11.0), seems like there is a bug here . This is controlled by the MSBuild property VisualStudioVersion.

Here are the rules for how this value is populated at build time. 1. If VisualStudioVersion is defined as an environment variable or a global property (e.g. /p: on the command line) that wins. This is how Dev11 & the Dev11 command prompt are always v11 – they both define VSV as an environment variable 1. Otherwise, if there is a sub-toolset that matches the equivalent solution version (which is currently always file format version – 1), choose that 1. Otherwise, get the default version; 10.0 if Dev10 is installed, Highest-versioned sub-toolset version installed (currently always 11) otherwise

In your case since you are running into an issue you can pass in the property /p:VisualStudioVersion=11.0 to ensure that the correct targets are used.

like image 153
Sayed Ibrahim Hashimi Avatar answered Sep 29 '22 09:09

Sayed Ibrahim Hashimi