Adding extra files for MSBuild Deployment

Adding extra files/folders for a MSBuild Deployment that aren't referenced by your project file can be done by adding a target. In this case it is named CustomCollectFiles

MyProject.csproj

<Target Name="CustomCollectFiles">
    <Message Text="Collecting extra files" />
    <ItemGroup>
      <_CustomFiles Include="assets\js\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>assets\js\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
    <Message Text="Finish collecting extra files" />
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>
comments powered by Disqus