How do you include build outputs as additional files using web deploy (MSDEPLOY)?

StackOverflow https://stackoverflow.com/questions/23235294

  •  07-07-2023
  •  | 
  •  

سؤال

I have a web project that has a post-build event that produces some minified files. Assume for the moment that this needs to remain a post- build event, and cannot be changed into a pre-build event.

I have successfully used a .wpp.targets file to package additional files:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
    <PropertyGroup>
        <SourceRoot>$(BuildDirectory)\Sources\Web</SourceRoot>
    </PropertyGroup>
    <ItemGroup>
        <FilesForPackagingFromProject Include="$(SourceRoot)\ExtraScripts\Normal.js">
            <DestinationRelativePath>Scripts\%(RecursiveDir)%(FileName)%(Extension)</DestinationRelativePath>
            <FromTarget>Web.wpp.targets</FromTarget>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Project>

Unfortunately, this fails when I do the same thing for the files produced by the post-build step. This is because the CopyAllFilesToSingleFolderForMsdeploy target executes before the build. Even before the PrepareForBuild target.

Is there a way to add extra files and folders to the deploy package when they are produced during the build?

هل كانت مفيدة؟

المحلول

There was a similar question before (Add Plugin DLL in MVC 4 Website after publish).

You can deploy files only if they have been a part of your project before.

What we usually do is that we include those files as dummy files in our project and overwrite them during the build process. Because those files are part of your project, this approach will publish those files.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top