ASP.NET Web 部署项目:摆脱 .compiled 文件

发布于 2024-07-12 12:46:47 字数 1003 浏览 10 评论 0 原文

我在 Visual Studio 2008 中使用Web 部署项目来准备我的 ASP.NET 应用程序(ASP.NET Web 应用程序,不是 ASP.NET 网站)用于复制到多个服务器。 我必须将文件复制到本地临时服务器、通过 FTP 复制到不同的服务器上,有时我必须从客户的服务器上获取它们。

因此,最好以紧凑的形式部署所有文件,而无需在源和目标之间进行大量比较。 Web 部署项目有一个很好的功能:将所有 aspx 和 ascx 文件编译成单个(附加)程序集。

我以某种方式发现如何删除服务器上的 aspx 占位符文件,现在我想知道是否有一种(也许是自制的)方法来删除这些文件.compiled 文件

来自 Rick Strahl 的博客

.Compiled 文件是一个标记文件 对于 Web 中的每个页面和控件 站点并标识所使用的类 装配体内部。 这些文件 不是可选的,因为它们映射 ASPX 页面到适当的预编译 预编译程序集中的类。 如果删除 .Compiled 文件, 它映射的页面将无法访问 执行,你会得到一个令人讨厌的执行结果 错误。

有人有创意,也许可以使用模块/处理程序来拦截对 bin 文件夹中的 .compiled 文件的检查?

I'm using a Web Deployment Project in Visual Studio 2008 in order to prepare my ASP.NET application (ASP.NET web application, not ASP.NET web site) for being copied to several servers. I have to copy the files on local staging servers, on different servers via FTP and sometimes I have to fetch them from customers' servers.

So, it would be nice to have all files for deployment in a compact form without the necessity of doing a lot of comparing between source and destination. Web deployment projects have this nice feature: compile all your aspx and ascx files into a single (additional) assembly.

I somehow found out how to get rid of aspx placeholder files on the server, now I'd like to know if there is a (maybe self-made) way to get rid of these .compiled files.

From Rick Strahl's blog:

The .Compiled file is a marker file
for each page and control in the Web
site and identifies the class used
inside of the assembly. These files
are not optional as they map the ASPX
pages to the appropriate precompiled
classes in the precompiled assemblies.
If you remove the .Compiled file, the
page that it maps will not be able to
execute and you get a nasty execution
error.

Anybody out there with a creative idea, maybe using a module/handler which intercepts the check against the .compiled files in the bin folder?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

柳若烟 2024-07-19 12:46:47

.compile 文件来自部署时的预编译。 因此,您基本上有 3 个选择:

  1. 保留 .compiled 文件
  2. 不要预编译和部署源代码
  3. 将其转换为 Web 应用程序而不是网站,并编译为程序集

我自己也遇到过同样的问题。 实际上,在处理网站部署时,我在大多数情况下选择#1,但在极少数情况下,当我知道我将不得不长时间维护该网站时,我会花时间将其升级为 Web应用。

The .compile file comes from pre-compiling on deployment. So you basically have 3 options:

  1. Keep the .compiled file
  2. Don't pre-compile and deploy source code
  3. Turn this in to a Web Application instead of a Web Site and compile as an assembly

I have run in to the same problem myself. I actually choose #1 in most cases when dealing with deployment of Web Sites, but on the rare occasion when I know I am going to have to maintain the site for an extended period of time, I take the time to upgrade it to a Web Application.

苍白女子 2024-07-19 12:46:47

我也不喜欢 .compiled 文件,但如果它们在那里,没有人会受到伤害。 那为什么还要麻烦呢?

I don't like the .compiled files either, but nobody gets hurt if they're there. So why bother?

风铃鹿 2024-07-19 12:46:47

您可能需要查看虚拟路径提供程序< /a>(知识库文章此处)在 ASP.NET 中。

此建议的功劳必须归功于 Cheeso 和他在这里自我回答的问题:

我可以获得“WAR 文件”类型部署吗使用 ASP.NET?

You might want to take a look at Virtual Path Providers (KB how to here) in ASP.NET.

Credit for this suggestion must go to Cheeso and his self answered question here:

Can I get “WAR file” type deployment with ASP.NET?

狼亦尘 2024-07-19 12:46:47

我不知道 .compiled 文件,但您可以将服务器设置为使用 subversion 更新其文件,而不是在编译时手动复制文件。

因此,您可以使用 Web 部署项目(而不是单个程序集)编译文件,将它们放入为此目的创建的存储库中,然后在每台服务器上执行 svn update 来自动获取和比较文件。

我知道这不是你直接要求的,但这可能是一条探索之路。

I don't know about the .compiled files, but you could set up your servers to update their files with subversion instead of manually copying the files when you compile.

So you would compile the files using the Web deployment project (not into a single assembly), put them in a repository you created for this purpose, and on each server, just do an svn update to fetch and compare the files automatically.

I know it's not what you asked for directly, but it may be a path to explore.

假面具 2024-07-19 12:46:47

将“排除过滤器”添加到您的部署项目:

  1. 在部署项目中。
  2. 右键单击内容文件。
  3. 单击“排除过滤器”。
  4. 添加“*.Compiled”
  5. 点击确定。

就是这样。

Add "Exclude Filter" to your deployment project:

  1. In the Deployment Project.
  2. Right Click on Content Files.
  3. Click on "Exclude Filter".
  4. Add "*.Compiled"
  5. click OK.

and thats it.

梦境 2024-07-19 12:46:47

我记得当我无法使用 VWD Express 进行 Web 应用程序时,我使用 nant 脚本将项目编译成单个 dll 并部署,这样就可以了(所以我也不需要完整的 VS 来进行 dll 部署),所以如果你真的不想把你的项目弄乱到Web应用程序,也许这也是一个需要检查的路径。

I remember at the days when I cant do Web Application with VWD Express, I use nant script to compile the project into a single dll and deploy, that would work (so I dont need the full VS to do dll deployment too), so if you really don't want to mess your project to Web Application, maybe this is a path to check too.

走走停停 2024-07-19 12:46:47

您可以使用 .compiled 文件>aspnet_merge 工具,带有 -r 选项。

删除主代码程序集的 .compiled 文件(App_Code 文件夹中的代码)。 如果您的应用程序包含对主代码程序集的显式类型引用,请勿使用此选项。

You can get rid of the .compiled files by using the aspnet_merge tool with the -r option.

Removes the .compiled files for the main code assembly (code in the App_Code folder). Do not use this option if your application contains an explicit type reference to the main code assembly.

终止放荡 2024-07-19 12:46:47

如果您将代码发布为可更新(在发布设置中),则会生成这些文件。 取消选中该值并重新发布。 这是我知道的一个老问题,但这里没有明确定义答案。

If you publish your code as updateable (in publish settings) these files are generated. Uncheck that value and republish. This is an old question I know, but no answers are clearly defined for this here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文