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

时间:2022-12-31 00:27:15

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.

当我在Visual Studio 2008中使用Build-> Publish Web Site时,大多数时候它会编译站点,然后只是问我“目标文件夹中的所有文件都将被删除。继续?” (或者那种效果)。但是,有时候,在Visual Studio中发布项目时,我会得到一个对话框,让我可以选择完全替换文件夹的内容,或者只是用更新的版本替换更改的文件。

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?

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

Any insight is appreciated!

任何见解都表示赞赏!

Edit - Followup on 2009-01-20

编辑 - 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:

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

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

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

这就是我的Vista笔记本电脑上的不同项目的样子:

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

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?

两台计算机都运行Visual Studio 2008 Professional(版本9.0.30729.1 SP,根据帮助 - >关于)。完全相同的版本。我怀疑操作系统的不同导致了这种功能的改变。它必须是某个地方的设置,对吗?有人知道吗?

6 个解决方案

#1


12  

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:

John是对的,唯一的区别是你的一个项目是一个Web站点项目,另一个是Web应用程序项目。除非您在Web应用程序项目中,否则您将看不到“转换为Web应用程序”选项。我知道......这是非常误导的。这背后的原因源于您转换为Web应用程序项目的方式。如果你计划转换它(这可能是一个真正的痛苦,取决于它的设置),那么你需要意识到一些差异:

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.

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

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.

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

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

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

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.

我已经转换了一些这样的项目,只要“app_code”文件夹中没有很多代码,我发现它们相当顺利。你可以尝试一下,看看它有多容易,如果它看起来很痛苦,我会建议FileZilla只是FTP它并省去一些头疼。

Good Luck

祝你好运

#2


3  

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.

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

#3


1  

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.

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

#4


0  

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.

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

#5


0  

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"

显然这个功能将在VS2010中出现 - 这就是Vishal Joshi在TechEd EMEA会议上宣布的“PDC307:Microsoft Visual Studio 10:Web Development Futures”

#6


-2  

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

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

#1


12  

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:

John是对的,唯一的区别是你的一个项目是一个Web站点项目,另一个是Web应用程序项目。除非您在Web应用程序项目中,否则您将看不到“转换为Web应用程序”选项。我知道......这是非常误导的。这背后的原因源于您转换为Web应用程序项目的方式。如果你计划转换它(这可能是一个真正的痛苦,取决于它的设置),那么你需要意识到一些差异:

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.

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

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.

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

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

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

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.

我已经转换了一些这样的项目,只要“app_code”文件夹中没有很多代码,我发现它们相当顺利。你可以尝试一下,看看它有多容易,如果它看起来很痛苦,我会建议FileZilla只是FTP它并省去一些头疼。

Good Luck

祝你好运

#2


3  

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.

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

#3


1  

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.

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

#4


0  

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.

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

#5


0  

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"

显然这个功能将在VS2010中出现 - 这就是Vishal Joshi在TechEd EMEA会议上宣布的“PDC307:Microsoft Visual Studio 10:Web Development Futures”

#6


-2  

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

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