Heinzi
Heinzi

Reputation: 172210

How to prevent Visual Studio from "publishing" XML documentation files in web projects?

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 elaborate).


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?

Upvotes: 12

Views: 13392

Answers (5)

mark
mark

Reputation: 62722

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.

Upvotes: 5

Alex
Alex

Reputation: 6149

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

Upvotes: 0

APrough
APrough

Reputation: 2701

I'm doing this in Express, but this seemed to work for me...

  1. Went to Properties (for the Project)
  2. Clicked Publish Tab
  3. Click Application Files button
  4. Checked Show All Files
  5. Set xml File to Exclude

As I said, using Express 2010, but this worked (it didn't copy the file to the Publish location).

Upvotes: 1

Grant Thomas
Grant Thomas

Reputation: 45083

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.

Upvotes: 10

Henk Holterman
Henk Holterman

Reputation: 273179

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.

Upvotes: 4

Related Questions