问题
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).
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.
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.
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?
回答1:
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.
回答2:
Is there a way to prevent Visual Studio from copying this file when publishing the ASP.NET project,
Turn XML docs off in Release mode
but still retain the benefit of XML documentation IntelliSense when developing?
Turn XML docs on / off in Debug mode. Intellisense will work either way.
回答3:
I'm doing this in Express, but this seemed to work for me...
- Went to Properties (for the Project)
- Clicked Publish Tab
- Click Application Files button
- Checked Show All Files
- Set xml File to Exclude
As I said, using Express 2010, but this worked (it didn't copy the file to the Publish location).
回答4:
There is another solution. Just include the following in your csproj file somewhere in the beginning:
<AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions>
That's it. XML files will no longer be published. Of course, you can make it conditional on the concrete configuration.
回答5:
You can do this by adding the addon Web deployment project on visual studio which can be downloaded from here: http://www.microsoft.com/download/en/details.aspx?id=19995 and to exclude whatever files/folders you need please follow the steps found here
来源:https://stackoverflow.com/questions/9314237/how-to-prevent-visual-studio-from-publishing-xml-documentation-files-in-web-pr