如何在不编译的情况下直接在生产服务器上从开发计算机运行站点
我有一个用 ASP.Net MVC 开发的网站。
开发机上开发的站点是否可以直接在生产服务器上运行而无需编译?即在 /bin
文件夹中,我将只有需要的外部 DLL,而不是项目 DLL。
我将从开发计算机提交代码并在服务器上获取工作副本,它应该无需任何编译即可运行。 有什么办法可以做到这一点吗?
I have a site developed in ASP.Net MVC.
Is it possible to run the site as developed on the developing machine directly on the production server without compilation? I.e. in the /bin
folder I will only have the external DLLs that will be needed and not the project DLL.
I will commit the code from the development machine and take the working copy on the server and it should get run without any compilation.
Is there any way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有两种类型的项目:网站和网站应用程序。
网站将在运行时由 ASP.NET 引擎自动编译,这意味着您可以将源代码部署在
App_Code
文件夹中,然后它将进行编译。另一方面,需要编译 Web 应用程序,并且包含所有代码的生成的程序集应放入
bin
文件夹中。这是 ASP.NET MVC 使用的默认模型。因此,实现您正在寻找的目标的唯一方法是将您的网络应用程序转换为我强烈建议您反对的网站。There are two types of projects: Web Site and Web Application.
A web site will be automatically compiled at runtime by the ASP.NET engine, meaning that you can deploy the source code in the
App_Code
folder and it will compile.On the other hand a web application needs to be compiled and the resulting assembly containing all the code will should be placed into the
bin
folder. This is the default model used by ASP.NET MVC. So the only way to achieve what you are looking for is to convert your web application into a web site which I would strongly recommend you against.你想要实现的目标是可能的,但不是以你想要的方式实现的。
我建议使用ContinousIntegration并使用CruiseControl.net进行部署
http://confluence.public.thoughtworks.org/display/ CCNET/Welcome+to+CruiseControl.NET
您可以将其设置为监视存储库中的更改,并仅在发生更改时才进行构建。我确实相信 FTP 功能即将推出,但我不知道它是否已添加,由于我目前工作的地方,我已经大约 2 年没有使用过 CC.net。但是您可以包含批处理文件或其他类型的脚本来将构建的文件复制到您的服务器。
或者甚至在服务器上有 CC.net?
自动部署的唯一缺点是您必须非常擅长签入工作代码,或者通过大量单元测试进行门控签入,因此如果测试失败,则不会部署站点。
另一种选择是您在分支上进行开发,并且仅从主干中构建和部署 CC.net?
这不会部署未编译的站点,但从您提出问题的方式来看,我猜您只是想删除部署的手动部分。
希望这有帮助。
What you want achieve is possible, but not in the way you want.
I would suggest using ContinousIntegration and deployment using CruiseControl.net
http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET
You can set it up to monitor for changes in the repo and build only when there are changes. I do believe there was FTP functionality coming, but I dont know if it has been added yet, I havent used CC.net in about 2yrs due to the current place I work. BUT you can include a batchfile or a script of some other sort to copy the built files to your server.
OR even have CC.net on the server?
The only downside with auto deployment is you have to be VERY good with checking in working code, or have gated checkins with lots of unit tests, so if the tests fail the site doesnt get deployed.
One other option is you dev on a branch and only have CC.net build and deploy form trunk?
This wont deploy an uncompiled site, but from they way you asked your question I guess you just want to cut out the manual parts of deployment.
hope this helps.
您可以在本地发布,然后将文件复制到生产服务器。使用 Visual Studio 的内置发布功能。 (右键单击 Web 项目,它应该在菜单中)。您可能必须更改配置文件,以便它指向您的产品数据库并具有所有生产设置。如果配置文件已经正确配置,我建议不要复制它。
我们使用 Beyond Compare http://www.scootersoftware.com/ 将代码从开发机器推送到 QA /Staging/Production,因为它允许您查看和推送单个文件(通过文件系统共享或 ftp)或不同的文件夹。此外,在配置更改的情况下,您可以轻松地将它们合并。
You could publish locally and then just do a file copy to the production server. Use Visual Studio's built in Publish feature. (right click the web project and it should be in the menu). You may have to change the configuration file so that it points to your prod database and has all your production settings. I'd recommend just not copying the config file up if it's already configured correctly.
We use Beyond Compare http://www.scootersoftware.com/ to push code from the dev machine to QA/Staging/Production because it allows you to see and push individual files (either through file system shares or ftp) or folders that are different. Also, in the case of configuration changes, you can easily merge them up.