Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure MSBuild to do some tasks only on release builds?

I just learned about how to include FxCop on a build. But it's slow and I want it to be done just only on release builds. Is there any way to configure that?

like image 664
Jader Dias Avatar asked Feb 10 '09 11:02

Jader Dias


People also ask

How do you build specific targets in solutions using MSBuild exe?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

How do you exclude a project from a build?

On the menu bar, choose Build > Configuration Manager. In the Project contexts table, locate the project you want to exclude from the build. In the Build column for the project, clear the check box. Choose the Close button, and then rebuild the solution.

Will MSBuild compile without any target?

If MSBuild determines that any output files are out of date with respect to the corresponding input file or files, then MSBuild executes the target. Otherwise, MSBuild skips the target. After the target is executed or skipped, any other target that lists it in an AfterTargets attribute is run.

Which tasks in MSBuild can be used by developers in code with MSBuild?

MSBuild includes common tasks that you can modify to suit your requirements. Examples are Copy, which copies files, MakeDir, which creates directories, and Csc, which compiles Visual C# source code files.


1 Answers

Check the configuration condition.

<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release' ">    <FxCop TargetAssemblies="@(OutputAssemblies)"        RuleLibraries="@(FxCopRuleAssemblies)"         DependencyDirectories="$(MSBuildCommunityTasksPath)"        FailOnError="False"        ApplyOutXsl="True"        OutputXslFileName="C:\Program Files\Microsoft FxCop 1.32\Xml\FxCopReport.xsl"        DirectOutputToConsole="true"/> </Target> 
like image 147
Julien Hoarau Avatar answered Sep 28 '22 12:09

Julien Hoarau