Beispiel #1
0
        private void OnReplaceClick(object sender, EventArgs e)
        {
            if (dte != null)
            {
                outputWindow?.OutputString($"Updating project versions to {txtVersion.Text}.\r\n");

                var fileNames = GetProjectAssemblyInfoFiles();
                if (!fileNames.Any())
                {
                    outputWindow?.OutputString("No AssemblyInfo.cs found in any project. " +
                                               "Lightweight solution load might be enabled. " +
                                               "Please disable lightweight solution load and try again.\r\n");
                }
                else
                {
                    var increaseVersion = CreateIncreaseVersion(txtVersion.Text);
                    foreach (var fileName in fileNames)
                    {
                        outputWindow?.OutputString(fileName + "\r\n");
                        increaseVersion.Files.Add(new File(fileName));
                    }

                    increaseVersion.Execute();

                    outputWindow?.OutputString("Project versions updated.\r\n");
                }
            }

            this.Close();
        }
Beispiel #2
0
        /// <inheritdoc/>
        public override async TPL.Task Execute(Project project)
        {
            string projName    = project.UniqueName;
            bool   needInstall = true;

            lock (SyncObject)
            {
                needInstall = InstallTasks.Add(projName);
            }

            if (needInstall)
            {
                string warningTitle   = this.IsUpdate ? Resources.Resources.NugetUpdate_Title : Resources.Resources.NugetInstall_Title;
                string warningMessage = this.IsUpdate ? Resources.Resources.NugetUpdate_Text : Resources.Resources.NugetInstall_Text;
                if (await this.HasUserAcceptedWarningMessage(warningTitle, warningMessage))
                {
                    // Gets the general output pane to inform user of installation
                    IVsOutputWindowPane outputWindow = (IVsOutputWindowPane)await this.Package.GetServiceAsync(typeof(SVsGeneralOutputWindowPane));

                    outputWindow?.OutputString(string.Format(CultureInfo.CurrentCulture, Resources.Resources.NugetInstall_InstallingOutput, project.Name) + Environment.NewLine);

                    this.Package.JoinableTaskFactory.RunAsync(async() =>
                    {
                        await TPL.TaskScheduler.Default;

                        string outputMessage = Resources.Resources.NugetInstall_FinishedOutput;
                        try
                        {
                            await this.Successor.Execute(project);
                        }
                        catch
                        {
                            outputMessage = Resources.Resources.NugetInstall_ErrorOutput;
                            throw;
                        }
                        finally
                        {
                            lock (SyncObject)
                            {
                                InstallTasks.Remove(projName);
                            }

                            await this.Package.JoinableTaskFactory.SwitchToMainThreadAsync();
                            outputWindow?.OutputString(string.Format(CultureInfo.CurrentCulture, outputMessage, project.Name) + Environment.NewLine);
                        }
                    }).Task.Forget();
                }
                else
                {
                    lock (SyncObject)
                    {
                        // If the user refuses to install, the task should not be added
                        InstallTasks.Remove(projName);
                    }
                }
            }
        }
        private void BackgroundInstallSlowCheetah(Project project)
        {
            string projName    = project.UniqueName;
            bool   needInstall = true;

            lock (this.syncObject)
            {
                needInstall = this.installTasks.Add(projName);
            }

            if (needInstall)
            {
                if (this.HasUserAcceptedWarningMessage(Resources.Resources.NugetInstall_Title, Resources.Resources.NugetInstall_Text))
                {
                    // Gets the general output pane to inform user of installation
                    IVsOutputWindowPane outputWindow = (IVsOutputWindowPane)this.package.GetService(typeof(SVsGeneralOutputWindowPane));
                    outputWindow?.OutputString(string.Format(Resources.Resources.NugetInstall_InstallingOutput, project.Name) + Environment.NewLine);

                    // Uninstalls the older version (if present) and installs latest package
                    var componentModel = (IComponentModel)this.package.GetService(typeof(SComponentModel));
                    IVsPackageInstaller2 packageInstaller = componentModel.GetService <IVsPackageInstaller2>();

                    TPL.Task.Run(() =>
                    {
                        string outputMessage = Resources.Resources.NugetInstall_FinishedOutput;
                        try
                        {
                            packageInstaller.InstallLatestPackage(null, project, PackageName, false, false);
                        }
                        catch
                        {
                            outputMessage = Resources.Resources.NugetInstall_ErrorOutput;
                            throw;
                        }
                        finally
                        {
                            lock (this.syncObject)
                            {
                                this.installTasks.Remove(projName);
                            }

                            ThreadHelper.Generic.BeginInvoke(() => outputWindow?.OutputString(string.Format(outputMessage, project.Name) + Environment.NewLine));
                        }
                    });
                }
                else
                {
                    lock (this.syncObject)
                    {
                        // If the user refuses to install, the task should not be added
                        this.installTasks.Remove(projName);
                    }
                }
            }
        }
Beispiel #4
0
        /// <inheritdoc/>
        public override void Execute(Project project)
        {
            string projName    = project.UniqueName;
            bool   needInstall = true;

            lock (SyncObject)
            {
                needInstall = InstallTasks.Add(projName);
            }

            if (needInstall)
            {
                string warningTitle   = this.IsUpdate ? Resources.Resources.NugetUpdate_Title : Resources.Resources.NugetInstall_Title;
                string warningMessage = this.IsUpdate ? Resources.Resources.NugetUpdate_Text : Resources.Resources.NugetInstall_Text;
                if (this.HasUserAcceptedWarningMessage(warningTitle, warningMessage))
                {
                    // Gets the general output pane to inform user of installation
                    IVsOutputWindowPane outputWindow = (IVsOutputWindowPane)this.Package.GetService(typeof(SVsGeneralOutputWindowPane));
                    outputWindow?.OutputString(string.Format(Resources.Resources.NugetInstall_InstallingOutput, project.Name) + Environment.NewLine);

                    TPL.Task.Run(() =>
                    {
                        string outputMessage = Resources.Resources.NugetInstall_FinishedOutput;
                        try
                        {
                            this.Successor.Execute(project);
                        }
                        catch
                        {
                            outputMessage = Resources.Resources.NugetInstall_ErrorOutput;
                            throw;
                        }
                        finally
                        {
                            lock (SyncObject)
                            {
                                InstallTasks.Remove(projName);
                            }

                            ThreadHelper.Generic.BeginInvoke(() => outputWindow?.OutputString(string.Format(outputMessage, project.Name) + Environment.NewLine));
                        }
                    });
                }
                else
                {
                    lock (SyncObject)
                    {
                        // If the user refuses to install, the task should not be added
                        InstallTasks.Remove(projName);
                    }
                }
            }
        }
            internal static async Task OutputWindowPaneAsync(string message)
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                IVsOutputWindowPane outputPane = null;
                var outputWindow = ServiceProvider.GlobalProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

                if (outputWindow != null && ErrorHandler.Failed(outputWindow.GetPane(ActionOutputWindowPane, out outputPane)))
                {
                    IVsWindowFrame windowFrame;
                    var            vsUiShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
                    if (vsUiShell != null)
                    {
                        uint flags = (uint)__VSFINDTOOLWIN.FTW_fForceCreate;
                        vsUiShell.FindToolWindow(flags, VSConstants.StandardToolWindows.Output, out windowFrame);
                        windowFrame.Show();
                    }

                    outputWindow.CreatePane(ActionOutputWindowPane, "Actions", 1, 1);
                    outputWindow.GetPane(ActionOutputWindowPane, out outputPane);
                    outputPane.Activate();
                }

                outputPane?.OutputString(message);
            }
Beispiel #6
0
 /// <summary>
 /// Prints messages to the package manager output window
 /// </summary>
 /// <param name="message">Message to print</param>
 /// <param name="pane">Pane object</param>
 public static void PrintOutput(string message, IVsOutputWindowPane pane)
 {
     if(pane != null)
     {
         ErrorHandler.ThrowOnFailure(pane.OutputString(message + "\n"));
     }
 }
        public void WriteLine(string output)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            TryCreateOutputPane();

            _outputPane?.OutputString($"{output}{Environment.NewLine}");
        }
Beispiel #8
0
        private async Task OutputMessageAsync(string message, bool clear = false)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            IVsOutputWindowPane outputPane  = null;
            IVsWindowFrame      windowFrame = null;
            var outputWindow = ServiceProvider.GlobalProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            if (outputWindow != null && ErrorHandler.Failed(outputWindow.GetPane(windowGuid, out outputPane)))
            {
                outputWindow.CreatePane(windowGuid, "Meadow Device Explorer", 1, 1);
                outputWindow.GetPane(windowGuid, out outputPane);
            }

            var  vsUiShell = ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;
            uint flags     = (uint)__VSFINDTOOLWIN.FTW_fForceCreate;

            vsUiShell?.FindToolWindow(flags, VSConstants.StandardToolWindows.Output, out windowFrame);

            if (clear)
            {
                outputPane?.Clear();
            }

            windowFrame?.Show();
            outputPane?.Activate();
            outputPane?.OutputString($"[{DateTime.Now.ToLocalTime()}] {message}" + Environment.NewLine);
        }
        public static void Write(string message)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsOutputWindow     outWindow       = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid                generalPaneGuid = VSConstants.GUID_OutWindowDebugPane; // P.S. There's also the GUID_OutWindowDebugPane available.
            IVsOutputWindowPane generalPane     = null;

            outWindow?.GetPane(ref generalPaneGuid, out generalPane);
            generalPane?.OutputString(Environment.NewLine);
            generalPane?.OutputString(message);
            generalPane?.OutputString(Environment.NewLine);
            if (_isFirstTime)
            {
                _isFirstTime = false;
                generalPane?.Activate();
            }
        }
Beispiel #10
0
        public static void OutputMessageToPane(string message)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            if (currentPane == null)
            {
                CreatePane();
            }

            currentPane?.OutputString(message + "\n");
        }
Beispiel #11
0
        public static void ReportError(string error)
        {
            var outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            outWindow?.CreatePane(ref ErrorOutputGuid, ErrorOutputTitle, 1, 1);

            // ReSharper disable once InlineOutVariableDeclaration
            IVsOutputWindowPane customPane = null;

            outWindow?.GetPane(ref ErrorOutputGuid, out customPane);

            customPane?.OutputString($"ERROR: {error}");
            customPane?.Activate(); // Brings this pane into view
        }
Beispiel #12
0
        /// <summary>Log the error to the Output Window.</summary>
        public static async Task LogAsync(this Exception exception)
        {
            try
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                if (await EnsurePaneAsync())
                {
                    _pane?.OutputString(exception + Environment.NewLine);
                }
            }
            catch
            {
                // Swallow the exception
            }
        }
Beispiel #13
0
        public static void Log(object message)
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                if (_pane == null)
                {
                    var guid = Guid.NewGuid();
                    _output.CreatePane(ref guid, _name, 1, 1);
                    _output.GetPane(ref guid, out _pane);
                }

                _pane?.OutputString($"{DateTime.Now}: {message}{Environment.NewLine}");
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
            }
        }
        public static void WriteToGeneral(string text)
        {
            const int VISIBLE = 1;
            const int DO_NOT_CLEAR_WITH_SOLUTION = 0;

            // Get the output window
            var outputWindow = Instance.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;

            // The General pane is not created by default. We must force its creation
            var guidPane = VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
            var hr       = outputWindow.CreatePane(guidPane, "General", VISIBLE, DO_NOT_CLEAR_WITH_SOLUTION);

            ErrorHandler.ThrowOnFailure(hr);

            // Get the pane
            IVsOutputWindowPane outputWindowPane = null;

            hr = outputWindow.GetPane(guidPane, out outputWindowPane);
            ErrorHandler.ThrowOnFailure(hr);

            // Output the text
            outputWindowPane?.Activate();
            outputWindowPane?.OutputString(text);
        }
        public override MSBuildResult Build(uint vsopts, string config, IVsOutputWindowPane output, string target)
        {
            if (output != null)
            {
                output.OutputString("Build for node.js project is not required.\n");
            }

            return MSBuildResult.Successful;
        }
Beispiel #16
0
 public void Log(string message)
 {
     outputWindow.OutputString(message + "\r\n");
 }
            public override void Write(string value)
            {
                Dispatcher.CurrentDispatcher.VerifyAccess();

                ErrorHandler.ThrowOnFailure(m_outputPane.OutputString(value));
            }
        private static void RefreshStackData(int pid)
        {
            DirectoryInfo taskDirectory = new DirectoryInfo(Path.GetTempPath());

            FileInfo[] taskFiles = taskDirectory.GetFiles("pmip_" + pid + "_*.txt");

            if (taskFiles.Length < 1)
            {
                return;
            }

            Array.Sort(taskFiles, (a, b) => GetFileNameSequenceNum(a.Name).CompareTo(GetFileNameSequenceNum(b.Name)));
            var fileName = taskFiles[taskFiles.Length - 1].FullName;

            if (_currentFile != fileName)
            {
                DisposeStreams();
                try
                {
                    _fileStream       = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
                    _fileStreamReader = new StreamReader(_fileStream);
                    _currentFile      = fileName;
                    var        versionStr = _fileStreamReader.ReadLine();
                    const char delimiter  = ':';
                    var        tokens     = versionStr.Split(delimiter);

                    if (tokens.Length != 2)
                    {
                        throw new Exception("Failed reading input file " + fileName + ": Incorrect format");
                    }

                    var version = double.Parse(tokens[1]);

                    if (version > 1.0)
                    {
                        throw new Exception("Failed reading input file " + fileName + ": A newer version of UnityMixedCallstacks plugin is required to read this file");
                    }
                }
                catch (Exception ex)
                {
                    _debugPane.OutputString("Unable to read dumped pmip file: " + ex.Message + "\n");
                    DisposeStreams();
                    _enabled = false;
                    return;
                }
            }

            try
            {
                string line;
                while ((line = _fileStreamReader.ReadLine()) != null)
                {
                    const char delemiter = ';';
                    var        tokens    = line.Split(delemiter);

                    //should never happen, but lets be safe and not get array out of bounds if it does
                    if (tokens.Length != 3)
                    {
                        continue;
                    }

                    var startip     = tokens[0];
                    var endip       = tokens[1];
                    var description = tokens[2];

                    var startiplong = ulong.Parse(startip, NumberStyles.HexNumber);
                    var endipint    = ulong.Parse(endip, NumberStyles.HexNumber);
                    _rangesSortedByIp.Add(new Range()
                    {
                        Name = description, Start = startiplong, End = endipint
                    });
                }
            }
            catch (Exception ex)
            {
                _debugPane.OutputString("Unable to read dumped pmip file: " + ex.Message + "\n");
                DisposeStreams();
                _enabled = false;
                return;
            }

            _rangesSortedByIp.Sort((r1, r2) => r1.Start.CompareTo(r2.Start));
        }
        public static async Task <Report> ProcessAsync(IAsyncServiceProvider serviceProvider, bool addComment)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var report = new Report();

            var dte = (DTE)await serviceProvider.GetServiceAsync(typeof(DTE));

            if (dte == null || string.IsNullOrEmpty(dte.Solution.FullName))
            {
                report.SolutionName = "N/A";
                return(report);
            }

            report.SolutionName = System.IO.Path.GetFileNameWithoutExtension(System.IO.Path.GetFileName(dte.Solution.FullName));

            IVsStatusbar statusBar = (IVsStatusbar)await serviceProvider.GetServiceAsync(typeof(SVsStatusbar));

            IVsThreadedWaitDialogFactory factory =
                (IVsThreadedWaitDialogFactory)await serviceProvider.GetServiceAsync(
                    typeof(SVsThreadedWaitDialogFactory));

            IVsThreadedWaitDialog2 dialog = null;

            factory?.CreateInstance(out dialog);
            dialog?.StartWaitDialog("PVSStudio Helper", (addComment) ? "Add comment" : "Remove comment", null, null,
                                    null, 0, false, true);

            IVsOutputWindow outWindow =
                (IVsOutputWindow)await serviceProvider.GetServiceAsync(typeof(SVsOutputWindow));

            var generalPaneGuid             = VSConstants.GUID_OutWindowGeneralPane; // P.S. There's also the GUID_OutWindowDebugPane available.
            IVsOutputWindowPane generalPane = null;

            outWindow?.GetPane(ref generalPaneGuid, out generalPane);
            if (generalPane == null)
            {
                outWindow?.CreatePane(ref generalPaneGuid, "General", 1, 0);
                outWindow?.GetPane(ref generalPaneGuid, out generalPane);
            }

            await ProjectProcess.ProcessAsync(dte, report, addComment, async (message) =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                dialog?.UpdateProgress(null, message, null, 0, 0, true, out var canceled);
                //messagePump.WaitText = message;
                if (statusBar != null)
                {
                    statusBar.IsFrozen(out var isFrozen);
                    if (isFrozen == 0)
                    {
                        statusBar.SetText(message);
                    }
                }

                generalPane?.OutputString($"{message}{Environment.NewLine}");
            });

            var finalMessage =
                $"The solution {report.SolutionName} processed. Processed items: {report.ProcessedItems}, include opened items {report.ProcessedOpenedItems}";

            if (statusBar != null)
            {
                statusBar.IsFrozen(out var isFrozen);
                if (isFrozen == 0)
                {
                    statusBar.SetText(finalMessage);
                }
            }
            generalPane?.OutputStringThreadSafe($"{finalMessage}{Environment.NewLine}");

            dialog.EndWaitDialog();

            return(report);
        }
 // Write text to output pane or logfile
 override public void WriteToLog(string Text)
 {
     GeneralOutputWindowPane.OutputString(Text + "\n");
 }
        internal override void BuildAsync(uint vsopts, string config, IVsOutputWindowPane output, string target, Action<MSBuildResult, string> uiThreadCallback)
        {
            if (output != null)
            {
                output.OutputString("Build for node.js project is not required.\n");
            }

            uiThreadCallback(MSBuildResult.Successful, target);
        }
Beispiel #22
0
        internal void OutputMessage(string message)
        {
            m_buildOutputPane.OutputString(string.Format(CultureInfo.InvariantCulture, "{0}{1}", message, Environment.NewLine));

            // Check whether this message represents an error or a warning and push to task itemlist accordingly
            ErrorTask task     = null;
            string    fileName = null;

            Match match = null;

            foreach (Regex regex in m_messageRegexs)
            {
                match = regex.Match(message);
                if (match.Success)
                {
                    break;
                }
            }

            if (match != null && match.Success)
            {
                fileName = match.Groups["file"].Value;
                var lineNumber = int.Parse(match.Groups["linestart"].Value, CultureInfo.InvariantCulture);
                var colNumber  = int.Parse(match.Groups["columnstart"].Value, CultureInfo.InvariantCulture);

                var errOrWarning = match.Groups["level"].Value;
                var isAnError    = string.Equals(errOrWarning, "error", StringComparison.OrdinalIgnoreCase);
                if (isAnError)
                {
                    m_numErrors++;
                }

                task = new ErrorTask
                {
                    Document      = fileName,
                    Line          = lineNumber - 1,
                    Column        = colNumber - 1,
                    Text          = match.Groups["message"].Value,
                    Priority      = isAnError ? TaskPriority.High : TaskPriority.Normal,
                    ErrorCategory = isAnError ? TaskErrorCategory.Error : TaskErrorCategory.Warning,
                    Category      = TaskCategory.BuildCompile,
                };
            }
            else
            {
                // If the standard pattern is not followed for errors
                if (message.StartsWith("error ", StringComparison.OrdinalIgnoreCase) ||
                    message.StartsWith("error:", StringComparison.OrdinalIgnoreCase))
                {
                    task = new ErrorTask
                    {
                        Text          = message,
                        Priority      = TaskPriority.High,
                        ErrorCategory = TaskErrorCategory.Error,
                        Category      = TaskCategory.BuildCompile,
                    };
                }
            }

            // Add the task (if not null) to error list
            if (task != null)
            {
                if (!string.IsNullOrEmpty(fileName))
                {
                    // populating the project hierarchy to show the project name in the error list window
                    IVsUIHierarchy vsHierarchy;
                    uint           itemId;
                    Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider;
                    var docInProj = 0;

                    var docOpenResult = m_shellOpenDocument.IsDocumentInAProject(
                        fileName,
                        out vsHierarchy,
                        out itemId,
                        out serviceProvider,
                        out docInProj);
                    if (docInProj != 0 && docOpenResult == VSConstants.S_OK)
                    {
                        task.HierarchyItem = vsHierarchy;
                    }
                }

                // Adding navigation handler
                task.Navigate += NavigateTo;
                m_errorListProvider.Tasks.Add(task);
            }
        }
Beispiel #23
0
 private void OutputLine(string Message)
 {
     m_OutputWindow.OutputString(Message + Environment.NewLine);
     Trace.WriteLine(Message, k_ExtensionName);
 }
        /// <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 = (DTE)await this.ServiceProvider.GetServiceAsync(typeof(DTE));

            foreach (SelectedItem item in dte.SelectedItems)
            {
                ProjectItem pi       = item.ProjectItem;
                string      tarsPath = null;
                switch (pi.ContainingProject.CodeModel.Language)
                {
                case CodeModelLanguageConstants.vsCMLanguageCSharp:
                    tarsPath = this.tars2csPath;
                    break;

                case CodeModelLanguageConstants.vsCMLanguageVC:
                    break;

                default:
                    break;
                }
                if (tarsPath != null)
                {
                    string srcFile = pi.FileNames[0];
                    string tmpFile = Path.GetTempPath() + pi.GetHashCode() + ".tars";
                    File.Copy(srcFile, tmpFile, true);
                    string targetPath = srcFile + "_";
                    string path       = Path.GetTempPath() + pi.GetHashCode();
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path, true);
                    }
                    Directory.CreateDirectory(path);
                    ProjectItems pis = pi.Collection;
                    try
                    {
                        pis.Item(pi.Name + "_").Delete();
                    }
                    catch
                    {
                    }
                    if (Directory.Exists(targetPath))
                    {
                        Directory.Delete(targetPath, true);
                    }
                    pi = pis.AddFolder(pi.Name + "_");
                    ProcessStartInfo psi = new ProcessStartInfo(tarsPath, $"--base-package= \"{tmpFile}\"");
                    psi.UseShellExecute       = false;
                    psi.CreateNoWindow        = true;
                    psi.WorkingDirectory      = path;
                    psi.RedirectStandardError = true;
                    using (Process p = Process.Start(psi))
                    {
                        if (p?.WaitForExit(10 * 1000) == true)
                        {
                            IVsOutputWindowPane outputPane = (IVsOutputWindowPane)await this.ServiceProvider.GetServiceAsync(typeof(SVsGeneralOutputWindowPane));

                            outputPane.OutputString(p.StandardError.ReadToEnd());
                            //string targetPath = Path.GetDirectoryName(srcFile);
                            this.AddLinks(pi, path, targetPath);
                        }
                    }
                    Directory.Delete(path, true);
                    File.Delete(tmpFile);
                }
            }
        }
 private void WriteToPaneLog(string text)
 {
     pane.OutputString(text);
 }
 /// <summary>
 /// Writes text to the Output window pane.
 /// </summary>
 /// <param name="value">The text to write.</param>
 public override void Write(string value)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     _pane.OutputString(value);
 }
 private void Output(string text)
 {
     pane.OutputString(text);
 }
Beispiel #28
0
 private void OutputToOutputWindow(string message)
 {
     _pane?.OutputString(message + Environment.NewLine);
 }
 private void WriteToOutputPane(string message)
 {
     _outputPane.OutputString(message + Environment.NewLine);
     _outputPane.Activate();
 }
Beispiel #30
0
        private void WriteLineToOutputWindow(string text)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _vsOutputWindowPane.OutputString(text + Environment.NewLine);
        }
Beispiel #31
0
 /// <summary>
 /// Sends a text string into pane.
 /// </summary>
 /// <param name="text"></param>
 public void OutputString(string text)
 {
     pane.OutputString(text);
 }
Beispiel #32
0
        /// <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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _dte = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            if (_dte == null)
            {
                return;
            }

            // Intercept build commands
            string[] buildCommandNames = new[]
            {
                "Build.BuildSolution",
                "Build.RebuildSolution",
                "Build.BuildSelection",
                "Build.RebuildSelection",
                "ClassViewContextMenus.ClassViewProject.Build",
                "ClassViewContextMenus.ClassViewProject.Rebuild",
                "Build.ProjectPickerBuild",
                "Build.ProjectPickerRebuild",
                "Build.BuildOnlyProject",
                "Build.RebuildOnlyProject"
            };

            _cmdEvents = new List <CommandEvents>();
            foreach (string buildCommandName in buildCommandNames)
            {
                var buildCommand = _dte.Commands.Item(buildCommandName);
                var cmdev        = _dte.Events.CommandEvents[buildCommand.Guid, buildCommand.ID];
                cmdev.BeforeExecute += this.BuildCommand_BeforeExecute;
                _cmdEvents.Add(cmdev);
            }

            _dte.Events.SolutionEvents.BeforeClosing       += SolutionEvents_BeforeClosing;
            _dte.Events.BuildEvents.OnBuildBegin           += BuildEvents_OnBuildBegin;
            _dte.Events.BuildEvents.OnBuildDone            += BuildEvents_OnBuildDone;
            _dte.Events.BuildEvents.OnBuildProjConfigBegin += BuildEvents_OnBuildProjConfigBegin;


            _rdt = (IVsRunningDocumentTable)(await GetServiceAsync(typeof(SVsRunningDocumentTable)));
            _rdt.AdviseRunningDocTableEvents(this, out _rdtCookie);

            await AdMaiora.RealXaml.Extension.Commands.EnableRealXamlCommand.InitializeAsync(this, _dte);

            await AdMaiora.RealXaml.Extension.Commands.DisableRealXamlCommand.InitializeAsync(this, _dte);

            CreateOutputPane();

            try
            {
                string currentPath = Path.GetDirectoryName(GetType().Assembly.Location);
                _assemblyResolver = new ManualAssemblyResolver(
                    Assembly.LoadFile(Path.Combine(currentPath, "Newtonsoft.Json.dll")),
                    Assembly.LoadFile(Path.Combine(currentPath, "System.Buffers.dll")),
                    Assembly.LoadFile(Path.Combine(currentPath, "System.Numerics.Vectors.dll"))
                    );
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                _outputPane.OutputString("Something went wrong loading assemblies.");
                _outputPane.OutputString(ex.ToString());
            }

            UpdateManager.Current.IdeRegistered    += this.UpdateManager_IdeRegistered;
            UpdateManager.Current.ClientRegistered += this.UpdateManager_ClientRegistered;
            UpdateManager.Current.PageAppeared     += this.UpdateManager_PageAppeared;
            UpdateManager.Current.PageDisappeared  += this.UpdateManager_PageDisappeared;
            UpdateManager.Current.XamlUpdated      += this.UpdateManager_XamlUpdated;
            UpdateManager.Current.AssemblyLoaded   += this.UpdateManager_AssemblyLoaded;
            UpdateManager.Current.ExceptionThrown  += this.UpdateManager_ExceptionThrown;
            UpdateManager.Current.IdeNotified      += this.Current_IdeNotified;

            _xamlCache.Clear();
        }
 public void WriteAsync(XElement element)
 {
     debugPane.OutputString(element.ToString());
 }