简体   繁体   English

Web Deploy 2.0-可以阻止调试部署吗?

[英]Web Deploy 2.0 - Possible to prevent debug deploy?

When developing an ASP.NET website with the Entity Framework, you can use an initialiser to drop and recreate the database when the model changes. 在使用实体框架开发ASP.NET网站时,可以使用初始化程序在模型更改时删除并重新创建数据库。

Take this example: I set up my project to drop and recreate the db under the Debug configuration, but not the Release. 以以下示例为例:我将项目设置为删除并在Debug配置(而不是Release)下重新创建db。

I use Web Deploy 2.0, but, I see a potential issue, where I deploy to a production server, and forget to build the website with the configuration set to Release. 我使用Web Deploy 2.0,但是我看到一个潜在的问题,即我将其部署到生产服务器上,却忘记了将配置设置为Release来构建网站。 Therefore the db may be dropped in production. 因此,该数据库可能会在生产中删除。

Is there a way to prohibit Visual Studio from publishing a website, based on certain criteria? 是否可以根据某些条件禁止Visual Studio发布网站? eg destination server is X and the project is built in the Debug configuration 例如,目标服务器是X,项目是在Debug配置中构建的

If you know the server name, you can write code to skip setting the database initializer in Global.asax 如果知道服务器名称,则可以编写代码以跳过在Global.asax中设置数据库初始化程序的步骤

if(Server.MachineName=="skipServerName")
{//do not set the initalizer
}

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

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