msbuild-task
MSBuild builds defaults to debug configuration
That depends on the contents of that buildscript. Visual Studio C# uses the parameter Configuration to switch between Release and Debug. Not buildmode. You might want to try the following: msbuild LP.sln /p:Configuration=Release
Return output from an MsBuild task?
Use a property or an item. Your MSBuild that calculates the path, return it as a property and you use this property as input for your other task. public class CalculatePathTask : ITask { [Output] public String Path { get; set; } public bool Execute() { Path = CalculatePath(); return true; } } <Target Name=”CalculateAndUsePath”> … Read more
how to replace string in file using msbuild?
This is no longer required… you can now inject C# into the project/build file… Define a custom task and parameters as follows: <UsingTask TaskName=”ReplaceFileText” TaskFactory=”CodeTaskFactory” AssemblyFile=”$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll”> <ParameterGroup> <InputFilename ParameterType=”System.String” Required=”true” /> <OutputFilename ParameterType=”System.String” Required=”true” /> <MatchExpression ParameterType=”System.String” Required=”true” /> <ReplacementText ParameterType=”System.String” Required=”true” /> </ParameterGroup> <Task> <Reference Include=”System.Core” /> <Using Namespace=”System” /> <Using Namespace=”System.IO” /> <Using … 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)
What is the difference between a PreBuildEvent, BeforeBuild target and BeforeCompile target in MSBuild?
The answer to this question can be found in the Microsoft.Common.targets file which can be found (depending on wether you’re using the 64-bit or 32-bit framework) at: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.target for 64-bit and C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets for the 32-bit runtime. This file defines all the steps a build of your project undergoes. Quoting the source: <!– ============================================================ Build The … Read more
MSBuild Task syntax for deleting files
You can delete the files in those directories first and then the dir itself with <Target Name=”SomeTarget”> <ItemGroup> <FilesToDelete Include=”Path\To\Obj\**\*”/> </ItemGroup> <Delete Files=”@(FilesToDelete)” /> <RemoveDir Directories=”Path\To\Obj\” /> </Target>
How get exec task output with msbuild
Good news everyone! You can now capture output from <Exec> as of .NET 4.5. Like this: <Exec … ConsoleToMSBuild=”true”> <Output TaskParameter=”ConsoleOutput” PropertyName=”OutputOfExec” /> </Exec> Simply: Add ConsoleToMsBuild=”true” to your <Exec> tag Capture the output using the ConsoleOutput parameter in an <Output> tag Finally! Documentation here