コード例 #1
0
        public override bool Execute()
        {
            var serviceProvider = new WixToolsetServiceProvider();

            var listener = new MsbuildMessageListener(this.Log, "WIX", this.BuildEngine.ProjectFileOfTaskNode);

            try
            {
                this.ExecuteCore(serviceProvider, listener);
            }
            catch (WixException e)
            {
                listener.Write(e.Error);
            }
            catch (Exception e)
            {
                this.Log.LogErrorFromException(e);

                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return(!this.Log.HasLoggedErrors);
        }
コード例 #2
0
        public override bool Execute()
        {
            var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();

            var listener = new MsbuildMessageListener(this.Log, this.TaskShortName, this.BuildEngine.ProjectFileOfTaskNode);

            try
            {
                var commandLineBuilder = new WixCommandLineBuilder();
                this.BuildCommandLine(commandLineBuilder);

                var commandLineString = commandLineBuilder.ToString();
                this.ExecuteCore(serviceProvider, listener, commandLineString);
            }
            catch (WixException e)
            {
                listener.Write(e.Error);
            }
            catch (Exception e)
            {
                this.Log.LogErrorFromException(e, showStackTrace: true, showDetail: true, null);

                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            return(!this.Log.HasLoggedErrors);
        }
コード例 #3
0
        private int ExecuteInProc(string commandLineString)
        {
            this.Log.LogMessage(MessageImportance.Normal, $"({this.ToolName}){commandLineString}");

            var listener = new MsbuildMessageListener(this.Log, this.TaskShortName, this.BuildEngine.ProjectFileOfTaskNode);
            var exitCode = -1;

            try
            {
                var coreProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();

                var messaging = coreProvider.GetService <IMessaging>();
                messaging.SetListener(listener);

                exitCode = this.ExecuteCoreAsync(coreProvider, commandLineString, CancellationToken.None).GetAwaiter().GetResult();
            }
            catch (WixException e)
            {
                listener.Write(e.Error);
            }
            catch (Exception e)
            {
                this.Log.LogErrorFromException(e, showStackTrace: true, showDetail: true, null);

                if (e is NullReferenceException || e is SEHException)
                {
                    throw;
                }
            }

            if (exitCode == 0 && this.Log.HasLoggedErrors)
            {
                exitCode = -1;
            }
            return(exitCode);
        }