How to ensure your accepted updates get published in Project Server 2007

In Project Server 2003 updates needed to be made with Project Professional , and then when Project was closed an auto publish would happen – if you wanted it to or not.  Some people wanted it, some didn’t.  In 2007 as we don’t need to use Project Professional and this can happen purely on the server then we leave the choice of when to publish up to you. 

One way you can simulate the 2003 behavior is to use a server-side event handler to act on the Statusing.OnApplied method, and carry out a publish of the project via the PSI.  This would then ensure that all accepted updates were reflected in PWA.  The following code samples is based on the SDK TestEventHandler, and apart from the code, would also require web references to the Project and LoginWindows web services.  I am also not using impersonation, so my SSP Administrator (the account that would be running the Event services) does need to be a user in PWA with the right permissions to publish the projects.  You could use the same techniques as I recently published for impersonation if you did not want to give any PWA permissions to this account.  If multiple publish events hit the queue at one time then most will get skipped for optimization – but if you are processing a great deal of updates you should consider the load this extra publish work will put on your server.  I use the “post” rather than the “pre” event so that even if the event handler fails it will not block or cancel the event.  Obviously my writing to the event log is optional too – just helped me to see it was working.

As usual with MSDN blog postings the code is supplied “as-is”, with no warranties or support and could probably do with some better exception handling – but hopefully for any customers wanting to get auto publishing this will be a help.  You will need to replace servername and pwa with your own servername and pwa instance names.

using System;
using System.Net;
using System.Diagnostics;
using Microsoft.Office.Project.Server.Events;
using Microsoft.Office.Project.Server.Library;

namespace TestEventHandler
    public class MyPublishingEventHandler : StatusingEventReceiver 
        const string LOGINWINDOWS = "_vti_bin/PSI/LoginWindows.asmx";
        const string PROJECT = "_vti_bin/PSI/Project.asmx";
        private static WebSvcLoginWindows.LoginWindows 
            loginWindows = new 
        private static WebSvcProject.Project project =
            new WebSvcProject.Project();
        private string baseUrl = "http://servername/pwa/";
        public override void  OnApplied(PSContextInfo contextInfo, 
            StatusingPostApplyEventArgs e)

             base.OnApplied(contextInfo, e);
            loginWindows.Url = baseUrl + LOGINWINDOWS;
            loginWindows.Credentials = 
            project.Url = baseUrl + PROJECT;
            project.Credentials = 

            // I don't do a full publish 
            // You could change the third parameter to true if you wanted to
            Guid jobUid = Guid.NewGuid();
            project.QueuePublish(jobUid, e.ProjectID, false, "");

            // Create an EventLog instance and assign its source.
            EventLog myLog = new EventLog();
            myLog.Source = "Auto Publish Event Handler";

            // Get information from the event arguments, and 
            // write an entry to the Application event log. 
            string userName = contextInfo.UserName.ToString();
            string projectGuid = e.ProjectID.ToString();
            int eventId = 3945;
            string logEntry;

            logEntry = "User: " + userName + "nProject UID: "
                + projectGuid + " has been queued for publish.";
                EventLogEntryType.Information, eventId);


The SDK description of the Event Handlers, and links to the SDK samples can be found here.