visual-studio 为什么在我发布带有“运行此应用程序所需的仅文件”选项的 ASP.NET Web 项目时不复制 web.config?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1306515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why the web.config isn't copied when I publish an ASP.NET Web Project with the "Only files needed to run this application" option?
提问by Jader Dias
How to correct it?
如何纠正?
回答by Brandon
"Only files needed to run this application" means any build output files like DLLs and references in the bin folder and any files that have a Build Action of Content.
“仅运行此应用程序所需的文件”是指 bin 文件夹中的任何构建输出文件,如 DLL 和引用,以及任何具有内容构建操作的文件。
Since the web.config is neither of these, you'll have to change the publish option to All Project Files, or else copy the web.config manually.
由于 web.config 两者都不是,您必须将发布选项更改为所有项目文件,或者手动复制 web.config。
回答by David R. Longnecker
When you say 'ASP.NET web project', do you mean 'ASP.NET web application project'?
当您说“ASP.NET Web 项目”时,您的意思是“ASP.NET Web 应用程序项目”吗?
If so, the web.config should have a build action of Contentby default. As Brandon mentioned, Content is then copied over to the publish destination.
如果是这样,默认情况下web.config 应该具有Content的构建操作。正如 Brandon 所提到的,然后将内容复制到发布目的地。
To verify, select the web.config file in your Solution Explorer then use the Properties Window. An example:
要进行验证,请在解决方案资源管理器中选择 web.config 文件,然后使用“属性”窗口。一个例子:
example http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&id=558
示例 http://photos.tiredstudent.com/WebStorageHandler.ashx?tb=false&id=558
回答by Oliver
I know it sounds silly but make sure it is marked as 'Content' as it's Build Action under it's properties.
我知道这听起来很愚蠢,但请确保将其标记为“内容”,因为它是其属性下的构建操作。

