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

Replicate VS2008 “Publish Web Site” from command line

The following command duplicates the Publish Web Site dialog with default settings. Command for Publish Web Site with Default Settings aspnet_compiler -nologo -v / -p “C:\WebSite1” -u “C:\TargetPath” Reference 1) See Community Content titled You want Publish a site but you have not Visual Studio then… at http://msdn.microsoft.com/en-us/library/20yh9f1b(classic).aspx. Microsoft Visual Studio 2005 > Visual Studio … 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

.csproj multiple hint paths for an assembly

The simplest way since only ONE HintPath can be used is to use the all-so-nice Condition attribute like this: <Reference Include=”TheAssembly”> <HintPath Condition=”Exists(‘..\My\Assembly\Path’)”>..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\My\Assembly\Path’)”>..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\My\Assembly\Path’)”>..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\..\My\Assembly\Path’)”>..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\..\..\My\Assembly\Path’)”>..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\..\..\..\My\Assembly\Path’)”>..\..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\..\..\..\..\My\Assembly\Path’)”>..\..\..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> etc… </Reference> So the answer to the question would be this: <Reference Include=”assembly”> <HintPath Condition=”Exists(‘..\..\csharp\bin’)”>..\..\csharp\bin\assembly.dll</HintPath> <HintPath Condition=”Exists(‘..\..\..\..\foo\sdk\csharp\bin’)”>..\..\..\..\foo\sdk\csharp\bin\assembly.dll</HintPath> </Reference> If multiple … Read more