0

I have a asp.net mvc 4 application that has multiple area setup. However, this application uses multiple projects to make up this area as explained here to follow n-tier in the solution. The output path of these separate projects is set to the bin folder of the main mvc application which works fine.

When I publish this main app on file system as target, the Areas folder that is created in the directory only has HelpPage folder content but no area folders.

I would like to know how can I add their resources like views, .config files, scripts, content, etc. to the Areas folder on publish.

At the moment I'm doing this using a bat file which I think is not appropriate. I've read about using [ProjectName].wpp.targets to include files while publishing. Can anyone advice how to include folders which is not included in the project, different areas in this context.

KKS
  • 3,600
  • 1
  • 27
  • 54
  • we deal the same but we copy those respective views in areas to other folder with same area name where M V C are present while deployment . – super cool Sep 20 '14 at 04:21

1 Answers1

1

We're using the same project set up as the blog post you provided. In our case we ended up adding [ProjectName].wpp.target with the following content..

<Target Name="CopyCustomFiles" AfterTargets="CopyAllFilesToSingleFolderForPackage" >   
     <ItemGroup> 
         <Areas Include="$(ProjectDir)Areas\*\Content\**;$(ProjectDir)Areas\*\Images\**;$(ProjectDir)Areas\*\Scripts\**;$(ProjectDir)Areas\*\Views\**;$(ProjectDir)Areas\*\web.config;$(ProjectDir)Areas\*\*.xml"  />
        </ItemGroup>

      <Copy SourceFiles="@(Areas)" DestinationFiles="@(Areas->'$(_PackageTempDir)\areas\%(ToPath)\%(RecursiveDir)%(Filename)%(Extension)')" />

</Target>

Basically the goal was the include the custom files in the msbuild publishing pipelines and by using "CopyAllFilesToSingleFolderForPackage", we're doing exactly that. Another approach would be to have a dedicated msbuild script, check the answer here How to Publish Web with msbuild?

Having a bat file, just like yours works too...

Community
  • 1
  • 1
Biser C.
  • 553
  • 5
  • 11
  • I've tried your Target element above in my wpp.targets file but it is not working for me with publish method as web deploy package. I have pasted it under Project element. Is there anything else I need to include ? – KKS Sep 21 '14 at 10:40
  • No, that is the only thing I believe. Try to run the publishing from the command prompt and increase the verbosity of msbuild to see what is happening, it will tell you what targets are getting executed. Try to add also CreatePackageOnPublish=True; to see if it is going to make any difference – Biser C. Sep 22 '14 at 12:32