LogTitle() public static method

public static LogTitle ( string title ) : void
title string
return void
Exemplo n.º 1
0
        public static PackagingResult Execute(string packagePath, string targetPath, int phase, string[] parameters, TextWriter console)
        {
            var phaseCount = 1;

            var files = Directory.GetFiles(packagePath);

            Manifest  manifest = null;
            Exception manifestParsingException = null;

            if (files.Length == 1)
            {
                try
                {
                    manifest   = Manifest.Parse(files[0], phase == 0);
                    phaseCount = manifest.CountOfPhases;
                }
                catch (Exception e)
                {
                    manifestParsingException = e;
                }
            }

            if (files.Length == 0)
            {
                throw new InvalidPackageException(SR.Errors.ManifestNotFound);
            }
            if (files.Length > 1)
            {
                throw new InvalidPackageException(SR.Errors.PackageCanContainOnlyOneFileInTheRoot);
            }
            if (manifestParsingException != null)
            {
                throw new PackagingException("Manifest parsing error. See inner exception.", manifestParsingException);
            }
            if (manifest == null)
            {
                throw new PackagingException("Manifest was not found.");
            }

            SubstituteParameters(manifest, parameters);
            var sandboxPath = Path.Combine(Path.GetDirectoryName(packagePath), SANDBOXDIRECTORYNAME);

            Logger.LogTitle(String.Format("Executing phase {0}/{1}", phase + 1, phaseCount));

            var configEntry    = ConfigurationManager.AppSettings["NetworkTargets"];
            var networkTargets = string.IsNullOrEmpty(configEntry) ? new string[0] : configEntry.Split(',', ';').Select(x => x.Trim()).ToArray();

            var executionContext = new ExecutionContext(packagePath, targetPath, networkTargets, sandboxPath, manifest, phase, manifest.CountOfPhases, console);
            var result           = ExecuteCurrentPhase(manifest, executionContext);

            if (Repository.Started())
            {
                console.WriteLine("-------------------------------------------------------------");
                console.Write("Stopping repository ... ");
                Repository.Shutdown();
                console.WriteLine("Ok.");
            }

            return(result);
        }
Exemplo n.º 2
0
        public static PackagingResult Execute(string packagePath, string targetPath, int currentPhase, string[] parameters, TextWriter console)
        {
            var packageParameters = parameters?.Select(PackageParameter.Parse).ToArray() ?? new PackageParameter[0];
            var forcedReinstall   = "true" == (packageParameters
                                               .FirstOrDefault(p => p.PropertyName.ToLowerInvariant() == "forcedreinstall")?
                                               .Value?.ToLowerInvariant() ?? "");

            var phaseCount = 1;

            var files = Directory.GetFiles(packagePath);

            Manifest  manifest = null;
            Exception manifestParsingException = null;

            if (files.Length == 1)
            {
                try
                {
                    manifest   = Manifest.Parse(files[0], currentPhase, currentPhase == 0, packageParameters, forcedReinstall);
                    phaseCount = manifest.CountOfPhases;
                }
                catch (Exception e)
                {
                    manifestParsingException = e;
                }
            }

            if (files.Length == 0)
            {
                throw new InvalidPackageException(SR.Errors.ManifestNotFound);
            }
            if (files.Length > 1)
            {
                throw new InvalidPackageException(SR.Errors.PackageCanContainOnlyOneFileInTheRoot);
            }
            if (manifestParsingException != null)
            {
                throw new PackagingException("Manifest parsing error. See inner exception.", manifestParsingException);
            }
            if (manifest == null)
            {
                throw new PackagingException("Manifest was not found.");
            }

            Logger.LogTitle(String.Format("Executing phase {0}/{1}", currentPhase + 1, phaseCount));

            var sandboxDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var executionContext = new ExecutionContext(packagePath, targetPath, Configuration.Packaging.NetworkTargets,
                                                        sandboxDirectory, manifest, currentPhase, manifest.CountOfPhases, packageParameters, console);

            executionContext.LogVariables();

            PackagingResult result;

            try
            {
                result = ExecuteCurrentPhase(manifest, executionContext);
            }
            finally
            {
                if (Repository.Started())
                {
                    console.WriteLine("-------------------------------------------------------------");
                    console.Write("Stopping repository ... ");
                    Repository.Shutdown();
                    console.WriteLine("Ok.");
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public static PackagingResult Execute(string packagePath, string targetPath, int currentPhase,
                                              PackageParameter[] parameters, TextWriter console,
                                              RepositoryBuilder builder = null, bool editConnectionString = false)
        {
            // Workaround for setting the packaging db provider: in normal cases this happens
            // when the repository starts, but in case of package execution the repository
            // is not yet started sometimes.
            if (null == DataStore.GetDataProviderExtension <IPackagingDataProviderExtension>())
            {
                DataStore.SetDataProviderExtension(typeof(IPackagingDataProviderExtension), new MsSqlPackagingDataProvider());
            }

            var packageParameters = parameters ?? new PackageParameter[0];
            var forcedReinstall   = "true" == (packageParameters
                                               .FirstOrDefault(p => p.PropertyName.ToLowerInvariant() == "forcedreinstall")?
                                               .Value?.ToLowerInvariant() ?? "");

            var phaseCount = 1;

            var files = Directory.GetFiles(packagePath);

            Manifest  manifest = null;
            Exception manifestParsingException = null;

            if (files.Length == 1)
            {
                try
                {
                    manifest = Manifest.Parse(files[0], currentPhase, currentPhase == 0, packageParameters,
                                              forcedReinstall, editConnectionString);
                    phaseCount = manifest.CountOfPhases;
                }
                catch (Exception e)
                {
                    manifestParsingException = e;
                }
            }

            if (files.Length == 0)
            {
                throw new InvalidPackageException(SR.Errors.ManifestNotFound);
            }
            if (files.Length > 1)
            {
                throw new InvalidPackageException(SR.Errors.PackageCanContainOnlyOneFileInTheRoot);
            }
            if (manifestParsingException != null)
            {
                throw new PackagingException("Manifest parsing error. See inner exception.", manifestParsingException);
            }
            if (manifest == null)
            {
                throw new PackagingException("Manifest was not found.");
            }

            Logger.LogTitle(String.Format("Executing phase {0}/{1}", currentPhase + 1, phaseCount));

            var sandboxDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var executionContext = ExecutionContext.Create(packagePath, targetPath, Configuration.Packaging.NetworkTargets,
                                                           sandboxDirectory, manifest, currentPhase, manifest.CountOfPhases, packageParameters, console, builder);

            executionContext.LogVariables();

            PackagingResult result;

            try
            {
                result = ExecuteCurrentPhase(manifest, executionContext);
            }
            finally
            {
                if (Repository.Started())
                {
                    console.WriteLine("-------------------------------------------------------------");
                    console.Write("Stopping repository ... ");
                    Repository.Shutdown();
                    console.WriteLine("Ok.");
                }
            }

            return(result);
        }