Inheritance: Object
コード例 #1
0
 private SerialConnection()
 {
     Devices = new ObservableCollection<DeviceInformation>();
     State = ConnectionState.Disconnected;
     Debugger = Debugger.Instance;
     LookForBluetoothDevices();
 }
コード例 #2
0
 public override void Write(string message)
 {
     if (DiagDebugger.IsLogging())
     {
         DiagDebugger.Log(0, null, message);
     }
 }
コード例 #3
0
        public bool Execute()
        {
            try
            {
                if (Keys.ControlKey.IsPressed())
                {
                    if (MessageBox.Show("Debug?", "Debug CleanHydraInstaller", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Debugger.Launch();
                    }
                }

                if (this.Configuration == "PreRelease")
                {
                    var      solutionPath     = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%HYDRASOLUTIONPATH%"));
                    var      productFilePath  = Path.Combine(solutionPath, @"Hydra.InstallerStandalone\Product.wxs");
                    var      document         = XDocument.Load(productFilePath);
                    var      namespaceManager = new XmlNamespaceManager(new NameTable());
                    XElement elementFeature;
                    XElement elementDirectory;

                    namespaceManager.AddNamespace("wi", "http://schemas.microsoft.com/wix/2006/wi");

                    elementFeature   = document.XPathSelectElement("/wi:Wix/wi:Product/wi:Feature", namespaceManager);
                    elementDirectory = document.XPathSelectElement("/wi:Wix/wi:Fragment/wi:Directory", namespaceManager);

                    elementFeature.Elements().Remove();
                    elementDirectory.Elements().Remove();

                    document.Save(productFilePath, SaveOptions.DisableFormatting);
                }
            }
            catch (Exception ex)
            {
                var error = string.Format("Error installing Hydra Visual Studio templates. \r\nError: {0}", ex.ToString());

                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, error, "", "", DateTime.Now);
                this.BuildEngine.LogErrorEvent(message);

                Console.WriteLine(error);

                return(false);
            }

            return(true);
        }
コード例 #4
0
        internal static void Break(this PSCmdlet invokedCmdLet)
        {
            while (!Debugger.IsAttached)
            {
                invokedCmdLet.WriteWarning($"Waiting for debugger to attach to process {Process.GetCurrentProcess().Id}");
                for (var i = 0; i < 50; i++)
                {
                    if (Debugger.IsAttached)
                    {
                        break;
                    }
                    Thread.Sleep(100);
                    invokedCmdLet.WriteProgress(new ProgressRecord(0, "Waiting for Debugger",
                        "Waiting for Debugger to attach to process"));
                }
            }

            Debugger.Break();
        }
コード例 #5
0
        internal static void Break(this PSCmdlet invokedCmdLet)
        {
            while (!Debugger.IsAttached)
            {
                Console.Error.WriteLine($"Waiting for debugger to attach to process {Process.GetCurrentProcess().Id}");
                for (var i = 0; i < 50; i++)
                {
                    if (Debugger.IsAttached)
                    {
                        break;
                    }

                    Thread.Sleep(100);
                    Console.Error.Write(".");
                }

                Console.Error.WriteLine();
            }

            Debugger.Break();
        }
コード例 #6
0
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            Debugger.Break();
            Debug.WriteLine(string.Format("OpenWrapBootstrapper: Connecting solution add-in, .net version {0}", Environment.Version));
            var dte = application as DTE;

            if (dte == null)
            {
                return;
            }
            var engine = Engine(dte);

            if (engine == null)
            {
                return;
            }

            foreach (var project in from dteProject in dte.Solution.Projects.OfType <Project>()
                     select engine.Load(dteProject.FullName))
            {
                project.RunTarget("OpenWrap-Initialize");
            }
        }
コード例 #7
0
ファイル: Process.cs プロジェクト: Zinterax/meddle
        public Process(PythonBoss pyBoss, Controller parent, dynamic pyProcess)
        {
            _targets = new Hashtable(10);
            _pyBoss = pyBoss;
            _parent = parent;
            _targetsToLoad = new List<object>(10);
            PyProcess = pyProcess;
            _name = PyProcess.get_name();

            try
            {
                // Initialize the DotNet process class
                int pid = PyProcess.get_pid();

                if (pid >= 0)
                {
                    ProcessDotNet = System.Diagnostics.Process.GetProcessById(pid);

                    // Start the debugger instance
                    _debugger = new Debugger(pid, this);
                }
                else
                {
                    Console.WriteLine(string.Format("ERROR: Constructor of dot net class 'Process' {0} failed. Python process class returned 'get_pid()' of -1, this is invalid.", _name));
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("ERROR: Constructor of python class 'Process' {0} failed:", _name));
                Console.WriteLine(e.ToString());
                return;
            }

            Initialized = true;
        }
コード例 #8
0
ファイル: Tracer.cs プロジェクト: svetek/Profiler
        public static void WaitForDebugger()
        {
            if (_triggered)
            {
                return;
            }

            var debug = Environment.GetEnvironmentVariable("PROFILER_DEBUG")?.ToLowerInvariant();

            if (!new[] { "on", "yes", "true", "1" }.Contains(debug))
            {
                return;
            }

            while (!Debugger.IsAttached)
            {
                var process = Process.GetCurrentProcess();
                Console.WriteLine($"Waiting for debugger {process.Id} - {process.ProcessName}");
                Thread.Sleep(1000);
            }

            _triggered = true;
            Debugger.Break();
        }
コード例 #9
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Member

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken);

            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            var m_objDTE = (DTE)GetService(typeof(DTE));

            Assumes.Present(m_objDTE);

            commandEvents = m_objDTE.Events.CommandEvents;

            commandEvents.BeforeExecute += delegate(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                var objCommand = m_objDTE.Commands.Item(Guid, ID);
                if (objCommand != null)
                {
                    var bindings = objCommand.Bindings as object[];
                    if (bindings != null && bindings.Any())
                    {
                        var shortcuts = GetBindings(bindings);
                        if (shortcuts.Any())
                        {
                            lock (typeof(ShortcutCommanderPackage))
                            {
                                var shortcutActive = false;
                                foreach (var shortcut in shortcuts)
                                {
                                    var sequenceActive = false;

                                    var shortcutSequences = shortcut.Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                                    foreach (var shortcutSequence in shortcutSequences)
                                    {
                                        var keyActive    = true;
                                        var shortcutKeys = shortcutSequence.Split('+');

                                        foreach (var shortcutKey in shortcutKeys)
                                        {
                                            Key key;
                                            switch (shortcutKey)
                                            {
                                            case "Ctrl":
                                                key = Key.LeftCtrl;
                                                break;

                                            case "Alt":
                                                key = Key.LeftAlt;
                                                break;

                                            case "Shift":
                                                key = Key.LeftShift;
                                                break;

                                            case "Bkspce":
                                                key = Key.Back;
                                                break;

                                            case "Del":
                                                key = Key.Delete;
                                                break;

                                            case "Ins":
                                                key = Key.Insert;
                                                break;

                                            case "PgDn":
                                                key = Key.PageDown;
                                                break;

                                            case "PgUp":
                                                key = Key.PageUp;
                                                break;

                                            case "Down Arrow":
                                                key = Key.Down;
                                                break;

                                            case "Up Arrow":
                                                key = Key.Up;
                                                break;

                                            case "Left Arrow":
                                                key = Key.Left;
                                                break;

                                            case "Right Arrow":
                                                key = Key.Right;
                                                break;

                                            default:
                                                if (!Enum.TryParse(shortcutKey, out key))
                                                {
                                                    if (Debugger.IsAttached)
                                                    {
                                                        Debugger.Break();
                                                    }
                                                    continue;
                                                }
                                                break;
                                            }

                                            if (!Keyboard.IsKeyDown(key))
                                            {
                                                keyActive = false;
                                                break;
                                            }
                                        }

                                        if (keyActive)
                                        {
                                            sequenceActive = true;
                                            break;
                                        }
                                    }

                                    if (sequenceActive)
                                    {
                                        shortcutActive = true;
                                        break;
                                    }
                                }

                                if (!shortcutActive)
                                {
                                    if (window != null)
                                    {
                                        window.Close();
                                        window = null;
                                    }

                                    window = new HotkeyWindow();

                                    var contentBlock = window.CommandText.Children;
                                    contentBlock.Clear();

                                    var space = " " + Convert.ToChar(160) + " ";
                                    for (var i = 0; i < shortcuts.Length; i++)
                                    {
                                        if (i > 0)
                                        {
                                            contentBlock.Add(new TextBlock(new Run(space + " or " + space))
                                            {
                                                Opacity = 0.5
                                            });
                                        }
                                        contentBlock.Add(new TextBlock(new Run(shortcuts[i])));
                                    }

                                    window.Show();
                                }
                            }
                        }
                    }
                }
            };
        }
コード例 #10
0
        public void RegisterPackage(string packageIdentifier, string packagePath)
        {
            var fileInfo           = new FileInfo(packagePath);
            var outdated           = false;
            var installedExtension = (IInstalledExtension)null;

            if (!fileInfo.Exists)
            {
                var openFileDialog = new OpenFileDialog();
                var ext            = Path.GetExtension(packagePath).Remove(0, 1);
                var window         = new WindowWrapper(Process.GetCurrentProcess().MainWindowHandle);

                openFileDialog.CheckFileExists  = true;
                openFileDialog.Filter           = string.Format("Package files (*.{0})|*.{0}", ext);
                openFileDialog.DefaultExt       = ext;
                openFileDialog.InitialDirectory = Environment.ExpandEnvironmentVariables("%HYDRASOLUTIONPATH%");
                openFileDialog.Title            = string.Format("Select file for '{0}'", packagePath);

                if (openFileDialog.ShowDialog(window) != DialogResult.OK)
                {
                    var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error finding package '{0}' at '{1}'", packageIdentifier, packagePath) + ". Please select file from bin folder of Package Project or get latest from TFS.", "", "", DateTime.Now);
                    this.BuildEngine.LogErrorEvent(message);

                    return;
                }
                else
                {
                    File.Copy(openFileDialog.FileName, packagePath);
                }
            }

            fileInfo = new FileInfo(packagePath);

            if (!fileInfo.Exists)
            {
                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error finding package '{0}' at '{1}'", packageIdentifier, packagePath) + ". Please select file from bin folder of Package Project or get latest from TFS.", "", "", DateTime.Now);
                this.BuildEngine.LogErrorEvent(message);

                return;
            }

            if (fileInfo.Extension == ".dll")
            {
                // is a dll, use RegPkg

                var projectFile = new FileInfo(this.BuildEngine.ProjectFileOfTaskNode);
                var regPkgPath  = Path.Combine(solutionPath, @"Binaries\SolutionLibraries\RegPkg.exe");

                var process   = new Process();
                var startInfo = new ProcessStartInfo
                {
                    UseShellExecute        = false,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    FileName  = regPkgPath,
                    Arguments = "/unregister" + " \"" + fileInfo.FullName + "\""
                };

                process.StartInfo = startInfo;
                process.Start();

                var result = process.StandardOutput.ReadToEnd();
                result += "\r\n" + process.StandardError.ReadToEnd();

                process.WaitForExit();

                if (process.ExitCode != 0)
                {
                    var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error unregistering package '{0}'. ", packageIdentifier) + result + " Exit code = " + process.ExitCode.ToString() + ". You can try running Visual Studio as Administrator to uninstall this component.", "", "", DateTime.Now);
                    this.BuildEngine.LogErrorEvent(message);
                }
                else
                {
                    var message = new BuildMessageEventArgs(string.Format("'{0}' package unregistered successfully.  ", packageIdentifier) + result, "", "", MessageImportance.High);
                    this.BuildEngine.LogMessageEvent(message);
                }

                process   = new Process();
                startInfo = new ProcessStartInfo
                {
                    UseShellExecute        = false,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true,
                    FileName  = regPkgPath,
                    Arguments = "/root:Software\\Microsoft\\VisualStudio\\10.0 \"" + packagePath + "\""
                };

                process.StartInfo = startInfo;
                process.Start();

                result  = process.StandardOutput.ReadToEnd();
                result += "\r\n" + process.StandardError.ReadToEnd();

                process.WaitForExit();

                if (process.ExitCode != 0)
                {
                    var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error registering package '{0}'. ", packageIdentifier) + result + " Exit code = " + process.ExitCode.ToString() + ". You can try running Visual Studio as Administrator to install this component.", "", "", DateTime.Now);
                    this.BuildEngine.LogErrorEvent(message);

                    return;
                }
                else
                {
                    var message = new BuildMessageEventArgs(string.Format("'{0}' package registered successfully.  ", packageIdentifier) + result, "", "", MessageImportance.High);
                    this.BuildEngine.LogMessageEvent(message);
                }
            }
            else
            {
                // is vsx

                Action <DateTime, DirectoryInfo> checkOutdated = null;

                checkOutdated = new Action <DateTime, DirectoryInfo>((date, directory) =>
                {
                    foreach (var file in directory.GetFiles())
                    {
                        if (file.Extension != ".vsix" && file.Extension != ".zip")
                        {
                            if (DateTime.Compare(file.LastWriteTime, date) > 0)
                            {
                                outdated = true;
                                return;
                            }
                        }
                    }

                    foreach (var dir in directory.GetDirectories())
                    {
                        checkOutdated(date, dir);
                    }
                });

                // lets do another workaround due to Microsoft stupidity

                //var extensionPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\VisualStudio\10.0\Extensions\Cloud IDEaaS");
                //var folder = new DirectoryInfo(extensionPath);

                //Action<DirectoryInfo> deleteDeleteMeFiles = null;

                //deleteDeleteMeFiles = new Action<DirectoryInfo>(directory =>
                //{
                //    foreach (var file in directory.GetFiles("*.deleteme"))
                //    {
                //        try
                //        {
                //            file.Delete();
                //        }
                //        catch (Exception ex)
                //        {
                //            try
                //            {
                //                RestartExplorer();
                //                file.Delete();
                //            }
                //            catch
                //            {
                //                try
                //                {
                //                    var hydraCopyPath = Path.Combine(solutionPath, @"Binaries\SolutionLibraries\HydraCopy.exe");

                //                    var process = new Process();
                //                    var startInfo = new ProcessStartInfo
                //                    {
                //                        UseShellExecute = false,
                //                        RedirectStandardError = true,
                //                        RedirectStandardOutput = true,
                //                        CreateNoWindow = true,
                //                        FileName = hydraCopyPath,
                //                        Arguments = "\"" + file.FullName + "\" /delete"
                //                    };

                //                    process.StartInfo = startInfo;
                //                    process.Start();

                //                    process.WaitForExit();

                //                    if (process.ExitCode != 0)
                //                    {
                //                        throw new Exception(string.Format("HydraCopy.exe exited with error code = '{0}'", process.ExitCode));
                //                    }
                //                }
                //                catch (Exception ex2)
                //                {
                //                    var message2 = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error launching HydraCopy.exe to remove leftover files for package '{0}'. Error={1}. You can try rebuilding or restarting Visual Studio to remove these files.", packageIdentifier, ex2.ToString()), "", "", DateTime.Now);
                //                    this.BuildEngine.LogErrorEvent(message2);
                //                }

                //                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error removing leftover files for package '{0}'. Error={1}. You can try rebuilding or restarting Visual Studio to remove these files.", packageIdentifier, ex.ToString()), "", "", DateTime.Now);
                //                this.BuildEngine.LogErrorEvent(message);
                //            }
                //        }
                //    }

                //    foreach (var dir in directory.GetDirectories())
                //    {
                //        deleteDeleteMeFiles(dir);
                //    }
                //});

                //if (folder.Exists)
                //{
                //    deleteDeleteMeFiles(folder);
                //}

                //if (Environment.Is64BitOperatingSystem)
                //{
                //    extensionPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), @"Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Cloud IDEaaS");
                //}
                //else
                //{
                //    extensionPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Cloud IDEaaS");
                //}

                //folder = new DirectoryInfo(extensionPath);

                //if (folder.Exists)
                //{
                //    deleteDeleteMeFiles(folder);
                //}

                if (extensionManager.TryGetInstalledExtension(packageIdentifier, out installedExtension))
                {
                    checkOutdated(installedExtension.InstalledOn.DateTime, fileInfo.Directory);

                    if (!outdated)
                    {
                        return;
                    }
                }

                if (outdated)
                {
                    // see if there are templates in folder the VSIX installer will balk

                    fileInfo = new FileInfo(Path.Combine(fileInfo.DirectoryName, "extension.vsixmanifest"));

                    if (fileInfo.Exists)
                    {
                        var stream          = File.OpenRead(fileInfo.FullName);
                        var installLocation = Path.Combine(Environment.ExpandEnvironmentVariables("%LocalAppData%"), @"Microsoft\VisualStudio\10.0\Extensions");
                        var _namespace      = "vs";

                        stream.Seek(0, SeekOrigin.Begin);

                        var xPathDocument = new XPathDocument(stream);

                        stream.Close();

                        var nsmgr = new XmlNamespaceManager(new NameTable());
                        nsmgr.AddNamespace(_namespace, "http://schemas.microsoft.com/developer/vsx-schema/2010");

                        var navigator = xPathDocument.CreateNavigator();

                        var iter = navigator.Select(string.Format("{0}:Vsix/{0}:Identifier/{0}:Author", _namespace), nsmgr);
                        iter.MoveNext();

                        var author = iter.Current.Value;

                        iter = navigator.Select(string.Format("{0}:Vsix/{0}:Identifier/{0}:Name", _namespace), nsmgr);
                        iter.MoveNext();

                        var name = iter.Current.Value;

                        iter = navigator.Select(string.Format("{0}:Vsix/{0}:Identifier/{0}:Version", _namespace), nsmgr);
                        iter.MoveNext();

                        var version = iter.Current.Value;

                        installLocation = Path.Combine(installLocation, string.Format(@"{0}\{1}\{2}", author, name, version));

                        var dirInstall = new DirectoryInfo(installLocation);

                        if (dirInstall.Exists)
                        {
                            try
                            {
                                dirInstall.Delete(true);
                            }
                            catch
                            {
                                try
                                {
                                    RestartExplorer();
                                    dirInstall.Delete(true);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }

                    try
                    {
                        if (extensionManager.IsInstalled(installedExtension))
                        {
                            extensionManager.Uninstall(installedExtension);
                        }

                        var message = new BuildMessageEventArgs(string.Format("'{0}' package unregistered successfully.  ", packageIdentifier), "", "", MessageImportance.High);
                        this.BuildEngine.LogMessageEvent(message);
                    }
                    catch (Exception ex)
                    {
                        var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error unregistering package '{0}'. Error={1}", packageIdentifier, ex.ToString()), "", "", DateTime.Now);
                        this.BuildEngine.LogErrorEvent(message);
                    }
                }

                if (installedExtension == null || outdated)
                {
                    try
                    {
                        var debug = false;

                        if (debug)
                        {
                            var package = ZipPackage.Open(@"C:\Users\u164225\Documents\Visual Studio 2010\My Exported Templates\DummyProject.vsix");
                            var parts   = package.GetParts();

                            package.Close();

                            package = ZipPackage.Open(packagePath);
                            parts   = package.GetParts();

                            package.Close();

                            var installExtension2 = extensionManager.CreateInstallableExtension(@"C:\Users\u164225\Documents\Visual Studio 2010\My Exported Templates\DummyProject.vsix");
                            var reason2           = extensionManager.Install(installExtension2, false);
                            var message2          = new BuildMessageEventArgs(string.Format("'{0}' package registered successfully with restart reason={1}.  ", "DummyProject.fc1c3820-6d48-428d-963d-1f4bfa392f6b", reason2), "", "", MessageImportance.High);

                            Debugger.Break();
                        }

                        var installExtension = extensionManager.CreateInstallableExtension(packagePath);
                        var reason           = extensionManager.Install(installExtension, false);
                        var message          = new BuildMessageEventArgs(string.Format("'{0}' package registered successfully with restart reason={1}.  ", packageIdentifier, reason), "", "", MessageImportance.High);

                        this.BuildEngine.LogMessageEvent(message);
                    }
                    catch (Exception ex2)
                    {
                        try
                        {
                            RestartExplorer();

                            var installExtension = extensionManager.CreateInstallableExtension(packagePath);
                            var reason           = extensionManager.Install(installExtension, false);
                            var message          = new BuildMessageEventArgs(string.Format("'{0}' package registered successfully with restart reason={1}.  ", packageIdentifier, reason), "", "", MessageImportance.High);

                            this.BuildEngine.LogMessageEvent(message);
                        }
                        catch (Exception ex)
                        {
                            var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, string.Format("Error registering package '{0}'. Error={1}", packageIdentifier, ex.ToString()), "", "", DateTime.Now);
                            this.BuildEngine.LogErrorEvent(message);
                        }
                    }
                }
            }
        }
コード例 #11
0
ファイル: debugger.cs プロジェクト: 40a/PowerShell
        /// <summary>
        /// End monitoring a runspace on the target degbugger.
        /// </summary>
        /// <param name="debugger">Target debugger</param>
        /// <param name="runspaceInfo">PSMonitorRunspaceInfo</param>
        public static void EndMonitoringRunspace(Debugger debugger, PSMonitorRunspaceInfo runspaceInfo)
        {
            if (debugger == null)
            {
                throw new PSArgumentNullException("debugger");
            }

            if (runspaceInfo == null)
            {
                throw new PSArgumentNullException("runspaceInfo");
            }

            debugger.EndMonitoringRunspace(runspaceInfo);
        }
コード例 #12
0
            //emulator stuff

            public ComboBoxItemDevice( Debugger.PortDefinition pd)
                : base(pd.DisplayName, pd.PersistName, pd is PortDefinition_Tcp)
            {
                m_pd = pd;
            }
コード例 #13
0
        public bool Execute()
        {
            try
            {
                if (Keys.ControlKey.IsPressed())
                {
                    if (MessageBox.Show("Debug?", "Debug UpdateHydraInstaller", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Debugger.Launch();
                    }
                }

                var      solutionPath    = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%HYDRASOLUTIONPATH%"));
                var      productFilePath = Path.Combine(solutionPath, @"Hydra.InstallerStandalone\Product.wxs");
                var      applicationGeneratorBinaries = Path.Combine(solutionPath, @"ApplicationGenerator\bin", this.Configuration);
                var      applicationGeneratorProject  = Path.Combine(solutionPath, @"ApplicationGenerator\ApplicationGenerator.csproj");
                var      components       = ComponentFinder.GetComponents(applicationGeneratorBinaries, applicationGeneratorProject, this.TargetFramework, this.TargetAssembly, productFilePath);
                var      directories      = ComponentFinder.GetDirectories(applicationGeneratorBinaries, applicationGeneratorProject, this.TargetFramework, this.TargetAssembly, productFilePath);
                var      document         = XDocument.Load(productFilePath);
                var      namespaceManager = new XmlNamespaceManager(new NameTable());
                var      programMenuXml   = typeof(UpdateHydraInstaller).ReadResource <string>("ApplicationGeneratorBuildTasks.ProgramMenu.xml");
                XElement elementFeature;
                XElement elementDirectory;
                ApplicationGeneratorBuildTasks.Directory groupDirectory;
                ApplicationGeneratorBuildTasks.Directory topLeveDirectory;
                ComponentGroupRef componentGroupRef;
                XElement          elementGroupDirectory;
                XElement          elementComponentGroupRef;
                XElement          elementProgramMenu;
                XElement          elementProgramMenuDirectory;
                XElement          elementApplicationShortcutComponentRef;
                XElement          elementFragmentComponentGroup;
                ApplicationGeneratorBuildTasks.Directory programMenuDirectory;

                namespaceManager.AddNamespace("wi", "http://schemas.microsoft.com/wix/2006/wi");

                elementFeature   = document.XPathSelectElement("/wi:Wix/wi:Product/wi:Feature", namespaceManager);
                elementDirectory = document.XPathSelectElement("/wi:Wix/wi:Fragment/wi:Directory", namespaceManager);

                elementFeature.Elements().Remove();
                elementDirectory.Elements().Remove();

                foreach (var component in components)
                {
                    var elementComponent    = component.ToXElement <Component>();
                    var elementFile         = component.File.ToXElement <ApplicationGeneratorBuildTasks.File>();
                    var elementComponentRef = component.CreateComponentRef().ToXElement <ComponentRef>();

                    elementComponent.Add(elementFile);

                    elementDirectory.Add(elementComponent);
                    elementFeature.Add(elementComponentRef);
                }

                groupDirectory           = new ApplicationGeneratorBuildTasks.Directory(this.TargetAssembly + ".Binaries");
                componentGroupRef        = groupDirectory.CreateComponentGroupRef();
                elementGroupDirectory    = groupDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>();
                elementComponentGroupRef = componentGroupRef.ToXElement <ComponentGroupRef>();

                elementDirectory.Add(elementGroupDirectory);
                elementFeature.Add(elementComponentGroupRef);

                topLeveDirectory = new ApplicationGeneratorBuildTasks.Directory();
                topLeveDirectory.Directories.AddRange(directories);

                AddDirectories(elementFeature, elementDirectory, topLeveDirectory);

                // add start menu elements

                elementProgramMenuDirectory = elementDirectory.XPathSelectElement("wi:Directory[@Id='ProgramMenuFolder']", namespaceManager);

                if (elementProgramMenuDirectory != null)
                {
                    elementProgramMenuDirectory.Remove();
                }

                programMenuDirectory = new ApplicationGeneratorBuildTasks.Directory("ProgramMenuFolder")
                {
                    Directories = new List <ApplicationGeneratorBuildTasks.Directory> {
                        new ApplicationGeneratorBuildTasks.Directory("HydraShortcuts", "CloudIDEaaS Hydra")
                    }
                };
                elementProgramMenuDirectory = programMenuDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>();

                foreach (var shortcutDirectory in programMenuDirectory.Directories)
                {
                    elementProgramMenuDirectory.Add(shortcutDirectory.ToXElement <ApplicationGeneratorBuildTasks.Directory>());
                }

                elementDirectory.Add(elementProgramMenuDirectory);

                elementApplicationShortcutComponentRef = elementFeature.XPathSelectElement("wi:ComponentRef[@Id='ApplicationShortcut']", namespaceManager);

                if (elementApplicationShortcutComponentRef != null)
                {
                    elementApplicationShortcutComponentRef.Remove();
                }

                elementApplicationShortcutComponentRef = new ComponentRef("ApplicationShortcut").ToXElement <ComponentRef>();

                elementFeature.Add(new ComponentRef("ApplicationShortcut").ToXElement <ComponentRef>());

                elementFragmentComponentGroup = document.Root.XPathSelectElement("wi:Fragment/wi:ComponentGroup[@Id='ProductComponents']", namespaceManager);

                if (elementFragmentComponentGroup != null)
                {
                    elementFragmentComponentGroup.Remove();
                }

                elementProgramMenu = XElement.Parse(programMenuXml);
                document.Root.Add(elementProgramMenu);

                document.Save(productFilePath, SaveOptions.DisableFormatting);
            }
            catch (Exception ex)
            {
                var error = string.Format("Error installing Hydra Visual Studio templates. \r\nError: {0}", ex.ToString());

                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, error, "", "", DateTime.Now);
                this.BuildEngine.LogErrorEvent(message);

                Console.WriteLine(error);

                return(false);
            }

            return(true);
        }
コード例 #14
0
ファイル: debugger.cs プロジェクト: 40a/PowerShell
 /// <summary>
 /// Creates an instance of a NestedRunspaceDebugger.
 /// </summary>
 /// <param name="rootDebugger">Root debugger or null.</param>
 /// <returns>NestedRunspaceDebugger</returns>
 internal abstract NestedRunspaceDebugger CreateDebugger(Debugger rootDebugger);
コード例 #15
0
        private void InitializeDeployDevice( Debugger.PortDefinition selected)
        {
            //What about EmulatorExe????

            int iSelected = -1;
            DebugPort port = this.SelectedDeployPort;

            if (port == null)
                return;

            PortDefinition[] portDefinitions;

            if (port.IsLocalPort)
            {
                PlatformInfo platformInfo = this.VsProjectFlavorCfg.PlatformInfo;

                PlatformInfo.Emulator[] emulators = platformInfo.Emulators;

                portDefinitions = new PortDefinition[emulators.Length];

                for (int i = 0; i < emulators.Length; i++)
                {
                    portDefinitions[i] = new PlatformInfo.PortDefinition_PeristableEmulator(emulators[i]);
                }
            }
            else
            {
                portDefinitions = port.GetPersistablePortDefinitions();
            }

            m_cbDeployDevice.Items.Clear();

            for (int iPortDefinition = 0; iPortDefinition < portDefinitions.Length; iPortDefinition++)
            {
                PortDefinition pd = portDefinitions[iPortDefinition];

                ComboBoxItemDevice cbi = new ComboBoxItemDevice(pd);
                m_cbDeployDevice.Items.Add(cbi);

                if (Object.Equals(selected, pd))
                {
                    iSelected = m_cbDeployDevice.Items.Count - 1;
                }
            }

            if (m_cbDeployDevice.Items.Count == 0)
            {
                if(selected != null && port.PortFilter == PortFilter.TcpIp && selected is PortDefinition_Tcp)
                {
                    m_cbDeployDevice.Items.Add(new ComboBoxItemDevice(selected));
                }
                else
                {
                    ComboBoxItemDevice cbi = new ComboBoxItemDevice("<none>");
                    m_cbDeployDevice.Items.Insert(0, cbi);
                }
                iSelected = 0;
            }

            if(port.PortFilter != PortFilter.TcpIp)
            {
                iSelected = 0;
            }

            if(iSelected != -1)
            {
                m_cbDeployDevice.SelectedIndex = iSelected;
            }
                
        }
コード例 #16
0
ファイル: debugger.cs プロジェクト: 40a/PowerShell
 /// <summary>
 /// Creates an instance of a NestedRunspaceDebugger.
 /// </summary>
 /// <param name="rootDebugger">Root debugger or null</param>
 /// <returns>NestedRunspaceDebugger wrapper</returns>
 internal override NestedRunspaceDebugger CreateDebugger(Debugger rootDebugger)
 {
     return new StandaloneRunspaceDebugger(Runspace);
 }
コード例 #17
0
ファイル: debugger.cs プロジェクト: 40a/PowerShell
 /// <summary>
 /// Creates an instance of a NestedRunspaceDebugger.
 /// </summary>
 /// <param name="rootDebugger">Root debugger or null</param>
 /// <returns>NestedRunspaceDebugger wrapper</returns>
 internal override NestedRunspaceDebugger CreateDebugger(Debugger rootDebugger)
 {
     return new EmbeddedRunspaceDebugger(
         Runspace,
         Command,
         rootDebugger,
         RunspaceType,
         ParentDebuggerId);
 }
コード例 #18
0
        private void GetCommandLineForLaunch(bool fNoDebug, Debugger.PlatformInfo.Emulator emulatorConfig, Debugger.CommandLineBuilder cb, bool fIsTargetBigEndian)
        {
            if (emulatorConfig != null)
            {
                if (!string.IsNullOrEmpty(emulatorConfig.config))
                {
                    cb.AddArguments("/config:" + emulatorConfig.config);
                }
            }

            if (!fNoDebug)
            {
                cb.AddArguments("/waitfordebugger");
            }

            foreach (string assembly in m_project.GetDependencies(true, true, fIsTargetBigEndian))
            {
                cb.AddArguments( "/load:" + assembly );
            }

            string args = this.m_project.ProjectProperties.ActiveConfigurationSettings.StartArguments;
            args = args.Trim();
            if (args.Length > 0)
            {
                cb.AddArguments( "/commandlinearguments:" + args );
            }
        }
コード例 #19
0
        private string GetCommandLineForLaunch(bool fNoDebug, Debugger.PlatformInfo.Emulator emulatorConfig, bool fIsTargetBigEndian)
        {
            CommandLineBuilder cb = new CommandLineBuilder();

            if (emulatorConfig != null && !string.IsNullOrEmpty(emulatorConfig.additionalOptions))
            {
                CommandLineBuilder cbT = new CommandLineBuilder(emulatorConfig.additionalOptions);
                cb.AddArguments(cbT.Arguments);
            }

            if (emulatorConfig != null && emulatorConfig.legacyCommandLine)
            {
                GetCommandLineForLaunchLegacy(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }
            else
            {
                GetCommandLineForLaunch(fNoDebug, emulatorConfig, cb, fIsTargetBigEndian);
            }

            string commandLine = cb.ToString();
            commandLine = Environment.ExpandEnvironmentVariables(commandLine);

            return commandLine;
        }
コード例 #20
0
        private void GetCommandLineForLaunchLegacy(bool fNoDebug, Debugger.PlatformInfo.Emulator emulatorConfig, Debugger.CommandLineBuilder cb, bool fIsTargetBigEndian)
        {

#if DEBUG   // TRACE has been removed from release builds
                cb.AddArguments( "-Trace_MemoryStats", Utility.Boolean.BoolToInt( true ) );
#endif

                if (!fNoDebug)
                    cb.AddArguments( "-PipeName", "" );

#if DEBUG
                cb.AddArguments( "-Force_Compaction", Utility.Boolean.BoolToInt( true ) );
#endif

                string deviceCfg = Environment.GetEnvironmentVariable( "CLRROOT" );
                if (deviceCfg != null)
                {
                    deviceCfg = Path.Combine( deviceCfg, "test.devicecfg" );
                    if (File.Exists( deviceCfg ))
                        cb.AddArguments( "-devicecfg", deviceCfg );
                }


                foreach (string assembly in m_project.GetDependencies(true, true, fIsTargetBigEndian))
                {
                    cb.AddArguments( "-load", assembly );
                }

                string args = this.m_project.ProjectProperties.ActiveConfigurationSettings.StartArguments;
                args = args.Trim();
                if (args.Length > 0)
                {
                    cb.AddArguments( "-commandLineArgs", args );
                }

                cb.AddArguments( "-resolve" );
                cb.AddArguments( "-execute" );

        }
コード例 #21
0
        public bool Execute()
        {
            try
            {
                if (Keys.ControlKey.IsPressed())
                {
                    if (MessageBox.Show("Debug?", "Debug InstallTemplates", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Debugger.Launch();
                    }
                }

                var solutionPath               = Path.GetFullPath(Environment.ExpandEnvironmentVariables("%HYDRASOLUTIONPATH%"));
                var itemTemplatesOutputPath    = Path.Combine(solutionPath, @"ApplicationGenerator\ExportedItemTemplates");
                var projectTemplatesOutputPath = Path.Combine(solutionPath, @"ApplicationGenerator\ExportedProjectTemplates");
                var vsTemplatesPath            = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"Visual Studio 2019\Templates\ItemTemplates\Hydra");
                var projectDirectory           = Path.GetDirectoryName(this.BuildEngine.ProjectFileOfTaskNode);
                var localTemplatesPath         = Path.Combine(projectDirectory, @"bin\" + this.Configuration + @"\Templates");
                var directory     = new DirectoryInfo(itemTemplatesOutputPath);
                var parentProcess = Process.GetCurrentProcess().GetParent();

                if (!parentProcess.ProcessName.IsOneOf("devenv", "msvsmon"))
                {
                    return(true);
                }

                if (!Directory.Exists(vsTemplatesPath))
                {
                    Directory.CreateDirectory(vsTemplatesPath);
                }

                // Visual Studio templates

                foreach (var folder in directory.GetDirectories())
                {
                    using (var package = ZipPackage.Open(Path.Combine(vsTemplatesPath, folder.Name + ".zip"), FileMode.Create))
                    {
                        foreach (var file in folder.GetFiles())
                        {
                            var part = package.CreatePart(new Uri("/" + file.Name, UriKind.Relative), "");

                            using (var stream = new MemoryStream(File.ReadAllBytes(file.FullName)))
                            {
                                part.GetStream().WriteAll(stream);
                            }
                        }
                    }
                }

                // Locally distributed templates

                directory = new DirectoryInfo(projectTemplatesOutputPath);

                if (!Directory.Exists(localTemplatesPath))
                {
                    Directory.CreateDirectory(localTemplatesPath);
                }

                foreach (var folder in directory.GetDirectories())
                {
                    using (var package = ZipPackage.Open(Path.Combine(localTemplatesPath, folder.Name + ".zip"), FileMode.Create))
                    {
                        var subFolders = folder.GetDirectories("*", SearchOption.AllDirectories);

                        foreach (var file in folder.GetFiles())
                        {
                            var part = package.CreatePart(new Uri("/" + file.Name, UriKind.Relative), "");

                            using (var stream = new MemoryStream(File.ReadAllBytes(file.FullName)))
                            {
                                part.GetStream().WriteAll(stream);
                            }
                        }

                        foreach (var subFolder in subFolders)
                        {
                            foreach (var file in subFolder.GetFiles())
                            {
                                var relativePath = file.FullName.RemoveStart(folder.FullName).ReverseSlashes();
                                var part         = package.CreatePart(new Uri(relativePath, UriKind.Relative), "");

                                using (var stream = new MemoryStream(File.ReadAllBytes(file.FullName)))
                                {
                                    part.GetStream().WriteAll(stream);
                                }
                            }
                        }
                    }
                }

                foreach (var file in directory.GetFiles())
                {
                    File.Copy(file.FullName, Path.Combine(localTemplatesPath, file.Name), true);
                }
            }
            catch (Exception ex)
            {
                var error = string.Format("Error installing Hydra Visual Studio templates. \r\nError: {0}", ex.ToString());

                var message = new BuildErrorEventArgs(string.Empty, string.Empty, string.Empty, 0, 0, 0, 0, error, "", "", DateTime.Now);
                this.BuildEngine.LogErrorEvent(message);

                Console.WriteLine(error);

                return(false);
            }

            return(true);
        }
コード例 #22
0
        internal static bool TargetFrameworkExactMatch( Debugger.WireProtocol.Commands.Debugging_Resolve_Assembly.Version left, Version right)
        {
            if(left.iMajorVersion   == right.Major         && 
               left.iMinorVersion   == right.Minor         && 
               left.iBuildNumber    == right.Build         &&
               left.iRevisionNumber == right.Revision 
               )
            {
                return true;
            }

            return false;
        }