private static void Set() { try { System.EnterpriseServices.Internal.Publish pub = new System.EnterpriseServices.Internal.Publish(); pub.GacInstall(thispath + @"\QueryAnalyzer_DataProvider.dll"); Console.WriteLine("Added QueryAnalyzer_DataProvider to gac."); { Configuration c = ConfigurationManager.OpenMachineConfiguration(); string cpath = c.FilePath; SetNode(cpath); string cpath32 = GetConfigPath32(cpath); if (cpath32 != null) { SetNode(cpath32); } } } catch (Exception e) { Console.WriteLine("Error occurred while installing QueryAnalyzer_DataProvider.dll: {0}", e.ToString()); } }
private static Assembly GetAssembly(string dstDir) { List <string> sources = new List <string>(); DirectoryInfo dirInfo = new DirectoryInfo(dstDir); FileInfo[] fileInfos = dirInfo.GetFiles(); //遍历文件夹 foreach (FileInfo fileInfo in fileInfos) { sources.Add(fileInfo.DirectoryName); } System.EnterpriseServices.Internal.Publish publish = new System.EnterpriseServices.Internal.Publish(); publish.GacInstall(AppDomain.CurrentDomain.BaseDirectory + @"Google.Protobuf.dll"); // 1.CSharpCodePrivoder CSharpCodeProvider objCSharpCodePrivoder = new CSharpCodeProvider(); // 3.CompilerParameters CompilerParameters objCompilerParameters = new CompilerParameters(); objCompilerParameters.ReferencedAssemblies.Add("System.dll"); objCompilerParameters.ReferencedAssemblies.Add("Google.Protobuf.dll"); objCompilerParameters.GenerateExecutable = false; objCompilerParameters.GenerateInMemory = true; // 4.CompilerResults CompilerResults cr = objCSharpCodePrivoder.CompileAssemblyFromSource(objCompilerParameters, sources.ToArray()); Assembly objAssembly = cr.CompiledAssembly; return(objAssembly); }
private static void Set() { try { System.EnterpriseServices.Internal.Publish pub = new System.EnterpriseServices.Internal.Publish(); pub.GacInstall(thispath + @"\QueryAnalyzer_DataProvider.dll"); Console.WriteLine("Added QueryAnalyzer_DataProvider to gac."); { Configuration c = ConfigurationManager.OpenMachineConfiguration(); string cpath = c.FilePath; SetNode(cpath); string cpath32 = GetConfigPath32(cpath); if (cpath32 != null) { SetNode(cpath32); } } } catch (Exception e) { Console.WriteLine("Error occurred while installing QueryAnalyzer_DataProvider.dll: {0}", e.ToString()); } }
public static void RemoveAssembliesFromGac(string searchPattern) { var assemblyPaths = GetGacAssemblyPaths(searchPattern); var backupPath = Path.Combine(Environment.CurrentDirectory, @"GAC_Backup"); foreach (var assemblyPath in assemblyPaths) { // For safety, only allow files with a "MEDSEEK" or "Agatha" prefix to be removed from GAC var fileName = new FileInfo(assemblyPath).Name; if (fileName.StartsWith("MEDSEEK", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("Agatha", StringComparison.OrdinalIgnoreCase)) { LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "Removing assembly ({0}) from GAC", fileName)); // Backup assembly BackupAssembly(assemblyPath, backupPath); // Remove assembly from GAC var publisher = new System.EnterpriseServices.Internal.Publish(); publisher.GacRemove(assemblyPath); } else LoggingUtils.WriteWarn(string.Format(CultureInfo.InvariantCulture, "Skipping removal of non-MEDSEEK assembly ({0}) from GAC", fileName)); } LoggingUtils.WriteInfo(string.Format(CultureInfo.InvariantCulture, "GAC assemblies backed up to: ({0})", backupPath), ConsoleColor.Green); }
protected override void ExecutePublish(System.EnterpriseServices.Internal.Publish publish, string path) { if (File.Exists(path)) { Log.LogMessage(MessageImportance.Normal, "GacRemove: {0}", path); publish.GacRemove(path); } }
public override void Uninstall(System.Collections.IDictionary savedState) { //#if DEBUG // MessageBox.Show("Uninstalling"); //#endif RegistryKey rk = Registry.CurrentUser.OpenSubKey(InstallerSupport.GetProperty("RegKey"), true); AssemblyName = Context.Parameters["AssemblyName"]; string InstallPath = rk.GetValue(InstallerSupport.GetProperty("InstallPathKey")).ToString(); string strAssemblyFiles = base.Context.Parameters["gacname"].ToString(); try { base.Uninstall(savedState); // remove from GAC if (strAssemblyFiles.Length > 0) { System.EnterpriseServices.Internal.Publish publish = new System.EnterpriseServices.Internal.Publish(); foreach (string strAssemblyFile in strAssemblyFiles.Split('|')) { try { string[] strAssembly = strAssemblyFile.Split('*'); // if (!strAssembly[0].EndsWith(".Core.dll")) //{ publish.GacRemove(Path.Combine(Path.Combine(InstallPath, "Control"), strAssembly[0])); //} } catch { } } } } catch { } try { // toolbox AddRemoveItems AddRemoveItemsDlg = new AddRemoveItems(strAssemblyFiles); AddRemoveItemsDlg.RemoveItem(); // license if (strAssemblyFiles.Contains("Core.dll")) { rk.DeleteValue("GAC"); rk.DeleteValue("InstallPath"); } } catch { }; // rk.DeleteSubKeyTree("Features"); rk.Close(); // } catch { // } }
protected override void ExecutePublish(System.EnterpriseServices.Internal.Publish publish, string path) { if (File.Exists(path)) { publish.GacInstall(path); Log.LogMessage(Microsoft.Build.Framework.MessageImportance.Normal, "GacInstall: {0}", path); } else { Log.LogError("GacInstall: File Not Found: {0}", path); } }
public void RemoveAssembliesFromGac() { #if NETFRAMEWORK var publish = new System.EnterpriseServices.Internal.Publish(); var targetFolder = CustomTestFramework.GetProfilerTargetFolder(); foreach (var file in Directory.GetFiles(targetFolder, "*.dll")) { publish.GacRemove(file); } #endif }
private static void Main(string[] args) { if (args.Length == 0) { ShowError("引数が不正です。"); return; } System.EnterpriseServices.Internal.Publish pub = new System.EnterpriseServices.Internal.Publish(); if (args[0] == "/i") { try { //GACにインストール pub.GacInstall(args[1]); } catch { ShowError("GACへのインストールに失敗しました。"); return; } } else if (args[0] == "/u") { try { //GACからアンインストール pub.GacRemove(args[1]); } catch { ShowError("GACからのアンインストールに失敗しました。"); return; } } else { ShowError("引数が不正です。"); return; } System.Environment.ExitCode = 0; }
public void Event() { System.EnterpriseServices.Internal.Publish foo = new System.EnterpriseServices.Internal.Publish(); string folder = Settings1.Default.Folder; DirectoryInfo info = new DirectoryInfo(folder); foreach (var item in info.GetFiles()) { if (item.Extension.Equals(".dll") && !item.Name.Contains("Microsoft")) { foo.GacRemove(item.FullName); foo.GacInstall(item.FullName); } else { } } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private async void Execute(object sender, EventArgs e) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); DTE dte = await this.ServiceProvider.GetServiceAsync(typeof(DTE)) as DTE; ISharePointProjectService sharePointProjectService = await this.ServiceProvider.GetServiceAsync(typeof(ISharePointProjectService)) as ISharePointProjectService; var selectedProjects = dte.ActiveSolutionProjects as Array; if (selectedProjects != null && selectedProjects.Length > 0) { var currentProject = sharePointProjectService.Convert <Project, ISharePointProject>((Project)selectedProjects.GetValue(0)) as ISharePointProject; var extService = new SPProjectExtService(currentProject); var assembliesToDeploy = extService.GetDeployableAssemblies(out string[] missing); if (assembliesToDeploy.Any()) { var gacService = new System.EnterpriseServices.Internal.Publish(); currentProject.ProjectService.Logger.ActivateOutputWindow(); currentProject.ProjectService.Logger.WriteLine("========= Copy to GAC ===========", LogCategory.Status); foreach (var assembly in assembliesToDeploy) { currentProject.ProjectService.Logger.WriteLine(Path.GetFileName(assembly) + "...", LogCategory.Status); gacService.GacInstall(assembly); } if (missing.Any()) { currentProject.ProjectService.Logger.WriteLine("Missing:", LogCategory.Status); foreach (var missingAssembly in missing) { currentProject.ProjectService.Logger.WriteLine(Path.GetFileName(missingAssembly), LogCategory.Status); } } currentProject.ProjectService.Logger.WriteLine($"===== Copy to GAC done at {DateTime.Now:hh:mm:ss} =====", LogCategory.Status); extService.RecyclePools(); } } }
public override void Commit(IDictionary savedState) { base.Commit(savedState); //System.Text.StringBuilder keys = new System.Text.StringBuilder() ; //foreach (var item in Context.Parameters.Keys) //{ // keys.Append(item.ToString()+"--"); //} //MessageBox.Show("Keys:" +keys.ToString()); //InstallLib(Context.Parameters["DP_targetPath"].ToString() + "lib/o2010pia.msi"); //InstallLib(Context.Parameters["DP_targetPath"].ToString() + "lib/vstor30.exe"); //if (!this.IsDllRegistered("SunVoteARS.dll")) //{ Register_Dll(Context.Parameters["DP_targetPath"].ToString() + "lib/MSCOMM32.OCX"); Register_Dll(Context.Parameters["DP_targetPath"].ToString() + "lib/SunVoteARS.dll"); Register_Dll(Context.Parameters["DP_targetPath"].ToString() + "lib/SunVoteLPT.dll"); //} System.EnterpriseServices.Internal.Publish pub = new System.EnterpriseServices.Internal.Publish(); pub.GacInstall(Context.Parameters["DP_targetPath"].ToString() + "lib/Interop.SunVoteARS.dll"); }
public static void GacUnInstall(string assemblyName) { System.EnterpriseServices.Internal.Publish gac = new System.EnterpriseServices.Internal.Publish(); gac.GacRemove(assemblyName); }
public static void GacInstall(string filename) { System.EnterpriseServices.Internal.Publish gac = new System.EnterpriseServices.Internal.Publish(); gac.GacInstall(filename); }
public override void Install(System.Collections.IDictionary stateSaver) { string strAssemblyFiles = ""; try { AssemblyName = Context.Parameters["AssemblyName"]; ControlName = Context.Parameters["ControlName"]; InstallPath = Context.Parameters["FullPath"]; // Add assemblies to GAC strAssemblyFiles = base.Context.Parameters["gacname"].ToString(); if (strAssemblyFiles.Length > 0) { System.EnterpriseServices.Internal.Publish publish = new System.EnterpriseServices.Internal.Publish(); bool GacInstall = (Context.Parameters["CHECKBOXGAC"].ToString() == "1"); InstallerSupport.Instance.SetNetRixRegistryValue((GacInstall) ? "1" : "0", "GAC"); foreach (string strAssemblyFile in strAssemblyFiles.Split('|')) { try { string[] strAssembly = strAssemblyFile.Split('*'); if (strAssembly[0].EndsWith(".Core.dll")) { //publish.GacInstall(Path.Combine(Path.Combine(InstallPath, "Control"), strAssembly[0])); InstallerSupport.Instance.SetNetRixRegistryValue(InstallPath, InstallerSupport.GetProperty("InstallPathKey")); } if (GacInstall) { publish.GacInstall(Path.Combine(Path.Combine(InstallPath, "Control"), strAssembly[0])); //MessageBox.Show("Gac installed"); } // MessageBox.Show(strAssembly[0] + " : " + strAssembly[1]); if (!(strAssembly[0].EndsWith(".Core.dll"))) { Type type = GetEditorType(strAssembly[0], strAssembly[1], GacInstall); if (type == null) { continue; } else { InstallerSupport.Instance.SetLICFileContent(null, "", type, "Features", false); } } } catch { continue; } } } // Toolbox if (Context.Parameters["CHECKBOXTOOLBOX"].ToString() == "1") { try { AddRemoveItems AddRemoveItemsDlg = new AddRemoveItems(strAssemblyFiles); AddRemoveItemsDlg.InstallPath = InstallPath; AddRemoveItemsDlg.ShowDialog(); } catch { envDte = false; } } // Check for license condition //if (Context.Parameters["CHECKBOXLICENSE"].ToString() == "1") //{ // LicenseManager licenseManager = new LicenseManager(); // licenseManager.ShowDialog(); // // LicenseStorage.LaunchProg(); //} } // try catch (Exception ex) { if (envDte != false) { MessageBox.Show(ex.Message + "\n\n" + ex.StackTrace, "Error running Installer"); } throw new InstallException(ex.Message, ex); //rethrow } base.Install(stateSaver); }
public override void Uninstall(IDictionary savedState) { base.Uninstall(savedState); System.EnterpriseServices.Internal.Publish pub = new System.EnterpriseServices.Internal.Publish(); pub.GacRemove(Context.Parameters["DP_targetPath"].ToString() + "lib/Interop.SunVoteARS.dll"); }