msbuild
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
How to run tasks in parallel in MSBuild
Try the new parallel task in the MSBuild Extension Pack – http://mikefourie.wordpress.com/2012/02/29/executing-msbuild-targets-in-parallel-part-1
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
How do I fix MSB3073 error in my post-build event?
Playing around with different project properties, I found that the project build order was the problem. The project that generated the files I wanted to copy was built second, but the project that was running the batch file as a post-build event was built first, so I simply attached the build event to the second … 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("%(Filename)").Replace(".config",""))’)” /> … Read more
Is there any MSbuild task to check if a string contains another string (similar to string.contains)
If you use MSBuild 4, you could use Property function <Import Project=”A.proj” Condition=”$(BuildDefinition.Contains(‘Dist Staging to Dev’))”/> (More info on Property function)
.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
What does two asterisks together in file path mean?
\**\ This pattern is often used in Copy Task for recursive folder tree traversal. Basically it means that all files with extension config would be processed from the all subdirectories of $(Services_Jobs_Drop_Path) path. MSDN, Using Wildcards to Specify Items: You can use the **, *, and ? wildcard characters to specify a group of files … Read more