Publish Profile Copy Files To Relative Destination

Viewed 3070

I have a publish profile in visual studio 2017 I am trying to copy files from another project. No issues doing so when going to a simple relative directory. However, have a problem with the double recursion going on in the source, making it harder to determine the desired directory.

Source directory: $(MSBuildThisFileDirectory)..\..\..\..Foundation\**\App_Config\**\* gets me the relevant files.

Goes to: <DestinationRelativePath /> using %(RecursiveDir)%(Filename)%(Extension)

Which deploys to: \**\App_Config\**\*.

Not to my desire: \App_Config\**\*

I am missing the trick what ever I place in the <DestinationRelativePath> won't deploy to my desired location. Where am I going wrong? Or is this not possible?

<PropertyGroup>      
    <PipelineCollectFilesPhaseDependsOn>
        GetFoundationConfigFiles;
        GetProjectConfigFiles;
        $(PipelineCollectFilesPhaseDependsOn);
    </PipelineCollectFilesPhaseDependsOn>
</PropertyGroup>

<Target Name="GetFoundationConfigFiles">
    <Message Text="Inside of GetFoundationConfigFiles" Importance="high"/>
    <ItemGroup>
        <_CustomFiles Include="$(MSBuildThisFileDirectory)..\..\..\..\Foundation\**\App_Config\**\*" />
        <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>App_Config\Include\%(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>

<Target Name="GetProjectConfigFiles">
    <Message Text="Inside of GetProjectConfigFiles" Importance="high"/>
    <ItemGroup>
        <_CustomFiles1 Include="$(MSBuildThisFileDirectory)..\..\..\..\Feature\**\App_Config\**\*" />
        <FilesForPackagingFromProject Include="%(_CustomFiles1.Identity)">
            <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>
2 Answers
Related