我是否应该在部署之前预编译 ASP.NET 2.0 站点?
在我工作的地方,我们制作了大量非常小的 ASP.NET 应用程序,并且已经发生过几次网站以预编译格式部署的情况,并且需要更改应用程序,但是源代码中可用的代码版本控件已过时且开发人员不可用。 该应用程序的 dll 必须被反编译并重新组合在一起。
理想情况下,开发人员永远不会通过测试和生产匆忙进行更改并跳过检查更改,此后我们对策略进行了更改以防止这种情况发生,但我想知道在服务器上编译站点的开销是否会增加每当应用程序池重新启动时都是一个足够大的问题,我们应该避免将代码直接上传到服务器。 如果我们可以下载实时源代码,那么检查源代码管理中的版本与实际实时版本会更容易。
预编译VS直接上传cs文件到服务器并在那里编译有什么好处?
Where I work, we do a very large number very small ASP.NET apps, and it has happened a few times that sites have been deployed in precompiled format, and the app needs to be changed, but the version of the code available in source control is out of date and the developer is not available. The app's dll has to be decompiled and hacked back together.
Ideally, it would never happen that a develpoer rushes a change through testing and production and skips checking in the change, we have since made changes to our policies to keep this from happening, but I wonder if the overhead of compiling a site on the server whenever the app pool restarts is a big enough problem that we should avoid uploading our code directly to the server. It would be easier to check the version in source control vs the actual live version if we could download the live source.
What are the advantages of precompiling VS uploading cs files directly to the server and having them compiled there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我不同意针对这一点给出的大多数答案。 与临时发布文件相比,预编译有很多优点,其中最重要的是生产和测试环境中的代码或多或少保持同步。 预编译可以确保您测试的代码每次都是要投入生产的代码。
您遇到的问题不是预编译与首次运行编译之间的问题。 相反,它源于您正在使用的源代码管理类型。 如果我必须猜测(我确实这么做了),我会说您正在运行 Visual SourceSafe。 如果您要切换到使分支和合并变得微不足道的源代码控制系统,那么您可以将代码分为
稳定
和开发
分支。 错误修复针对dev
分支进行(经过验证后,这些分支会合并回stable
分支)。 这样,未经测试或未准备就绪的代码不会最终出现在生产服务器上,并且您始终拥有可以使用的稳定
集的副本。I disagree with most of the answers given to this point. There are many advantages to precompiling over ad-hoc posting of files, not the least of which is that the code in the production and testing environments stay more or less in sync. Pre-compiling makes it certain that the code you tested is the code going to production every time.
The issue you are running into is not one of pre-compile versus first-run compile. Instead it stems from the type of source control you are using. If I had to guess (and I do), I would say you are running Visual SourceSafe. If you were to switch to a source control system that made branching and merging trivial then you could separate your code into
stable
anddevelopment
branches. Bug fixes happen against thedev
branches (which then get merged back to thestable
branch once validated). That way, untested or otherwise not-ready-for-prime-time code does not end up on the production server and you always have a copy of thestable
set to work from.纯粹从易用性的角度来看,我确实喜欢简单地将源文件上传到服务器,而忘记预编译。
这就是我为我管理的所有网站所做的事情,甚至是大型网站。 我确实尝试养成点击应用程序中更重要部分的习惯,以确保一切正常(并在我使用它们时编译它们)。
这是另一个想法。 如果该网站是公开的,您可以使用w3c 链接检查器对其进行控制。 这将产生编译它所访问的每个页面的效果。 无论如何,确保您没有任何损坏的链接是一件好事。
简而言之,我认为这些例行检查几乎可以消除用户首次访问编译缓慢的问题。 无论如何,由于这是一个很好的惯例,所以它对我来说效果很好。
From purely an ease of use standpoint, I do like simply uploading the source files to the server and forget about pre-compiling.
This is what I do for all of the sites I manage, even the big ones. I do try to make a habit of hitting the more important pieces of the application to make sure everything works (and to compile them while I'm at it).
And here's another thought. If the site is public you can let the w3c link checker loose on it. This will have the effect of compiling every page it hits. And it's a nice thing to do anyway to ensure you don't have any broken links.
Simply put, I suppose these routine checks almost eliminate the problem of slow first-visit-compilation from your users. And since it's a good routine to follow anyway, it has worked out well for me.
我首先想到的是:
临时黑客攻击失控的代码。
最终用户是利益相关者,并且是开发人员信托责任的对象。 开发人员应该利用一切机会来提高其产品的效率。
免责声明:这些评论是“按原样”表述的,我不在乎你是否对我进行拼写检查。
您真诚的,
DrFunkie
拼写错误,但是非常好的开发人员。
:)
The first thing that comes to mind is:
Ad Hoc Hacking the Code that's out of control.
End Users are Stake Holders and are the object of a developer's Fiduciary Responsibilities. Developers should take advantage of ever opportunity to improved the efficiently of their products.
DISCLAIMER: These comments are stated "as is" and I don't give a damn if you spell check me.
Sincerely,
DrFunkie
Bad Speller, but damn good developer.
:)
这取决于应用程序的大小和使用频率。 如果它的使用频率足够高,以至于应用程序池仅在一天结束时回收,那么在早上首次启动时短暂等待可能是值得的。 如果它每 30 分钟才被命中一次,每次都强制重新编译,那么可能值得预编译。
当然,如果它是一个非常大的应用程序,第一次运行时需要一段时间才能编译,我会倾向于预编译,特别是如果它没有得到持续使用的话。
It would depend on the size of the applications and the frequency of use. If it's being used regularly enough that the app pool is only recycled at the end of the day, a brief wait on first launch in the morning may be worthwhile. If it's only getting hit once every 30 minutes, forcing a recompile each time, it may be worth precompiling.
Of course, if it's a very large app that takes a while to compile on first run, I'd lean towards precompiling, especially if it's not getting constant use.
主要优点是在网络服务器上的编译性能。 它还可以保护您的代码,因为从汇编中读取代码更困难:-)
The main advantage is in compiling performance on webserver. Also it protects your code, because it is harder to read the code from assembly :-)
我上传文件时没有预编译:
这样,由于我的代码有很多错误,我可以直接从服务器使用 Notepad++ 更正它
此外,Visual Web Developer 2008(免费的)没有编译选项:-P
I upload files without precompiling:
in this way, since my code is very buggy, i can correct it with Notepad++ directly from the server
Also, Visual Web Developer 2008 (the free one) does not have the compiling option :-P