"Access is denied" on build server when deploying Web API project with XML documentation
Asked Answered
P

3

15

In order to generate XML documentation using Web API Help Pages for my Web API project, I had to check the "XML documentation file" option under the "Builds" section of my project's properties. This correctly generates the documentation when I build locally.

However, when I check in, I get the following error on the build server:

CSC: Error generating XML documentation file 'c:\Builds\3...\Sources\CurrentVersion...\ProjectName\App_Data\XmlDocument.xml' ('Access is denied. ')

I'm not sure why this happens, since it creates a new directory for each build anyway. I googled this issue and searched Stack Overflow, but the only solutions I found were to remove the XML documentation file (which defeats the purpose of using Web API Help Pages). How can I resolve this?

Pallua answered 4/6, 2014 at 21:37 Comment(2)
Do you have the file "ProjectName\App_Data\XmlDocument.xml" checked-in to TFS? And are you trying to overwrite the file for each build?Wedekind
Yes, the file is checked in. I do want the file would get copied over to the drop folder with each build, but I would think it wouldn't need to be an overwrite since a new drop folder is created for each build.Pallua
W
16

If the XML file is checked-in to TFS then when TFS gets the files to the workspace on the build server, it will have "Read-Only attribute" associated with the file. Now when the build generates the new XML file, it wont be able to overwrite the old XML file since it has the read-only attribute.

Solution is to: a) use your build scripts to modify the file attribute and make it read-write b) remove the xml file checked-in to TFS so that, build will be able to generate the XML easily.

Update: if you are using solution b, if the file is part of you project file make sure that you remove the file from the csproj file as well.

Wedekind answered 5/6, 2014 at 16:14 Comment(1)
Had this issue today even though I worked on that project and Published a few weeks ago.Johnnajohnnie
S
5

Removing the file from Source Control did not fix it for me, Team Server was still trying to access it.

I was able to solve it by Cloaking App_Data in the build definition.

Stag answered 11/11, 2014 at 22:51 Comment(0)
R
1

Even though you are creating a new directory for each build, this directory is only for build output. The build doesn't actually occur in that directory, it occurs in the server's tfs workspace and the build output get's copied into the new directory after. The access denied error is due to the checked in file being read only when accessed by tfs on the build server work space and so the file cannot be re-generated\ overwritten during build.

I got around this issue by changing my xml documentation output path to the bin folder.

So Project-> Build -> Output Output path: bin\ XML Documentation file: bin/XmlDocument.xml

I suggest you do this for all of your build configurations (Project -> Build, Configuration Drop down menu -> Select All Configurations)

Then under Project -> Areas/ HelpPage/App_Start/HelpPageConfig.cs change config.SetDocumentationProvider to map to "~/bin/XmlDocument.xml"

Don't forget to remove the XmlDocument.xml file from source control as well since it is re-generated for every build

Ransdell answered 6/8, 2015 at 7:27 Comment(1)
Thanks, worked for me by changing output path to bin/...Brantbrantford

© 2022 - 2024 — McMap. All rights reserved.