Master pages missing from Web Deployment Project output
-
06-07-2019 - |
Question
We seem to be having an issue when running our deployment project in that, when it compiles, it seems to miss our master pages from the output.
Is there any way to 'force' the project to include .master files, either through editing the .wdproj file, or via another method?
Also, I've been reading up on the MSBuildTasks community project, and have followed some of the sample documentation but this doesn't appear to work. The project won't exclude files that I select, and doesn't seem to do compression either. Has anyone else tried this extension that can provide feedback/guidance?
Many thanks in advance
Update:
I have fixed this by creating an Itemgroup and doing a copy.
<ItemGroup>
<MasterFiles Include="$(SolutionDir)\MVC\Views\Shared\Templates\**\*.master" />
</ItemGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(MasterFiles)" DestinationFiles="$(OutputPath)\Views\Shared\Templates\%(RecursiveDir)%(Filename)%(Extension)" />
</Target>
Solution
One problem that I've noticed with Web Deployment Projects is that it assumes that your web application has already been built. So you must build it before invoking the .wdproj itself. I'm not sure if this is your problem though.
About excluding files, you'll have to crack open the .wdproj file, which is just an MSBuild file. To exclude files add them to the ExcludeFromBuild item. For instance to make sure that your project file is not included inthe deployment you would add a statement like:
<ItemGroup>
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)*.csproj"/>
<!-- Below excludes svn folders -->
<ExcludeFromBuild Include="$(SourceWebPhysicalPath)**\.svn\**\*"/>
</ItemGroup>
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
OTHER TIPS
I have fixed this by creating an Itemgroup and doing a copy.
<ItemGroup>
<MasterFiles Include="$(SolutionDir)\MVC\Views\Shared\Templates\**\*.master" />
</ItemGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(MasterFiles)" DestinationFiles="$(OutputPath)\Views\Shared\Templates\%(RecursiveDir)%(Filename)%(Extension)" />
</Target>
Many thanks