Simon Boudrias
Simon Boudrias

Reputation: 44589

visual studio publish build generated files

During the build process, some files are generated by the system (concatenated, minified and versionned assets).

As these files are created on the fly, they're not added to the project, so when I publish, visual studio don't copy them.

Is there a way to tell VS to copy all files inside a folder?

Upvotes: 0

Views: 670

Answers (1)

Simon Boudrias
Simon Boudrias

Reputation: 44589

Been able to resolve the issue by manually editing the .csproj file and adding those lines:

<PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForPackageDependsOn>
    <CopyAllFilesToSingleFolderForMsdeployDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
  </CopyAllFilesToSingleFolderForMsdeployDependsOn>
  </PropertyGroup>
  <Target Name="CustomCollectFiles">
    <ItemGroup>
      <_CustomFiles Include="public\form\dist\*.js" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>public\form\dist\%(Filename)%(Extension)</DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>
</PropertyGroup>

Upvotes: 1

Related Questions