简体   繁体   English

部署已发布的代码?

[英]Deployment of published code?

I published the code with Visual Studio 2010 and then deployed the pulished code on production server. 我使用Visual Studio 2010发布了代码,然后在生产服务器上部署了代码。

Everthing is working fine. Everthing工作正常。

Suppose if I need to make some changes in code behind file (.cs file). 假设我需要在文件(.cs文件)后面的代码中进行一些更改。 Do I need to publish the code again and again from visual studio 2010? 我是否需要从visual studio 2010一次又一次地发布代码? Or Can I just need to replace the bin folder on production server? 或者我可以只需要替换生产服务器上的bin文件夹吗?

Currenlty I publish the code each time I change the code in code behind file and replace the publish code on production server. Currenlty每次我更改代码隐藏文件中的代码并替换生产服务器上的发布代码时,我都会发布代码。

Your bin directory will contain your compiled code so if that's all you change you can only deploy the bin folder. 您的bin目录将包含已编译的代码,因此如果您更改了所有内容,则只能部署bin文件夹。

But when you change other files, like your web.config, aspx, css or javascript files, those changes will not show up in your bin directory. 但是当您更改其他文件(如web.config,aspx,css或javascript文件)时,这些更改将不会显示在您的bin目录中。 Those physical files will need to be deployed. 需要部署这些物理文件。

Because deploying can be a tedious and repetitive process, it would be best to automate this. 由于部署可能是一个繁琐且重复的过程,因此最好将其自动化。 If you setup your webserver for WebDeploy , you can automatically deploy from Visual Studio to your server. 如果为WebDeploy设置Web服务器, 可以从Visual Studio自动部署到服务器。 WebDeploy will keep track of all changes and make sure they are deployed. WebDeploy将跟踪所有更改并确保它们已部署。

if you chage .cs files only, then you can replace dll files. 如果你只使用.cs文件,那么你可以替换dll文件。

when you publish: 当你发布时:

If you choose Replace matching files, it copies only changed files 如果选择“替换匹配文件”,则仅复制更改的文件

it is equal to replace dll as above and also it is better option than doing it manually. 它等于替换上面的dll,也比手动更好。

sometimes we may have changes css or javascripts but forgot to add them. 有时我们可能会更改css或javascripts但忘记添加它们。

If you try to modify the code behind code, you don't have to republish the whole project and just need to override the production files. 如果您尝试修改代码背后的代码,则不必重新发布整个项目,只需要覆盖生产文件。 Because it is a partial class of aspx page and is compiled at runtime. 因为它是aspx页面的部分类,并且是在运行时编译的。

But it is better to do it automatically using some tools. 但最好是使用一些工具自动完成。 It can avoid human mistakes and run your test to make sure your change doesn't break any functions. 它可以避免人为错误并运行测试以确保您的更改不会破坏任何功能。

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

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