Exemplo n.º 1
0
        public async Task DifferentVersions_UpgradeIsCompleted()
        {
            migrationRunnerService.Execute(Arg.Any <SemVersion>(), Arg.Any <SemVersion>()).Returns(true);
            var anyStringArg = Arg.Any <string>();

            settings.TryGetSiteRootDirectory(out anyStringArg).Returns(
                x => {
                x[0] = @"C:\test\umbraco";
                return(true);
            });

            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(
                "<configuration>" +
                "<appSettings>" +
                "<add key=\"umbracoConfigurationStatus\" value=\"1.1.1\" />" +
                "</appSettings>" +
                "</configuration>"
                );

            xmlDocumentWrapper.LoadDocument(Arg.Any <string>()).Returns(xmlDoc);

            var deliverable = new UpgradeDeliverable(null, writer, migrationRunnerService,
                                                     MigrationEntryService(new SemVersion(7, 1)), settings, xmlDocumentWrapper);

            var response = await deliverable.Run(null, null);

            Assert.Equal(2, writer.Messages.Count());
            Assert.Equal(DeliverableResponse.Continue, response);
        }
Exemplo n.º 2
0
        public override async Task <DeliverableResponse> Run(string command, string[] args)
        {
            if (!TryFindCurrentDbVersion(out var currentVersion))
            {
                await Out.WriteLineAsync("Can't upgrade as there is no configured version");

                return(DeliverableResponse.FinishedWithError);
            }

            var targetVersion = UmbracoVersion.GetSemanticVersion();

            if (currentVersion == targetVersion)
            {
                await Out.WriteLineAsync($"Version is up to date {currentVersion} no work todo");

                return(DeliverableResponse.FinishedWithError);
            }

            await Out.WriteLineAsync($"Upgrading from {currentVersion} to {targetVersion}");

            var upgraded = migrationRunner.Execute(currentVersion, targetVersion);

            if (!upgraded)
            {
                await Out.WriteLineAsync("Upgrading failed, see log for full details");

                return(DeliverableResponse.FinishedWithError);
            }

            chauffeurSettings.TryGetSiteRootDirectory(out string path);
            var         configPath = Path.Combine(path, "web.config");
            XmlDocument xmld       = xmlDocumentWrapper.LoadDocument(configPath);

            XmlElement status = (XmlElement)xmld.SelectSingleNode("/configuration/appSettings/add[@key='umbracoConfigurationStatus']");

            if (status != null)
            {
                status.SetAttribute("value", targetVersion.ToString());
            }
            xmlDocumentWrapper.SaveDocument(xmld, configPath);

            await Out.WriteLineAsync("Upgrading completed");

            return(DeliverableResponse.Continue);
        }