如何发布带有区域的ASP.NET MVC 4应用程序? [英] How to publish an asp.net mvc 4 application with areas?

查看:97
本文介绍了如何发布带有区域的ASP.NET MVC 4应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有多个区域设置的asp.net mvc 4应用程序.但是,此应用程序使用多个项目来组成该区域,如这里所述 在解决方案中遵循n层.这些单独项目的输出路径设置为可以正常工作的主mvc应用程序的bin文件夹.

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.

当我将此主应用程序作为目标发布到文件系统上时,在目录中创建的Areas文件夹仅具有HelpPage文件夹内容,而没有Area文件夹.

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.

我想知道如何在发布时将其资源(例如视图,.config文件,脚本,内容等)添加到Areas文件夹中.

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

目前,我正在使用bat文件执行此操作,我认为这不合适.我已经读过有关在发布时使用[ProjectName] .wpp.targets包含文件的信息.在这种情况下,任何人都可以建议如何包括项目中未包含的文件夹以及其他区域.

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.

推荐答案

我们正在使用与您提供的博客文章相同的项目设置.在我们的案例中,我们最终添加了[ProjectName] .wpp.target和以下内容.

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>

基本上,目标是将自定义文件包含在msbuild发布管道中,通过使用"CopyAllFilesToSingleFolderForPackage",我们正是在这样做. 另一种方法是拥有专用的msbuild脚本,请在此处查看答案 如何使用msbuild发布Web?

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...

这篇关于如何发布带有区域的ASP.NET MVC 4应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆