Пример #1
0
        /// <summary>
        /// Starts the application using the deployment and
        /// application manifests.
        /// </summary>
        /// <exception cref="ApplicationRestartException">
        /// If the application could not be started automatically
        /// </exception>
        static public void StartApplication()
        {
            log.Info("Starting application...");

            // Get the current application manifest
            ApplicationManifest appManifest = GetCurrentApplicationManifest();

            // If there is enough information to restart the application, do it now!
            if (appManifest != null &&
                appManifest.EntryPoint != null)
            {
                // NOTE: using workingDir fixes bug #1955109 - Working Directory not set
                string workingDir = Path.Combine(
                    VersionRepositoryFolder,
                    appManifest.AssemblyIdentity.Version.ToString()
                    );

                log.Debug("Executing entry point...");
                appManifest.EntryPoint.Run(
                    workingDir,
                    _CommandLineParameters);
                log.Debug("Done.");
            }
            else
            {
                log.Error("The application manifest could not be loaded, or the entry point was missing or invalid.");
                throw new ApplicationStartException();
            }
        }
Пример #2
0
        public UpdateFile(ApplicationManifest parent, XmlNode elm, XmlNamespaceManager nsmgr)
            : this(parent)
        {
            if (elm.Attributes["name"] != null)
            {
                Name = elm.Attributes["name"].Value;
            }
            if (elm.Attributes["size"] != null)
            {
                Size = long.Parse(elm.Attributes["size"].Value);
            }
            if (elm.Attributes["group"] != null)
            {
                Group = elm.Attributes["group"].Value;
            }
            if (elm.Attributes["optional"] != null)
            {
                Optional = Convert.ToBoolean(elm.Attributes["optional"].Value);
            }

            // NOTE: fixes a bug where files aren't always updated, due to
            // a change in the file hash.  Thanks to Dan Dixon for the fix.

            // Load the assembly hash
            XmlNode hashNode = elm.SelectSingleNode(@"asmv2:hash", nsmgr);
            if (hashNode != null)
            {
                XmlNode hashValueNode = hashNode.SelectSingleNode(@"dsig:DigestValue", nsmgr);
                if (hashValueNode != null && hashValueNode.HasChildNodes)
                {
                    Hash = hashValueNode.FirstChild.Value;
                }
            }
        }
Пример #3
0
        public void Load()
        {
            try
            {
                if (!string.IsNullOrEmpty(CodeBase))
                {
                    // NOTE: Fixes bug #1831194 - URI segments already contain a slash.
                    string path = string.Join("", Parent.Uri.Segments);
                    path  = Path.GetDirectoryName(path);
                    path  = Path.Combine(path, CodeBase);
                    path += Parent.Uri.Query;

                    if (Parent is DeploymentManifest)
                    {
                        UriBuilder uriBuilder = new UriBuilder(
                            Parent.Uri.Scheme,
                            Parent.Uri.Host,
                            Parent.Uri.Port,
                            path);

                        ApplicationManifest = new ApplicationManifest(
                            this,
                            uriBuilder.Uri,
                            Parent.Username,
                            Parent.Password,
                            Parent.Domain);

                        // Add the application manifest to the deployment manifest
                        ((DeploymentManifest)Parent).ApplicationManifest = ApplicationManifest;
                    }
                }
            }
            catch
            {
                throw new ManifestException();
            }
        }
Пример #4
0
        public UpdateFile(ApplicationManifest parent, XmlNode elm, XmlNamespaceManager nsmgr)
            : this(parent)
        {
            if (elm.Attributes["name"] != null)
                Name = elm.Attributes["name"].Value;
            if (elm.Attributes["size"] != null)
                Size = long.Parse(elm.Attributes["size"].Value);
            if (elm.Attributes["group"] != null)
                Group = elm.Attributes["group"].Value;
            if (elm.Attributes["optional"] != null)
                Optional = Convert.ToBoolean(elm.Attributes["optional"].Value);

            // NOTE: fixes a bug where files aren't always updated, due to
            // a change in the file hash.  Thanks to Dan Dixon for the fix.

            // Load the assembly hash
            XmlNode hashNode = elm.SelectSingleNode(@"asmv2:hash", nsmgr);
            if (hashNode != null)
            {
                XmlNode hashValueNode = hashNode.SelectSingleNode(@"dsig:DigestValue", nsmgr);
                if (hashValueNode != null && hashValueNode.HasChildNodes)
                {
                    Hash = hashValueNode.FirstChild.Value;
                }
            }
        }
Пример #5
0
 public UpdateFile(ApplicationManifest parent)
 {
     Parent = parent;
 }
Пример #6
0
        static public ApplicationManifest GetCurrentApplicationManifest()
        {
            ApplicationManifest appManifest = null;

            DDayUpdateConfigurationSection cfg = ConfigurationManager.GetSection("DDay.Update")
                as DDayUpdateConfigurationSection;

            // Try to load a local deployment manifest
            if (LocalDeploymentManifest == null)
                LoadLocalDeploymentManifest();

            DeploymentManifest deploymentManifest = LocalDeploymentManifest ?? DeploymentManifest;

            // Try to retrieve the application manifest from the
            // deployment manifest.
            if (deploymentManifest != null)
            {
                // Load the deployment manifest, if we haven't done so already!            
                log.Debug("Loading application manifest from deployment manifest...");
                try
                {
                    deploymentManifest.LoadApplicationManifest();
                    appManifest = deploymentManifest.ApplicationManifest;
                    log.Debug("Loaded.");
                }
                catch
                {
                }
            }

            // If we haven't found an application manifest yet, then let's try to load
            // it from a previous version!            
            if (appManifest == null)
            {
                log.Debug("The application manifest could not be located; searching previous versions...");
                if (cfg != null)
                {
                    Version[] localVersions = cfg.VersionManager.LocalVersions;

                    if (localVersions.Length > 0)
                    {
                        for (int i = 0; i < localVersions.Length; i++)
                        {
                            log.Debug("Searching version '" + localVersions[i] + "'...");

                            // Try to load an application manifest
                            // from this version!
                            try
                            {
                                string directory = Path.Combine(VersionRepositoryFolder, localVersions[i].ToString());
                                Uri uri = new Uri(
                                    Path.Combine(
                                        directory,
                                        LocalApplicationManifestFilename
                                    )
                                );

                                log.Debug("Attempting to load manifest from '" + uri.AbsolutePath + "'...");

                                // Get the application manifest                                
                                appManifest = new ApplicationManifest(uri);
                            }
                            catch { }

                            // If we found an application manifest, then check to see
                            // if the application name matches our bootstrap executable
                            // name.  If it doesn't, then we're looking at a version 
                            // of a *different* application, and should ignore it!
                            if (appManifest.EntryPoint != null &&
                                appManifest.EntryPoint.AssemblyIdentity != null &&
                                appManifest.EntryPoint.AssemblyIdentity.Name != null)
                            {
                                string manifestName = appManifest.EntryPoint.AssemblyIdentity.Name;
                                string appName = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
                                if (!object.Equals(manifestName, appName))
                                {
                                    log.Debug("The application manifest for application '" + manifestName + "' was found and ignored (looking for '" + appName + "')");
                                    appManifest = null;
                                }
                            }

                            // We found an application manifest that we can use!
                            if (appManifest != null)
                            {
                                log.Debug("Application manifest found!");
                                break;
                            }
                        }
                    }
                }
            }

            return appManifest;
        }
Пример #7
0
        static public ApplicationManifest GetCurrentApplicationManifest()
        {
            ApplicationManifest appManifest = null;

            DDayUpdateConfigurationSection cfg = ConfigurationManager.GetSection("DDay.Update")
                                                 as DDayUpdateConfigurationSection;

            // Try to load a local deployment manifest
            if (LocalDeploymentManifest == null)
            {
                LoadLocalDeploymentManifest();
            }

            DeploymentManifest deploymentManifest = LocalDeploymentManifest ?? DeploymentManifest;

            // Try to retrieve the application manifest from the
            // deployment manifest.
            if (deploymentManifest != null)
            {
                // Load the deployment manifest, if we haven't done so already!
                log.Debug("Loading application manifest from deployment manifest...");
                try
                {
                    deploymentManifest.LoadApplicationManifest();
                    appManifest = deploymentManifest.ApplicationManifest;
                    log.Debug("Loaded.");
                }
                catch
                {
                }
            }

            // If we haven't found an application manifest yet, then let's try to load
            // it from a previous version!
            if (appManifest == null)
            {
                log.Debug("The application manifest could not be located; searching previous versions...");
                if (cfg != null)
                {
                    Version[] localVersions = cfg.VersionManager.LocalVersions;

                    if (localVersions.Length > 0)
                    {
                        for (int i = 0; i < localVersions.Length; i++)
                        {
                            log.Debug("Searching version '" + localVersions[i] + "'...");

                            // Try to load an application manifest
                            // from this version!
                            try
                            {
                                string directory = Path.Combine(VersionRepositoryFolder, localVersions[i].ToString());
                                Uri    uri       = new Uri(
                                    Path.Combine(
                                        directory,
                                        LocalApplicationManifestFilename
                                        )
                                    );

                                log.Debug("Attempting to load manifest from '" + uri.AbsolutePath + "'...");

                                // Get the application manifest
                                appManifest = new ApplicationManifest(uri);
                            }
                            catch { }

                            // If we found an application manifest, then check to see
                            // if the application name matches our bootstrap executable
                            // name.  If it doesn't, then we're looking at a version
                            // of a *different* application, and should ignore it!
                            if (appManifest.EntryPoint != null &&
                                appManifest.EntryPoint.AssemblyIdentity != null &&
                                appManifest.EntryPoint.AssemblyIdentity.Name != null)
                            {
                                string manifestName = appManifest.EntryPoint.AssemblyIdentity.Name;
                                string appName      = Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly().Location);
                                if (!object.Equals(manifestName, appName))
                                {
                                    log.Debug("The application manifest for application '" + manifestName + "' was found and ignored (looking for '" + appName + "')");
                                    appManifest = null;
                                }
                            }

                            // We found an application manifest that we can use!
                            if (appManifest != null)
                            {
                                log.Debug("Application manifest found!");
                                break;
                            }
                        }
                    }
                }
            }

            return(appManifest);
        }
Пример #8
0
 public UpdateFile(ApplicationManifest parent)
 {
     Parent = parent;
 }
Пример #9
0
        public void Load()
        {
            try
            {
                if (!string.IsNullOrEmpty(CodeBase))
                {
                    // NOTE: Fixes bug #1831194 - URI segments already contain a slash.
                    string path = string.Join("", Parent.Uri.Segments);
                    path = Path.GetDirectoryName(path);
                    path = Path.Combine(path, CodeBase);
                    path += Parent.Uri.Query;

                    if (Parent is DeploymentManifest)
                    {
                        UriBuilder uriBuilder = new UriBuilder(
                            Parent.Uri.Scheme,
                            Parent.Uri.Host,
                            Parent.Uri.Port,
                            path);

                        ApplicationManifest = new ApplicationManifest(
                            this,
                            uriBuilder.Uri,
                            Parent.Username,
                            Parent.Password,
                            Parent.Domain);

                        // Add the application manifest to the deployment manifest
                        ((DeploymentManifest)Parent).ApplicationManifest = ApplicationManifest;
                    }
                }
            }
            catch
            {
                throw new ManifestException();
            }
        }