将 VS 2008 Web 部署项目与 ASP.NET MVC 结合使用
有人有一个可以使用 ASP.NET MVC 的 Web 部署项目吗? 当我打开“已部署”项目时,MVC 所需的许多文件丢失,并且很难将项目中所有丢失的文件发布到服务器。
或者...是否有比 Web 部署项目更好的方法来修改 MVC 应用程序的 Web.Config? 我有一些差异(SMTP 和连接字符串)需要在上传之前更新,并且 Web 部署项目似乎是正确的方法。
一如既往的感谢!
更新:我至少缺少 global.asax、global.asax.cs 和 default.aspx.cs。
更新 2:发布后,我收到此错误。 无法加载类型“AppNamespace._Default”。
Has anyone got a Web Deployment Project to work with ASP.NET MVC? When I open the "deployed" project, a lot of the files are missing that MVC requires and makes it tough to Publish to the server with all the missing files in the project.
Or... Is there a better way than a Web Deployment Project to modify the Web.Config for MVC apps? I have differences (SMTP and connection strings) that need to be updated before uploading and Web Deployment Projects seem to be the right method.
Thanks as always!
Update: I am missing at least global.asax, global.asax.cs, and default.aspx.cs.
Update 2: Once I Publish, I get this error. Could not load type 'AppNamespace._Default'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我还没有使用我的 mvc 应用程序设置部署项目,但我一直在使用 Scott Hanselman 概述的这项技术,并且效果很好。
管理多个配置文件环境
I haven't set up a Deployment project yet with my mvc app but I've been using this technique outlined by Scott Hanselman and it works great.
Managing Multiple Configuration File Environments
您列出的 3 个特定文件均被编译到 ASP.NET MVC Web 项目生成的二进制文件中。 打开您的 .csproj,您将看到:
在 Reflector 等工具中打开您的二进制文件,您将看到这些类。 因此您不需要部署它们。
MVC .csproj 中的这些 MSBuild 步骤使 Web 部署项目所做的部分工作(即为站点编译单个二进制文件)变得多余。
至于令牌替换,您可以保留部署项目,也可以将相关的 MSBuilds 步骤从 .wdproj 文件复制到 .csproj 文件中。 这不是我做过的事情,但我很快就会尝试自己。
The 3 specific files you have listed are all compiled into the binary produced by your ASP.NET MVC web project. Open up your .csproj and you will see:
Open up your binary in a tool such as Reflector and you will see the classes. Therefore you don't need to deploy them.
These MSBuild steps in the MVC .csproj render part of what the Web Deployment Project does (i.e. compiling a single binary for the site) redundant.
As for the token replacement you can either keep your Deployment project or probably copy the relevant MSBuilds steps from your .wdproj file into your .csproj file. This is not something I've done, but am shortly to try myself.
我发现它对我有用。
当您说缺少文件时,您是在谈论 System.Web.Mvc 文件等吗? 您需要确保在 Web 应用程序中将这些引用设置为本地复制。
I've found it working for me.
When you say there are files missing, are you talking about the System.Web.Mvc files and such? You need to make sure in your web application that these references are set to copy locally.
我已使用 Web 部署项目成功部署到 IIS6。
我首先在部署到 Server 2003 时遇到了问题,但就我而言,这确实是阶段环境的问题。
我首先部署到本地IIS,检查是否是构建问题或环境问题。
我没有使用配置-替换。
这是我的构建脚本:
这是我的 wdp:
I have deployt succesfully to IIS6 using a Web Deployment Project.
I had issues deploying to Server 2003 first, but in my case it realy was a problem of the stage-environment.
I first deployt to a local IIS to check if it was a problem of the build or of the environment.
I did not use config - replacement.
This is my build script:
Here is my wdp: