Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top