This project is read-only.

How to use PageMethods and SVN together

Topics: Developer Forum
May 31, 2007 at 7:11 PM
Edited May 31, 2007 at 11:31 PM
In August 2006 there was a question in the PM discussion group how to use PageMethods together with Subversion or any other source control system (

The problem is that the PM AddIn uses the VS object model to analyse the code and find all page methods defined in code. The Addin stores this information in the PageList.xml file, from which the PM code will be generated into the PageList.xml.cs file. If you have these two files under source control, you will get lots of updates and conflicts.

These updates and conflicts occur because the PM Addin tracks the timestamp of the last code file's change in the PageList.xml file. So there will be a change in your PageList.xml every time you change something in any code file containing a page method definition, independent from whether that change required a regeneration of the PageMethods code file or not. Because code changes are very common during main development, whereas PM definitions will change very rarely (I guess you define your PMs, test them and if they work you will not change them, unless you really want to change an PM definition or add a new one). So you can throw away approximately up to 80 or 90% of the PageList.xml changes because do not cause a PM code regeneration (with changed output compared to the current version of PageList.xml.cs file).

But there is a really simple and powerful workaround for this issue

Excluding both the PageList.xmlandPageList.xml.cs file from source control does not work because that will break the code / project because the generated code does not exist and breaks all usages of calling a page method. The generated namespaces, classes and methods do not exists and therefore the compiler cannot resolve them. If this happens you have lots of trouble because you need to comment all all usages of PM generated code to be able to compile your project and get that code regenerated. That's lot of, very hard and very time-consuming work.

The solution is to simply exclude only the PageList.xml from source control and not the PageList.xml.cs because then the generated code remains working for all team members and that file will only be updated when it really changes. Otherwise the PageList.xml is not under source control and can be updated on the development machine as often as needed. Only if a change of that file results in new/other code to be generated, the PageList.xml.cs will also change and therefore be updated in the source control system.

I've tested this in a small team and it works fine for me with SVN. But be aware that this solution will not work with Visual Source Safe <= 6.x and all other source control system which work (or are configured to work) with file write-locks on the local computer because I guess the code file will regenerated every time there is a change in the PageList.xml, also if only a timestamp has changed (Fabrice, please correct me if I'm wrong).
Jun 13, 2007 at 11:20 PM
Excellent post. Thank you for sharing the tip with us.
You are right that PageList.xml is regenerated much more than really needed. This is something that can be improved by having the add-in check more than the timestamp to detect whether something has actually changed on page methods. If someone would like to work on this, please contact me.

I should definitely add your tip to the FAQ. It can really help a lot of people!
Jun 14, 2007 at 2:07 PM
Sounds like it would work. It's been a while since we had this problem, and I think really we ended up using PageMethods a lot less because of the limitations as an add-in. I thought, though, that I remembered both files being updated and conflicted often? I could be wrong though. What you are saying would seem to make sense. Thanks for the post!
Jun 21, 2007 at 5:51 AM
Unfortunately I don't think this works if you're using TFS and Web Application Projects.

You can exclude the pagelist.xml file, but then other team members get exceptions when pagemethods tries to run:

Error during PageMethods add-in execution: Access to the path 'C:\myNETProjects\Auditmaker\Main\Source\Code\AuditMaker\AuditMaker\PageList.xml' is denied.
System.UnauthorizedAccessException: Access to the path 'C:\myNETProjects\Auditmaker\Main\Source\Code\AuditMaker\AuditMaker\PageList.xml' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding)
at MetaSapiens.PageMethods.Addin.PageListWriter.GenerateFile(String filename, PageList pageList) in E:\Projets\PageMethods\Source2005CodePlexReal\SourceVS2005\Addin\PageListWriter.cs:line 128
at MetaSapiens.PageMethods.Addin.Processor.GeneratePageList(String filename) in E:\Projets\PageMethods\Source2005CodePlexReal\SourceVS2005\Addin\Processor.cs:line 564
at MetaSapiens.PageMethods.Addin.Processor.Execute(Project project) in E:\Projets\PageMethods\Source2005CodePlexReal\SourceVS2005\Addin\Processor.cs:line 99
at MetaSapiens.PageMethods.Addin.Connect.buildEvents_OnBuildProjConfigBegin(String projectName, String projectConfigName, String platform, String solutionConfigName) in E:\Projets\PageMethods\Source2005CodePlexReal\SourceVS2005\Addin\Connect.cs:line 247

Errors occured during PageMethods processing: 1 error(s)
PageMethods processing finished. (8.09 seconds)

I'm not sure if VS is locking the file or what's going on.

Nov 15, 2007 at 9:55 AM
I am also using TFS and Web Application Project (WAP). This frequent editing issue does seem to be a deal breaker for my use of PageMethods, which otherwise seem great.

Excluding PageList.xml does not work in that it doesn't allow WAP to then compile because this and the .cs file are nested and get excluded together.

Is there any work being done against issues 2492 or 2493? Do you see much more work being done on this? And yes, I know that if you want something done well, you're best doing it yourself. Unfortunately I simply haven't the time now. Will keep an eye on this and see how it goes.

ps - I know SVN and think it is great, however so is TFS (to preempt a my technology is better than yours response;)
Nov 15, 2007 at 6:33 PM
Hello flcdrg and colum,

you do not have to exclude PageList.xml but onlyPageList.xml.cs.

Then the metadata stays in the source repository, but the code generated fom it not. And of course, do not mix up excluding from the Visual Studio project or solution with exclduding from source control (SVN or TFS). I do not know TFS in detail and therefore not, if it is possible to exclude files from being controlled as it is with SVN, but it should be.

Hope this helps.

Nov 20, 2007 at 6:28 PM

Thanks for replying. Alas, it is not possible to exclude like this in TFS, afaik anyway. We've gone down our own methods anyway as we've some legacy code to support that would prove tricky with this approach. I would definitely consdier it for other projects, especially ones I use SVN with.

On a note of pedantry, you stated the exact opposite in your first post, but it gave the right idea anyway. I'd tried both ways, i.e. with .cs or just .xml.