Esempio n. 1
0
        /// <summary>If the <paramref name="file"/> is a strong-named assembly, applies the XML merge.</summary>
        /// <param name="file">The assembly file.</param>
        /// <param name="xmlMergeFile">The XML merge file name.</param>
        /// <returns><c>true</c> if the XML Merge was applied successfully, <c>false</c> if the file was not a strong-named assembly or could not be read.</returns>
        private bool ApplyXmlMerge(InstallFile file, string xmlMergeFile)
        {
            var assemblyFileFullPath = Path.Combine(this.PhysicalBasePath, file.FullName);

            if (!File.Exists(assemblyFileFullPath))
            {
                return(false);
            }

            var assemblyName   = ReadAssemblyName(assemblyFileFullPath);
            var publicKeyToken = ReadPublicKey(assemblyName);

            if (string.IsNullOrEmpty(publicKeyToken))
            {
                return(false);
            }

            var name            = assemblyName.Name;
            var assemblyVersion = assemblyName.Version;
            var newVersion      = assemblyVersion.ToString();

            var xmlMergePath = Path.Combine(Globals.InstallMapPath, "Config", xmlMergeFile);
            var xmlMergeDoc  = GetXmlMergeDoc(xmlMergePath, name, publicKeyToken, OldVersion, newVersion);
            var xmlMerge     = new XmlMerge(xmlMergeDoc, this.Package.Version.ToString(), this.Package.Name);

            xmlMerge.UpdateConfigs();

            return(true);
        }
Esempio n. 2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UnInstall method uninstalls the config component
        /// </summary>
        /// <history>
        ///     [cnurse]	08/04/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void UnInstall()
        {
            if (string.IsNullOrEmpty(_UninstallFileName))
            {
                //Create an XmlDocument for the config file
                _TargetConfig = new XmlDocument();
                TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                //Create XmlMerge instance from UnInstallConfig source
                var merge = new XmlMerge(new StringReader(UnInstallConfig), Package.Version.ToString(), Package.Name);

                //Update the Config file - Note that this method does save the file
                merge.UpdateConfig(TargetConfig, TargetFile.FullName);
            }
            else
            {
                //Process external file
                string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
                if (File.Exists(strConfigFile))
                {
                    //Create XmlMerge instance from config file source
                    StreamReader stream = File.OpenText(strConfigFile);
                    var          merge  = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");

                    //Process merge
                    merge.UpdateConfigs();

                    //Close stream
                    stream.Close();
                }
            }
        }
 public override void Install()
 {
     try
     {
         if (string.IsNullOrEmpty(_FileName))
         {
             Util.BackupFile(TargetFile, PhysicalSitePath, Log);
             _TargetConfig = new XmlDocument();
             TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
             XmlMerge merge = new XmlMerge(new StringReader(InstallConfig), this.Package.Version.ToString(), this.Package.Name);
             merge.UpdateConfig(TargetConfig);
             Completed = true;
             Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
         }
         else
         {
             string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _FileName);
             if (File.Exists(strConfigFile))
             {
                 StreamReader stream = File.OpenText(strConfigFile);
                 XmlMerge     merge  = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");
                 merge.UpdateConfigs();
                 stream.Close();
                 Completed = true;
                 Log.AddInfo(Util.CONFIG_Updated);
             }
         }
     }
     catch (Exception ex)
     {
         Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
     }
 }
        //this is not used now. Kept for reference if in future needs to
        // set config changes by string directly
        private void MergeFileUpdated()
        {
            var AssemblyBinding = @"<configuration>
              <nodes configfile=""Web.config"">
                <node path=""/configuration/runtime/ab:assemblyBinding"" 
                      action=""update"" 
                      collision=""save"" 
                      targetpath=""/configuration/runtime/ab:assemblyBinding/ab:dependentAssembly[ab:assemblyIdentity/@name='System.Web.Mvc'][ab:assemblyIdentity/@publicKeyToken='31bf3856ad364e35']"" 
                      nameSpace=""urn:schemas-microsoft-com:asm.v1"" 
                      nameSpacePrefix=""ab"">
                  <dependentAssembly xmlns=""urn:schemas-microsoft-com:asm.v1"">
                    <assemblyIdentity name=""System.Web.Mvc"" publicKeyToken=""31bf3856ad364e35"" />
                    <bindingRedirect oldVersion=""1.0.0.0-4.0.0.0"" newVersion=""4.0.0.1""/>
                  </dependentAssembly>
                </node>
              </nodes>
            </configuration>";

            using (TextReader sr = new StringReader(AssemblyBinding))
            {
                var app   = DotNetNukeContext.Current.Application;
                var merge = new XmlMerge(sr, Globals.FormatVersion(app.Version), app.Description);
                merge.UpdateConfigs();
            }
        }
 public override void Install()
 {
     try
     {
         if (string.IsNullOrEmpty(_FileName))
         {
             Util.BackupFile(TargetFile, PhysicalSitePath, Log);
             _TargetConfig = new XmlDocument();
             TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
             XmlMerge merge = new XmlMerge(new StringReader(InstallConfig), this.Package.Version.ToString(), this.Package.Name);
             merge.UpdateConfig(TargetConfig);
             Completed = true;
             Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
         }
         else
         {
             string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _FileName);
             if (File.Exists(strConfigFile))
             {
                 StreamReader stream = File.OpenText(strConfigFile);
                 XmlMerge merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");
                 merge.UpdateConfigs();
                 stream.Close();
                 Completed = true;
                 Log.AddInfo(Util.CONFIG_Updated);
             }
         }
     }
     catch (Exception ex)
     {
         Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Installs support for Telerik Charting in the web.config.
 /// </summary>
 private void InstallTelerikCharting()
 {
     using (Stream xmlMergeManifest = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Engage.Dnn.Dashboard.01.00.00.xml"))
     {
         XmlMerge configMerge = new XmlMerge(xmlMergeManifest, "01.00.00", "Engage: Dashboard");
         configMerge.UpdateConfigs();
         this.Response.Redirect(Globals.NavigateURL());
     }
 }
Esempio n. 7
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the config component
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void Install()
        {
            try
            {
                if (string.IsNullOrEmpty(_FileName))
                {
                    //First backup the config file
                    Util.BackupFile(TargetFile, PhysicalSitePath, Log);

                    //Create an XmlDocument for the config file
                    _TargetConfig = new XmlDocument {
                        XmlResolver = null
                    };
                    TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                    //Create XmlMerge instance from InstallConfig source
                    _xmlMerge = new XmlMerge(new StringReader(InstallConfig), Package.Version.ToString(), Package.Name);

                    //Update the Config file - Note that this method does not save the file - we will save it in Commit
                    _xmlMerge.UpdateConfig(TargetConfig);
                    Completed = true;
                    Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
                }
                else
                {
                    //Process external file
                    string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _FileName);
                    if (File.Exists(strConfigFile))
                    {
                        //Create XmlMerge instance from config file source
                        using (var stream = File.OpenText(strConfigFile))
                        {
                            _xmlMerge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");

                            //Process merge
                            _xmlMerge.UpdateConfigs(false);
                        }

                        Completed = true;
                        Log.AddInfo(Util.CONFIG_Updated);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
            }
        }
        private void ExecuteXmlMerge(string path)
        {
            if (!File.Exists(path))
            {
                return;
            }

            var doc = new XmlDocument();

            doc.Load(path);

            var app   = DotNetNukeContext.Current.Application;
            var merge = new XmlMerge(doc, Globals.FormatVersion(app.Version), app.Description);

            merge.UpdateConfigs();
        }
 public override void UnInstall()
 {
     if (string.IsNullOrEmpty(_UninstallFileName))
     {
         _TargetConfig = new XmlDocument();
         TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
         XmlMerge merge = new XmlMerge(new StringReader(UnInstallConfig), this.Package.Version.ToString(), this.Package.Name);
         merge.UpdateConfig(TargetConfig, TargetFile.FullName);
     }
     else
     {
         string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
         if (File.Exists(strConfigFile))
         {
             StreamReader stream = File.OpenText(strConfigFile);
             XmlMerge     merge  = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");
             merge.UpdateConfigs();
             stream.Close();
         }
     }
 }
Esempio n. 10
0
        /// <summary>If tyhe <paramref name="file"/> is a strong-named assembly, applies the XML merge.</summary>
        /// <param name="file">The assembly file.</param>
        /// <param name="xmlMergeFile">The XML merge file name.</param>
        /// <returns><c>true</c> if the XML Merge was applied successfully, <c>false</c> if the file was not a strong-named assembly.</returns>
        private bool ApplyXmlMerge(InstallFile file, string xmlMergeFile)
        {
            var assemblyName = AssemblyName.GetAssemblyName(Path.Combine(this.PhysicalBasePath, file.FullName));

            if (!assemblyName.Flags.HasFlag(AssemblyNameFlags.PublicKey))
            {
                return(false);
            }

            var name           = assemblyName.Name;
            var publicKeyToken = PublicKeyTokenRegex.Match(assemblyName.FullName).Groups[1].Value;
            var oldVersion     = "0.0.0.0-" + new Version(assemblyName.Version.Major, short.MaxValue, short.MaxValue, short.MaxValue);
            var newVersion     = assemblyName.Version.ToString();

            var xmlMergePath = Path.Combine(Globals.InstallMapPath, "Config", xmlMergeFile);
            var xmlMergeDoc  = GetXmlMergeDoc(xmlMergePath, name, publicKeyToken, oldVersion, newVersion);
            var xmlMerge     = new XmlMerge(xmlMergeDoc, file.Version.ToString(), this.Package.Name);

            xmlMerge.UpdateConfigs();

            return(true);
        }
Esempio n. 11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UnInstall method uninstalls the config component
        /// </summary>
        /// <history>
        /// 	[cnurse]	08/04/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void UnInstall()
        {
            if (string.IsNullOrEmpty(_UninstallFileName))
            {
				//Create an XmlDocument for the config file
                _TargetConfig = new XmlDocument();
                TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                //Create XmlMerge instance from UnInstallConfig source
                var merge = new XmlMerge(new StringReader(UnInstallConfig), Package.Version.ToString(), Package.Name);

                //Update the Config file - Note that this method does save the file
                merge.UpdateConfig(TargetConfig, TargetFile.FullName);
            }
            else
            {
				//Process external file
                string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
                if (File.Exists(strConfigFile))
                {
					//Create XmlMerge instance from config file source
                    StreamReader stream = File.OpenText(strConfigFile);
                    var merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");

                    //Process merge
                    merge.UpdateConfigs();

                    //Close stream
                    stream.Close();
                }
            }
        }
Esempio n. 12
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the config component
        /// </summary>
        /// <history>
        /// 	[cnurse]	08/04/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void Install()
        {
            try
            {
                if (string.IsNullOrEmpty(_FileName))
                {
					//First backup the config file
                    Util.BackupFile(TargetFile, PhysicalSitePath, Log);

                    //Create an XmlDocument for the config file
                    _TargetConfig = new XmlDocument();
                    TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                    //Create XmlMerge instance from InstallConfig source
                    var merge = new XmlMerge(new StringReader(InstallConfig), Package.Version.ToString(), Package.Name);

                    //Update the Config file - Note that this method does not save the file - we will save it in Commit
                    merge.UpdateConfig(TargetConfig);
                    Completed = true;
                    Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
                }
                else
                {
					//Process external file
                    string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _FileName);
                    if (File.Exists(strConfigFile))
                    {
						//Create XmlMerge instance from config file source
                        using (var stream = File.OpenText(strConfigFile))
                        {
                            _xmlMerge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");

                            //Process merge
                            _xmlMerge.UpdateConfigs(false);
                        }

                        Completed = true;
                        Log.AddInfo(Util.CONFIG_Updated);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
            }
        }
 public override void UnInstall()
 {
     if (string.IsNullOrEmpty(_UninstallFileName))
     {
         _TargetConfig = new XmlDocument();
         TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
         XmlMerge merge = new XmlMerge(new StringReader(UnInstallConfig), this.Package.Version.ToString(), this.Package.Name);
         merge.UpdateConfig(TargetConfig, TargetFile.FullName);
     }
     else
     {
         string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
         if (File.Exists(strConfigFile))
         {
             StreamReader stream = File.OpenText(strConfigFile);
             XmlMerge merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");
             merge.UpdateConfigs();
             stream.Close();
         }
     }
 }
        /// <summary>Applies the XML Merge instructions to the configuration files.</summary>
        /// <param name="sourceFileName">Path to the XML Merge configuration file.</param>
        private void ApplyXmlMerge(string sourceFileName)
        {
            var xmlMerge = new XmlMerge(sourceFileName, this.ModuleInfo.DesktopModule.Version, this.ModuleInfo.DesktopModule.FriendlyName);

            xmlMerge.UpdateConfigs();
        }
Esempio n. 15
0
        /// <summary>Applies the XML Merge instructions to the configuration files.</summary>
        /// <param name="sourceDoc">The XML document with the merge instructions.</param>
        public void ApplyXmlMerge(XDocument sourceDoc)
        {
            var xmlMerge = new XmlMerge(sourceDoc.AsXmlDocument(), this.Version, this.Sender);

            xmlMerge.UpdateConfigs();
        }
Esempio n. 16
0
        /// <summary>Applies the XML Merge instructions to the configuration files.</summary>
        /// <param name="sourceFileName">Path to the XML Merge configuration file.</param>
        public void ApplyXmlMerge(string sourceFileName)
        {
            var xmlMerge = new XmlMerge(sourceFileName, this.Version, this.Sender);

            xmlMerge.UpdateConfigs();
        }
        /// <summary>Applies the XML Merge instructions to the configuration files.</summary>
        /// <param name="sourceDoc">The XML document with the merge instructions.</param>
        private void ApplyXmlMerge(XDocument sourceDoc)
        {
            var xmlMerge = new XmlMerge(sourceDoc.AsXmlDocument(), this.ModuleInfo.DesktopModule.Version, this.ModuleInfo.DesktopModule.FriendlyName);

            xmlMerge.UpdateConfigs();
        }
Esempio n. 18
0
 /// <summary>
 /// Installs support for Telerik Charting in the web.config.
 /// </summary>
 private void InstallTelerikCharting()
 {
     using (Stream xmlMergeManifest = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Engage.Dnn.Dashboard.01.00.00.xml"))
     {
         XmlMerge configMerge = new XmlMerge(xmlMergeManifest, "01.00.00", "Engage: Dashboard");
         configMerge.UpdateConfigs();
         this.Response.Redirect(Globals.NavigateURL());
     }
 }