简体   繁体   English

如何发布带有区域的ASP.NET MVC 4应用程序?

[英]How to publish an asp.net mvc 4 application with areas?

I have a asp.net mvc 4 application that has multiple area setup. 我有一个具有多个区域设置的asp.net mvc 4应用程序。 However, this application uses multiple projects to make up this area as explained here to follow n-tier in the solution. 但是,此应用程序使用多个项目来组成该区域,如此处所述,以跟随解决方案中的n层。 The output path of these separate projects is set to the bin folder of the main mvc application which works fine. 这些单独项目的输出路径设置为可以正常工作的主mvc应用程序的bin文件夹。

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

I would like to know how can I add their resources like views, .config files, scripts, content, etc. to the Areas folder on publish. 我想知道如何在发布时将其资源(例如视图,.config文件,脚本,内容等)添加到Areas文件夹中。

At the moment I'm doing this using a bat file which I think is not appropriate. 目前,我正在使用我认为不合适的bat文件进行此操作。 I've read about using [ProjectName].wpp.targets to include files while publishing. 我已经读过有关在发布时使用[ProjectName] .wpp.targets包含文件的信息。 Can anyone advice how to include folders which is not included in the project, different areas in this context. 在这种情况下,任何人都可以建议如何包括项目中未包含的文件夹以及项目中未包含的文件夹。

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.. 在我们的例子中,我们最终添加了[ProjectName] .wpp.target和以下内容。

<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. 基本上,目标是将自定义文件包含在msbuild发布管道中,通过使用“ CopyAllFilesToSingleFolderForPackage”,我们正是在这样做。 Another approach would be to have a dedicated msbuild script, check the answer here How to Publish Web with msbuild? 另一种方法是拥有专用的msbuild脚本,在此处查看答案如何使用msbuild发布Web?

Having a bat file, just like yours works too... 拥有蝙蝠文件,就像您的作品一样...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM