Hi, Not pretending to invent something truly unique I wanted to post this code anyway with hope that someone might find it useful.
The end product of our build is a bunch of MSI files and before pushing them to QA we usually perform basic testing of complete application at the integration environment. This environment consists from half a dozen machines which emulate production environment and allow us to run our automated smoke-test suit. The remote deployment question was discussed in this conference quite a few times and the most common suggestion I believe was to use variations of remote exec which in our case did not provided enough feedback information if something went wrong. What I opted out for is to use WMI components from System.Management namespace and couple of simple C# scripts. WMI objects necessary for the task are supplied with Windows servers and Windows XP Pro as well so you don't need to look for third party tools and I included sample script in the email: <script language="C#"> <references> <includes name="System.Management.dll"/> </references> <imports> <import name="System.Management"/> </imports> <code><![CDATA[ public static void ScriptMain(Project project) { try { project.Log(Level.Info, "Target server: {0}", project.Properties["deploy.remotesvr"]); ManagementScope scope = new ManagementScope(project.Properties["deploy.remotesvr"]+"\\root\\cimv2"); scope.Connect(); uninstall(scope, project, project.Properties["deploy.remotesvr.product"]); install(scope, project , project.Properties["deploy.remotesvr.msipath"] + project.Properties["msi.name"] , project.Properties["deploy.remotesvr.targetdir"]); } catch (Exception ex) { project.Log(Level.Error, ex.ToString()); throw; } } public static void uninstall(ManagementScope scope, Project project, string product) { try { project.Log(Level.Info, "\nStart removing {0}", product); SelectQuery query = new SelectQuery("select * from Win32_Product where name = '" + product + "'"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query); foreach (ManagementObject envVar in searcher.Get()) { project.Log(Level.Info, "Uninstalling {0}", envVar["Name"]); object res = envVar.InvokeMethod("Uninstall", null); project.Log(Level.Info, "Uninstall result {0}", res); } project.Log(Level.Info, "Uninstall completed for " + product); } catch (Exception ex) { project.Log(Level.Warning, ex.ToString()); } } static void install(ManagementScope scope, Project project, string msi, string targetDir) { try { project.Log(Level.Info, "\nInstalling " + msi + " \n into " + targetDir); ManagementClass installer = new ManagementClass(scope, new ManagementPath("Win32_Product"), new ObjectGetOptions()); object[] methodArgs = {msi, "TARGETDIR=" + targetDir, true}; object res = installer.InvokeMethod("Install", methodArgs); if ((UInt32)res != 0) throw new Exception("Install error " + res.ToString()); else project.Log(Level.Info, "Succesfully installed {0}", msi); } catch (Exception ex) { project.Log(Level.Error, ex.ToString()); } } ]]></code> </script> Thank you, --Max Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ NAnt-users mailing list NAnt-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-users