[263890] [regression] Run on Server does not run publish first, if server is not yet started
diff --git a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
index 20ed1f1..8d8d441 100644
--- a/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
+++ b/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/Server.java
@@ -1636,12 +1636,11 @@
 		byte pub = StartJob.PUBLISH_NONE;
 		if (ServerCore.isAutoPublishing() && shouldPublish()) {
 			if (((ServerType)getServerType()).startBeforePublish())
-				pub = StartJob.PUBLISH_AFTER;
-			else
 				return Status.OK_STATUS;
+			pub = StartJob.PUBLISH_BEFORE;
 		}
 		
-		final IStatus [] pubStatus = new IStatus[1];
+		final IStatus [] pubStatus = new IStatus[]{Status.OK_STATUS};
 		
 		// publish before start
 		byte publish = pub;
@@ -1667,21 +1666,21 @@
 				return Status.CANCEL_STATUS;
 			}
 		}
-		return Status.OK_STATUS;
+		return pubStatus[0];
 	}
 	
-	protected IStatus publishAfterStart(IProgressMonitor monitor, boolean synchronous){
+	protected IStatus publishAfterStart(IProgressMonitor monitor, boolean synchronous, final IOperationListener op){
 		
 		// check if we need to publish
 		byte pub = StartJob.PUBLISH_NONE;
 		if (ServerCore.isAutoPublishing() && shouldPublish()) {
 			if (((ServerType)getServerType()).startBeforePublish())
+				pub = StartJob.PUBLISH_AFTER;
+			else
 				return Status.OK_STATUS;
-			
-			pub = StartJob.PUBLISH_AFTER;
 		}
 		
-		final IStatus [] pubStatus = new IStatus[1];
+		final IStatus [] pubStatus = new IStatus[]{Status.OK_STATUS};
 		
 		// publish after start
 		byte publish = pub;
@@ -1692,6 +1691,9 @@
 					IStatus status = event.getResult();
 					if (status != null && status.getSeverity() == IStatus.ERROR)
 						pubStatus[0] = status; 
+					if (op != null){
+						op.done(status);
+					}
 				}
 				
 			});
@@ -1706,7 +1708,7 @@
 				return Status.CANCEL_STATUS;
 			}
 		}
-		return Status.OK_STATUS;
+		return pubStatus[0];
 	}
 	
 	/**
@@ -1730,7 +1732,7 @@
 		StartJob startJob = new StartJob(mode2);
 		startJob.schedule();
 		
-		publishAfterStart(monitor,false);
+		publishAfterStart(monitor,false,null);
 	}
 	
 	/**
@@ -1752,19 +1754,27 @@
 			Trace.trace(Trace.FINEST,"Failed publish job during start routine");
 			return;
 		}
-		
+
+		// check the publish flag (again) to determine when to call opListener.done 
+		byte pub = StartJob.PUBLISH_NONE;
+		if (ServerCore.isAutoPublishing() && shouldPublish()) {
+			if (((ServerType)getServerType()).startBeforePublish())
+				pub = StartJob.PUBLISH_AFTER;
+			else
+				pub = StartJob.PUBLISH_BEFORE;
+		}
+
 		StartJob startJob = new StartJob(mode2);
-		if (opListener != null) {
+		if (opListener != null && pub == StartJob.PUBLISH_BEFORE) {
 			startJob.addJobChangeListener(new JobChangeAdapter() {
 				public void done(IJobChangeEvent event) {
-					publishAfterStart(null,false);
 					opListener.done(event.getResult());
 				}
 			});
 		}
 		startJob.schedule();
 		
-		publishAfterStart(null,false);
+		publishAfterStart(null,false, opListener);
 	}
 
 	public void synchronousStart(String mode2, IProgressMonitor monitor) throws CoreException {
@@ -1790,7 +1800,7 @@
 			Trace.trace(Trace.WARNING, "Error waiting for job", e);
 		}
 		
-		publishAfterStart(monitor,true);
+		publishAfterStart(monitor,true,null);
 	}
 
 	/*