예제 #1
0
        protected override async Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            try
            {
                var updaterResult = (FileUpdaterResult)(await _updater.ApplyAsync(context, _razorUpdaterStep.RazorDocuments, token).ConfigureAwait(false));
                if (updaterResult.Result)
                {
                    // Process Razor documents again after successfully applying an updater in case Razor files have changed
                    _razorUpdaterStep.ProcessRazorDocuments(updaterResult.FilePaths);

                    return(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty));
                }
                else
                {
                    return(new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Failed to apply Razor updater \"{_updater.Title}\""));
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception exc)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                Logger.LogError(exc, "Unexpected exception while applying Razor updater \"{RazorUpdater}\"", _updater.Title);
                return(new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Unexpected exception while applying Razor updater \"{_updater.Title}\": {exc}"));
            }
        }
        protected override async Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var currentProject = context.CurrentProject.Required();

            try
            {
                var updaterResult = (WindowsDesktopUpdaterResult)(await _updater.ApplyAsync(context, ImmutableArray <IProject> .Empty.Add(currentProject), token).ConfigureAwait(false));
                if (updaterResult.Result)
                {
                    return(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty));
                }
                else
                {
                    return(new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Failed to apply Windows Desktop updater \"{_updater.Title}\""));
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception exc)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                Logger.LogError(exc, "Unexpected exception while applying Windows Desktop updater \"{WinformsUpdater}\"", _updater.Title);
                return(new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Unexpected exception while applying Windows Desktop updater \"{_updater.Title}\": {exc}"));
            }
        }
예제 #3
0
        protected override async Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            try
            {
                return((await _configUpdater.ApplyAsync(context, _parentStep.ConfigFiles, token).ConfigureAwait(false)).Result
                    ? new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty)
                    : new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Failed to apply config updater \"{_configUpdater.Title}\""));
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception exc)
#pragma warning restore CA1031 // Do not catch general exception types
            {
                Logger.LogError(exc, "Unexpected exception while apply config updater \"{ConfigUpdater}\"", _configUpdater.Title);
                return(new UpgradeStepApplyResult(UpgradeStepStatus.Failed, $"Unexpected exception while applying config updater \"{_configUpdater.Title}\": {exc}"));
            }
        }