Search code examples
visual-studio-2010msbuildmsbuild-taskcsprojmsbuild-target

Run other than the DefaultTarget for a project configuration under Visual Studio 2010


I've a MSBuild target in my csproj to copy files and folders of my web application to a target path after build.

<Target Name="PublishToFileSystem" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
...

If I call MSBuild via command line with the target "PublishToFileSystem" everything works fine.

But now I want to "use" this target also for a special configuration in Visual Studio (like Release, Debug, ...).

How can I assign a configuration to another target than the DefaultTarget "Build" set in the project with DefaultTargets:

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Thanks, Konrad


Solution

  • Try to use AfterBuild target instead of PublishToFileSystem:

    <Target Name="AfterBuild" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    

    or check Overriding Predefined Targets on MSDN