MSBUILDEMITSOLUTION not working with .NET 4?

Set MSBuildEmitSolution=1 and then build from the command line. You should then see a MySolution.sln.metaproj file near MySolution.sln. Notes: If you open a command prompt window, then set the env var via System Settings, you will have to open a new command prompt. You’d think you could also use msbuild /p:MSBuildEmitSolution=1, but you can’t.

Build MSBuild target without dependencies

I would like to reiterate @EMP’s solution (and I can’t vote him up due to my puny reputation). The correct way to avoid MSBuild’s default behavior of rebuilding all the dependencies listed in the project file is to set the BuildProjectReferences property to false. In his answer he invokes MSBuild from within an MSBuild script; … Read more

_CopyWebApplication with web.config transformations

I’ve been hitting my head against the wall for this. After hiking through the MSBuild targets I’ve come across something very “opaque”. Long story short: Try using the new _WPPCopyWebApplication. It works on my machine. The old _CopyWebApplication does not support transformations for legacy reasons. This is what I do: msbuild /t:Rebuild /p:OutDir=..\publish\;Configuration=Release;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False MvcApplication1\MvcApplication1.csproj # … Read more

In MSBuild, can I use the String.Replace function on a MetaData item?

You can do this with a little bit of trickery: $([System.String]::Copy(‘%(Filename)’).Replace(‘config’,”)) Basically, we call the static method ‘Copy’ to create a new string (for some reason it doesn’t like it if you just try $(‘%(Filename)’.Replace(‘.config’,”))), then call the replace function on the string. The full text should look like this: <Target Name=”Build”> <Message Text=”@(Files->’$([System.String]::Copy(&quot;%(Filename)&quot;).Replace(&quot;.config&quot;,&quot;&quot;))’)” /> … Read more

AfterPublish target not working

Note: The following applies to VS2010 and publishing web-application projects with the “Web Deploy” publish method selected in the ‘Build/Publish {projectname}’ dialog. Julien Hoarau’s correct in that “Publish” is NOT the name of the msbuild target invoked in the above case; the actual target name is “MSDeployPublish”. Therefore, you have to define a “Target” element … Read more