Visual Studio Post Build event - xcopy for another relative directory

Basically I want to use a wildcard for a directory.

The post build event is located in the PageComponents project:

PageComponents
    WidgetTemplates
        WidgetTemplate1
            Usercontrol1
        WidgetTemplate2
            Usercontrol2

And I want to copy all the custom controls to the web project, but to a different relative location:

Web
    CtrlPresentation
        Usercontrol1
        Usercontrol2

I tried to substitute the WidgetTemplates directory:

xcopy "$(ProjectDir)WidgetTemplates\*\*.ascx" "$(SolutionDir)Client.Web\CtrlPresentation" /y /s

But this fails. So, I tried the following:

xcopy "$(ProjectDir)WidgetTemplates\*.ascx" "$(SolutionDir)Client.Web\CtrlPresentation" /y /s

But this also copies every single WidgetTemplate folder.

Is there a way to achieve what I am trying to do?

+3


source to share


1 answer


Try to use the task.

<ItemGroup>
    <MySources Include="$(ProjectDir)WidgetTemplates\**\*.ascx" />
</ItemGroup>
<Target Name="CopyOver">
    <Copy SourceFiles="@(MySources)" DestinationFiles="@(MySources->'$(SolutionDir)Client.Web\CtrlPresentation\%(FileName)%(Extension)')">
</Target>

      



and use this target after build

<BuildDependsOn>
    $(BuildDependsOn);
    CopyOver
</BuildDependsOn>

      

0


source







All Articles