Пример #1
0
        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());
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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());
            }           
        }
Пример #4
0
 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);
     }
 }
Пример #5
0
        public void AddAssembliesToGac()
        {
#if NETFRAMEWORK
            var publish = new System.EnterpriseServices.Internal.Publish();

            var targetFolder = CustomTestFramework.GetProfilerTargetFolder();

            foreach (var file in Directory.GetFiles(targetFolder, "*.dll"))
            {
                publish.GacInstall(file);
            }
#endif
        }
Пример #6
0
        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;
        }
Пример #7
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
                {
                }
            }
        }
Пример #8
0
        /// <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");
        }
Пример #10
0
 public static void GacInstall(string filename)
 {
     System.EnterpriseServices.Internal.Publish gac = new System.EnterpriseServices.Internal.Publish();
     gac.GacInstall(filename);
 }
Пример #11
0
        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);
        }