Пример #1
0
        private void RunBuild(String projectPath, String target, Dictionary <String, String> properties, Action <BuildLogger> handler)
        {
            BuildLogger         logger          = new BuildLogger();
            IVsOutputWindow     outWindow       = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid                generalPaneGuid = VSConstants.GUID_OutWindowDebugPane;
            IVsOutputWindowPane debugPane;

            outWindow.GetPane(ref generalPaneGuid, out debugPane);
            logger.OutputWindow = debugPane;

            logger.Verbosity = LoggerVerbosity.Detailed;
            MsBuild.Execution.BuildRequestData buildRequest = new MsBuild.Execution.BuildRequestData(projectPath, properties, null, new string[] { target }, null);
            MsBuild.Execution.BuildParameters  buildParams  = new MsBuild.Execution.BuildParameters()
            {
                DetailedSummary = false,
                Loggers         = new List <ILogger>()
                {
                    logger
                }
            };

            ThreadPool.QueueUserWorkItem((Object) =>
            {
                String selectedFiles = properties["SelectedFiles"];
                logger.Write(String.Format("Alcantarea info: compile started \"{0}\"\n", selectedFiles));
                try
                {
                    MsBuild.Execution.BuildResult result = MsBuild.Execution.BuildManager.DefaultBuildManager.Build(buildParams, buildRequest);
                    if (result.OverallResult == MsBuild.Execution.BuildResultCode.Success)
                    {
                        logger.Write(String.Format("Alcantarea info: compile succeeded \"{0}\"\n", selectedFiles));
                        handler(logger);
                    }
                    else
                    {
                        logger.Write(String.Format("Alcantarea info: compile failed \"{0}\"\n", selectedFiles));
                    }
                }
                catch (Exception er)
                {
                }
            });
        }
Пример #2
0
        private void RunBuild(String projectPath, String target, Dictionary<String, String> properties, Action<BuildLogger> handler)
        {
            BuildLogger logger = new BuildLogger();
            IVsOutputWindow outWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            Guid generalPaneGuid = VSConstants.GUID_OutWindowDebugPane;
            IVsOutputWindowPane debugPane;
            outWindow.GetPane(ref generalPaneGuid, out debugPane);
            logger.OutputWindow = debugPane;

            logger.Verbosity = LoggerVerbosity.Detailed;
            MsBuild.Execution.BuildRequestData buildRequest = new MsBuild.Execution.BuildRequestData(projectPath, properties, null, new string[] { target }, null);
            MsBuild.Execution.BuildParameters buildParams = new MsBuild.Execution.BuildParameters()
            {
                DetailedSummary = false,
                Loggers = new List<ILogger>() { logger }
            };

            ThreadPool.QueueUserWorkItem((Object) =>
            {
                String selectedFiles = properties["SelectedFiles"];
                logger.Write(String.Format("Alcantarea info: compile started \"{0}\"\n", selectedFiles));
                try
                {
                    MsBuild.Execution.BuildResult result = MsBuild.Execution.BuildManager.DefaultBuildManager.Build(buildParams, buildRequest);
                    if (result.OverallResult == MsBuild.Execution.BuildResultCode.Success)
                    {
                        logger.Write(String.Format("Alcantarea info: compile succeeded \"{0}\"\n", selectedFiles));
                        handler(logger);
                    }
                    else
                    {
                        logger.Write(String.Format("Alcantarea info: compile failed \"{0}\"\n", selectedFiles));
                    }
                }
                catch(Exception er)
                {

                }
            });
        }