I was doing modification of MSBuild target https://github.com/MNF/OctoPack.Precompile/blob/master/Source/OctoPack.Precompile.targets to have different behavior depending on parameter OutDir was specified or not for Msbuild.
Follow to MSDN “MSBuild Conditional Constructs” I selected Choose Element and tried to put it inside <Target> element
<Target Name=”foo” />
It didn’t work as for Choose Element allowed Parents are only Project, Otherwise, When.
I tried other way to include Target inside Choose/When element, but it is also not allowed, because Target also should be direct child of Project.
I found an implementation in http://stackoverflow.com/questions/30904741/msbuild-now-to-conditionally-use-one-of-two-targets-with-same-name when you set target depends on other targets and each child target has different conditions:
<Target Name=”foo” DependsOnTargets=”_fooDebug;_fooRelease”/>
<Target Name=”_fooDebug” Condition=”‘$(Configuration)’ == ‘Debug’ “
Later I found in http://stackoverflow.com/questions/2284389/how-do-you-stop-msbuild-execution-without-raising-an-error/ that CallTaget elements with condition can be used as well:
I beleive that MSDN “MSBuild Conditional Constructs” documentation should provide reference to all such options.