After Publish Copy event in VS2019, same functionality as post build event

Viewed 553

I'm trying to copy a folder of template files (about 9 thousand files and ~1gb) that are used by my .net web application to the publish output directory when publishing through VS2019. I have a Post Build script in there to copy them to output when it builds(Works when building locally), but this step seems to get skipped when the files are copied for publishing.

Any ideas how I can add these files so that they get published with rest of application? its a large amount of files so when I tried adding them into VS and change "Copy to output always" VS crashes.

1 Answers

Microsoft has some documentation here about modifying the publish profile to pickup and deploy extra files. Essentially add this to your .pubxml file for the specific publish profile and extra files will be copied.

<Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="..\ExtraFiles\**\*" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
  <PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>

    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForMsdeployDependsOn);
    </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>

https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/deploying-extra-files

Related