public static string GetGenericParamaters(int aCommandId, string vsEdition, string vsVersion)
        {
            IBuilder <string> genericScriptBuilder = new GenericScriptBuilder(vsEdition, vsVersion, aCommandId);

            genericScriptBuilder.Build();
            var genericParameters = genericScriptBuilder.GetResult();

            return(genericParameters);
        }
Esempio n. 2
0
        protected void RunScript(int aCommandId)
        {
            try
            {
                var dte = VsServiceProvider.GetService(typeof(DTE)) as DTE2;
                dte.Solution.SaveAs(dte.Solution.FullName);

                IBuilder <string> runModeScriptBuilder = new RunModeScriptBuilder();
                runModeScriptBuilder.Build();
                var runModeParameters = runModeScriptBuilder.GetResult();

                IBuilder <string> genericScriptBuilder = new GenericScriptBuilder(VsEdition, VsVersion, aCommandId);
                genericScriptBuilder.Build();
                var genericParameters = genericScriptBuilder.GetResult();

                string solutionPath = dte.Solution.FullName;

                InitPowerShell();
                ClearWindows();
                mOutputWindow.Write($"\n{OutputWindowConstants.kStart} {OutputWindowConstants.kCommandsNames[aCommandId]}\n");

                StatusBarHandler.Status(OutputWindowConstants.kCommandsNames[aCommandId] + " started...", 1, vsStatusAnimation.vsStatusAnimationBuild, 1);

                VsServiceProvider.TryGetService(typeof(SVsSolution), out object vsSolutionService);
                var vsSolution = vsSolutionService as IVsSolution;

                foreach (var item in mItemsCollector.GetItems)
                {
                    if (!mCommandsController.Running)
                    {
                        break;
                    }

                    IBuilder <string> itemRelatedScriptBuilder = new ItemRelatedScriptBuilder(item);
                    itemRelatedScriptBuilder.Build();
                    var itemRelatedParameters = itemRelatedScriptBuilder.GetResult();

                    // From the first parameter is removed the last character which is mandatory "'"
                    // and added to the end of the string to close the script
                    var script = $"{runModeParameters.Remove(runModeParameters.Length - 1)} {itemRelatedParameters} {genericParameters}'";

                    if (null != vsSolution)
                    {
                        mOutputWindow.Hierarchy = AutomationUtil.GetItemHierarchy(vsSolution as IVsSolution, item);
                    }

                    var process = mPowerShell.Invoke(script, mRunningProcesses);

                    if (mOutputWindow.MissingLlvm)
                    {
                        mOutputWindow.Write(ErrorParserConstants.kMissingLlvmMessage);
                        break;
                    }
                }

                if (!mOutputWindow.MissingLlvm)
                {
                    mOutputWindow.Show();
                    mOutputWindow.Write($"\n{OutputWindowConstants.kDone} {OutputWindowConstants.kCommandsNames[aCommandId]}\n");
                }

                if (mOutputWindow.HasErrors)
                {
                    mErrorWindow.AddErrors(mOutputWindow.Errors);
                }
            }
            catch (Exception)
            {
                mOutputWindow.Show();
                mOutputWindow.Write($"\n{OutputWindowConstants.kDone} {OutputWindowConstants.kCommandsNames[aCommandId]}\n");
            }
            finally
            {
                StatusBarHandler.Status(OutputWindowConstants.kCommandsNames[aCommandId] + " finished", 0, vsStatusAnimation.vsStatusAnimationBuild, 0);
            }
        }