如何防止Visual Studio“发布” Web项目中的XML文档文件? [英] How to prevent Visual Studio from "publishing" XML documentation files in web projects?

查看:204
本文介绍了如何防止Visual Studio“发布” Web项目中的XML文档文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:此问题类似于 如何防止在发布模式下构建XML文档的副本? ,但是它不一样,那里的答案是不适用继续阅读,了解原因。 (如果您不同意,请在评论或聊天中询问,我将很乐意提出)。

Note: This question is similar to How to prevent the copy of XML documentation files in a release mode build?, but it's not the same and the answers there don't apply. Read on to find out why. (Please ask in the comments or in chat if you disagree, I'll be glad to elabroate).

我有一个库项目(myLibrary)和一个引用该库的ASP.NET Web应用程序项目(都在相同的解决方案中)。检查库项目的生成XML文档文件,因为我想在开发过程中拥有好的IntelliSense功能。

I have a library project (myLibrary) and an ASP.NET web application project referencing this library (both are in the same solution). "Generate XML documentation file" is checked for the library project, because I want to have those nice IntelliSense features while developing.

当我发布 Web应用程序(项目/ Publish ...上的上下文菜单),它仅将运行应用程序所需的文件(无源代码等)复制到某些发布目录。那很好。不幸的是,它还会复制库的XML文档文件。由于我认为我们的图书馆的文件是一个商业秘密,所以我不希望它最终在客户的服务器上。因此,我们必须记住在部署之前从发布目录手动删除此文件。

When I publish the web application (Context Menu on the project/Publish...), it copies only the files required for running the application (no source code, etc.) to some publish directory. That's good. Unfortunately, it also copies the XML documentation file of the library. Since I consider our library's documentation to be a trade secret, I wouldn't want it to end up on a customer's server. Thus, we have to remember to manually remove this file from the publish directory before deploying it.

有没有办法防止 Visual Studio在发布ASP.NET项目时复制此文件,但在开发时仍然保留XML文档IntelliSense的优点?

Is there a way to prevent Visual Studio from copying this file when publishing the ASP.NET project, but still retain the benefit of XML documentation IntelliSense when developing?

推荐答案

假设您使用不同的配置进行开发和发布(以及其他任何方式),取消选中XML文档文件/关闭特定配置的生成将阻止在不需要时进行部署。另一个选择是删除文件的后建立动作。

Assuming you're using distinct configurations for development and release (and whatever else), unchecking 'XML documentation file'/turning off generation for a specific configuration would prevent it being deployed when not needed. Another option would be a post-build action to delete the file/s.

这两个选项中的前者似乎更加优雅。

The former of those two options seeming more elegant.

这篇关于如何防止Visual Studio“发布” Web项目中的XML文档文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆