Is there a common way to access the local machines csproj.user file to get the web site url for watin tests so that The tests can run on each developers local server as well as on IIS on the build server? I guess you could parse the xml file yourself, but I am wondering if there is a Cleaner/Easier way.
+1
A:
I found this
and ended up just doing something like this with a relative path from my Test Project to my Web Project. Then set up an appropriate csproj.user file on the build server.
public static string GetDevelopmentServerURL(string csprojFileName) { XPathDocument doc = new XPathDocument(csprojFileName); XPathNavigator navigator = doc.CreateNavigator();
XmlNamespaceManager manager = new XmlNamespaceManager(navigator.NameTable);
manager.AddNamespace("msbuild",
"http://schemas.microsoft.com/developer/msbuild/2003");
const string xpath = "/msbuild:Project/msbuild:ProjectExtensions/"
+ "msbuild:VisualStudio/msbuild:FlavorProperties/"
+ "msbuild:WebProjectProperties";
XPathNavigator webProjectPropertiesNode =
navigator.SelectSingleNode(xpath, manager);
XPathNavigator developmentServerPortNode =
webProjectPropertiesNode.SelectSingleNode("msbuild:DevelopmentServerPort",
manager);
XPathNavigator developmentServerVPathNode =
webProjectPropertiesNode.SelectSingleNode("msbuild:DevelopmentServerVPath",
manager);
XPathNavigator UseIIS =webProjectPropertiesNode.SelectSingleNode("msbuild:UseIIS",
manager);
XPathNavigator IISPath = webProjectPropertiesNode.SelectSingleNode("msbuild:IISUrl",
manager);
XPathNavigator UseCustomServer = webProjectPropertiesNode.SelectSingleNode("msbuild:UseCustomServer",manager);
XPathNavigator CustomeServerPath = webProjectPropertiesNode.SelectSingleNode("msbuild:CustomServerUrl",
manager);
if (UseIIS.Value == "True")
return IISPath.Value;
if (UseCustomServer.Value == "True")
return CustomeServerPath.Value;
return "http://localhost:" + developmentServerPortNode.Value + developmentServerVPathNode;
}