如何使用“发布”功能 在 Visual Studio 2008 中运行而不删除目标文件夹的内容?

发布于 2024-07-11 06:31:44 字数 863 浏览 5 评论 0原文

当我在 Visual Studio 2008 中使用“生成”->“发布网站”时,大多数时候它都会编译网站,然后简单地询问我“目标文件夹中的所有文件都将被删除。是否继续?” (或类似的东西)。 然而,有时,当在 Visual Studio 中发布项目时,我会看到一个对话框,让我选择完全替换文件夹的内容,或者简单地用新版本替换更改的文件。

我更喜欢在不完全删除文件夹的情况下进行发布,因为部署的应用程序会创建用户文件和缓存文件,因为我不想采取额外的步骤来保留这些文件。 但是,我不确定为什么 Visual Studio 并不总是给我这个选项。 这是我可以更改的设置吗? 它与我使用的 .NET 版本有关吗?

任何见解表示赞赏!

编辑 - 2009-01-20 的后续

我仍然没有弄清楚这一点,但这里有一些更多信息。

下面是我的 Win XP 桌面上的一个 ASP.NET 项目的发布功能的样子:

下面是 Windows XP 桌面上的另一个项目的发布功能的样子:我的 Vista 笔记本电脑:

请注意第二个屏幕截图中的单选按钮,它们允许我选择在发布之前删除文件夹的内容,或者只是为了覆盖匹配的文件。 我希望每个项目都有这些选项。

两台计算机都运行 Visual Studio 2008 Professional(版本 9.0.30729.1 SP,根据 Help->About)。 完全相同的版本。 我怀疑操作系统的差异导致了这种功能的变化。 它一定是某个地方的设置,对吧? 有人知道吗?

When I use Build->Publish Web Site in Visual Studio 2008, most of the time it compiles the site, and then simply asks me "All files in the target folder will be deleted. Continue?" (or something to that effect). On occasion, however, when publishing a project in Visual Studio, I would get a dialog box that would give me the choice of replacing the folder's contents completely, or simply replacing changed files with newer version.

I much prefer to publish without completely obliterating the folder, because the deployed application creates user files and cache files as it's been used that I don't want to take extra steps to preserve. However, I'm not sure why Visual Studio doesn't always give me this option. Is this a setting somewhere I can change? Is it tied to the version of .NET I'm using?

Any insight is appreciated!

Edit - Followup on 2009-01-20

I still haven't figured this out, but here's some more information.

Here's what the publish function looks like for one ASP.NET project on my Win XP desktop:

And here's what it looks like for a different project on my Vista laptop:

Notice the radio buttons in the second screenshot that allow me to choose to either delete the contents of the folder prior to publishing, or merely to overwrite matching files. I'd like to have these options for every project.

Both computers are running Visual Studio 2008 Professional (version 9.0.30729.1 SP, according to Help->About). The exact same version. And I doubt the OS difference is causing this functionality change. It's got to be a setting somewhere, right? Does anyone know?

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

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

发布评论

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

评论(6

在你怀里撒娇 2024-07-18 06:31:44

约翰是对的,唯一的区别是您的项目之一是 网站项目 另一个是 Web 应用程序项目。 除非您处于 Web 应用程序项目中,否则您不会看到“转换为 Web 应用程序”选项。 我知道……这是非常误导性的。 其背后的原因源于您转换为 Web 应用程序项目的方式。 如果您打算转换它(这可能是一个真正的痛苦,具体取决于它的设置方式),那么您需要注意一些差异:

Web应用程序项目中,一切都是预先的-compiled 所有代码隐藏页面将被编译成.dll ---- 在网站项目中,项目中没有任何内容被预编译,编译器将编译所有内容以确保其有效,但没有已编译的页面已上传。 当用户第一次尝试访问该站点时,每个页面都会编译到自己的 dll 中。 这意味着在网站项目中,您可以上传单个代码隐藏文件。

命名空间 - 在Web 应用程序项目中,默认情况下会创建命名空间,但在网站项目中则不然。 因此,如果您打算转换它们,您可能需要花一些时间添加它们。

项目文件 - 您会注意到网站项目没有Web应用程序项目具有的“cproj”文件。

我已经转换了其中一些项目,我发现只要“app_code”文件夹中没有太多代码,它们就相当顺利。 你可以尝试一下,看看它有多容易,如果看起来会很痛苦,我建议 FileZilla 只需通过 FTP 传输即可,这样可以省去一些麻烦。

祝你好运

John is right, the only difference is one of your projects is a Web Site Project and the other is a Web Application project. You will not see the "convert to web application" option unless you are in a Web Application project. I know... it is very misleading. The reason behind this stems from the the way you convert to a web application project. If you plan on converting it(which can be a real pain in arse, depending on how it is set up) then you need to be aware of a few differences:

In a Web Application project everything is pre-compiled all the codebehind pages will be compiled into a .dll ---- In a Web Site Project nothing in the project is pre-compiled, the compiler will compile everything to ensure it is valid but none of the compiled pages are uploaded. When a user first attempts to access the site each page is compiled into its own dll. This means in a Web Site Project you are able to upload a single codebehind file.

Namespaces - In a Web Application project namespaces are created by default in a Web Site Project they are not. So you may have to spend some time adding them if you plan on converting them.

Project files - you will notice that A Website Project does not have a "cproj" file a Web Application project does.

I have converted a few of these project I find they go fairly smooth as long as there is not a lot of code in the "app_code" folder. You can give it a try and see how easy it is, if it looks like it is going to be a pain, I would suggest FileZilla just FTP it and save yourself some headache.

Good Luck

鲜肉鲜肉永远不皱 2024-07-18 06:31:44

对于网站项目和 Web 应用程序项目,该对话框是不同的。 在我的 MVC 项目(Web 应用程序项目)中,我看到了其他选项。 在我的常规网站项目中,我看到发布的第一个对话框。

That dialog is different for Web site projects and Web application projects. In my MVC projects (Web application projects), I see the additional options. In my regular ol' web site projects, I see the first dialog posted.

薔薇婲 2024-07-18 06:31:44

不确定此选项是否适合您,但您可以使用解决方案资源管理器中的复制网站功能。 单击解决方案资源管理器顶部的“复制网站”图标。

Not sure if this option will be suitable for you but you could use the copy website function from the solution explorer. Click on the "Copy Website" icon at the top of the solution explorer.

尛丟丟 2024-07-18 06:31:44

我认为您问题的真正答案是您应该将用户文件和缓存文件放在其他地方。

发布网站时,Visual Studio 旨在确保目标文件夹包含您的网站文件,而绝对没有其他内容。

I think the real answer to your question is that you should put your user files and cache files somewhere else.

When publishing a web site Visual Studio is designed to make sure that the target folder contains your web site files, and absolutely nothing else.

终遇你 2024-07-18 06:31:44

显然,此功能将在 VS2010 中推出 - 这是 Vishal Joshi 在 TechEd EMEA 会议“PDC307:Microsoft Visual Studio 10:Web 开发未来”中宣布的内容

Apparently this feature is coming in VS2010 - that's what Vishal Joshi announced at TechEd EMEA in session "PDC307: Microsoft Visual Studio 10: Web Development Futures"

乄_柒ぐ汐 2024-07-18 06:31:44

该网站已从更新层中的网站更新。

The site has been updated from the site in the updated layer.

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