custom "build" task

Hello

I'm sorry but i'm new to custom msbuilds, so i hope my question is not too stupid .

I created 2 custom configurations. so now i do have the following configurations :

- Debug

- Release

- Make X

- Make Y

when i "build" with the "Make X" configuration selected, it will call the Target "PerformX", when i "build" with the "Make Y" configuration selected, it will call the Target "PerformY", when i "build" with the "Debug" configuration selected, it will call normal debug process etc..

Also, i don't want that my "MakeX" configuration builds anything, i want to perform other tasks...

So i found this :

<Project DefaultTargets="Build;DoX;DoY" ...

Then on the targets :


<Target Name="DoX" Condition=" '$(Configuration)' == 'ConfX' ">
<Message Text="i do X" Importance="high" />
</Target>


<Target Name="DoY" Condition=" '$(Configuration)' == 'ConfY' ">
<Message Text="i do Y" Importance="high" />
</Target>

But my problem is to avoid executing DoX and DoY when i build...

i tryed this:


<Target Name="Build" Condition=" '$(Configuration)' != 'ConfX' and '$(Configuration)' != 'ConfY' ">
<Message Text="i'mbuilding" Importance="high" />
</Target>

But the problem is as i override "Build", i loose the build actions.... what should i add into "Build" Target to get the normal build target (you see, when you don't add the "build" target, the normal way it builds) ?

any help would be apprecieted.

[1961 byte] By [wonderliza] at [2008-1-7]
# 1

or if there is a way to say :

Configuration "Debug" => normal build, no target X, no target Y

ConfigurationX => target X, no build

ConfigurationY => target Y, no build

i take it too Smile

wonderliza at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 2

When you create your own new target called “Build”– regardless of the condition it will still overwrite the default “Build” target defined in Microsoft.Common.Targets and you will lose the functionality of what the default “Build” target does. What you most likely want to do is to overwrite the BuildDependsOn property based on the condition like - (at the end of the project file)

<PropertyGroup>

<BuildDependsOn Condition=”’$(Configuration)’ == ‘ConfigX’”>DoX</ BuildDependsOn>

<BuildDependsOn Condition=”’$(Configuration)’ == ‘ConfigY’”>DoY</ BuildDependsOn>

</PropertyGroup>

As the “Build” target itself does not do anything but depends on other targets like “CoreBuild” which does the actual build.

The other thing that I should also point out - you may still get an error and the end of the build when building ConfigX or ConfigY. This is because it will try to copy the intermediate files to the output directory and since there are none it will error. To workaround this you may have to write dummy files as we cannot do the same as above with “CopyFilesToOutputDirectory” target since this target actually does the copy work.

Jay Shrestha

(Jaysh@microsoft.com)

JayShrestha at 2007-10-2 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...

Visual Studio

Site Classified