Пример #1
0
        private static InstallResult ValidatePackage(IManifest[] manifests, StepVisitor visitor, bool enableCustomValidation, out int warnings)
        {
            InstallResult result = new InstallResult();

            warnings = 0;
            int warn;

            if (enableCustomValidation)
            {
                if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnPackageValidating(default(bool))), visitor.IsProbing, out warn))
                {
                    return(ReturnWithErrorResult());
                }
                warnings += warn;
            }

            foreach (var manifest in manifests)
            {
                if (enableCustomValidation)
                {
                    Logger.LogMessage(String.Concat("Validating ", manifest.PackageInfo.Name, " (version: ", manifest.PackageInfo.Version, ")"));
                }

                var pkgInfo = manifest.PackageInfo;
                if (pkgInfo == null)
                {
                    Logger.LogMessage("Required PackageDescription is missing");
                    return(new InstallResult {
                        Successful = false
                    });
                }
                CheckPackageNameAndVersion(pkgInfo);

                if (enableCustomValidation)
                {
                    Logger.LogMessage("Package is valid.");
                }
            }

            if (enableCustomValidation)
            {
                if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnPackageValidated(default(bool))), visitor.IsProbing, out warn))
                {
                    return(ReturnWithErrorResult());
                }
                warnings += warn;
            }

            return(new InstallResult {
                Successful = true
            });
        }
Пример #2
0
        internal void Combine(InstallResult other)
		{
			Successful &= other.Successful;
			NeedRestart |= other.NeedRestart;
        }
Пример #3
0
 internal void Combine(InstallResult other)
 {
     Successful  &= other.Successful;
     NeedRestart |= other.NeedRestart;
 }
Пример #4
0
        private static InstallResult DoIt(string fsPath, StepVisitor visitor, bool withBinaries)
        {
            InstallResult result = new InstallResult {
                Successful = true, NeedRestart = false
            };

            try
            {
                int warn;
                int err;
                int warnings = 0;
                int errors   = 0;

                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += new ResolveEventHandler(AssemblyHandler.CurrentDomain_ReflectionOnlyAssemblyResolve);
                var unpacker = CreateUnpacker(fsPath);

                var manifests = unpacker.Unpack(fsPath);

                var dbScripts = GetDbScripts(manifests);

                InstallResult dbScriptResult;
                dbScriptResult = ExecuteDbScripts(PositionInSequence.BeforePackageValidating, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                var validateResult = ValidatePackage(manifests, visitor, withBinaries, out warn);
                warnings += warn;
                if (!validateResult.Successful)
                {
                    return(validateResult);
                }
                result.Combine(validateResult);

                dbScriptResult = ExecuteDbScripts(PositionInSequence.AfterPackageValidating, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                //------------------------------------------------------------

                if (withBinaries)
                {
                    dbScriptResult = ExecuteDbScripts(PositionInSequence.BeforeCheckRequirements, dbScripts, visitor);
                    if (!dbScriptResult.Successful)
                    {
                        return(dbScriptResult);
                    }
                    result.Combine(dbScriptResult);

                    Logger.LogMessage("");
                    Logger.LogMessage("------------------------------ Prerequisits ---------------------------------");
                    Logger.LogMessage("");
                    result.Combine(ExecutePrerequisits(manifests, visitor, out warn, out err));
                    warnings += warn;
                    if (!result.Successful)
                    {
                        return(result);
                    }

                    dbScriptResult = ExecuteDbScripts(PositionInSequence.AfterCheckRequirements, dbScripts, visitor);
                    if (!dbScriptResult.Successful)
                    {
                        return(dbScriptResult);
                    }
                    result.Combine(dbScriptResult);

                    dbScriptResult = ExecuteDbScripts(PositionInSequence.BeforeExecutables, dbScripts, visitor);
                    if (!dbScriptResult.Successful)
                    {
                        return(dbScriptResult);
                    }
                    result.Combine(dbScriptResult);

                    Logger.LogMessage("");
                    Logger.LogMessage("------------------------------ Executables ----------------------------------");
                    Logger.LogMessage("");
                    result.Combine(ExecuteExecutables(manifests, visitor, out warn, out err));
                    warnings += warn;

                    dbScriptResult = ExecuteDbScripts(PositionInSequence.AfterExecutables, dbScripts, visitor);
                    if (!dbScriptResult.Successful)
                    {
                        return(dbScriptResult);
                    }
                    result.Combine(dbScriptResult);

                    if (!result.Successful || result.NeedRestart)
                    {
                        if (warnings > 0)
                        {
                            Logger.LogMessage(String.Concat(warnings, " warnings"));
                        }
                        if (errors > 0)
                        {
                            Logger.LogMessage(String.Concat(errors, " errors"));
                        }
                        return(result);
                    }
                }

                dbScriptResult = ExecuteDbScripts(PositionInSequence.BeforeContentTypes, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                Logger.LogMessage("");
                Logger.LogMessage("------------------------------ ContentTypes ---------------------------------");
                Logger.LogMessage("");
                result.Combine(ExecuteContentTypes(manifests, visitor, out warn, out err));
                warnings += warn;
                if (!result.Successful)
                {
                    return(result);
                }

                dbScriptResult = ExecuteDbScripts(PositionInSequence.AfterContentTypes, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                dbScriptResult = ExecuteDbScripts(PositionInSequence.BeforeContents, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                Logger.LogMessage("");
                Logger.LogMessage("-------------------------------- Contents -----------------------------------");
                Logger.LogMessage("");
                result.Combine(ExecuteContents(manifests, visitor, out warn, out err));
                warnings += warn;
                if (!result.Successful)
                {
                    return(result);
                }

                dbScriptResult = ExecuteDbScripts(PositionInSequence.AfterContents, dbScripts, visitor);
                if (!dbScriptResult.Successful)
                {
                    return(dbScriptResult);
                }
                result.Combine(dbScriptResult);

                if (warnings > 0)
                {
                    Logger.LogMessage(String.Concat(warnings, " warnings"));
                }
                if (errors > 0)
                {
                    Logger.LogMessage(String.Concat(errors, " errors"));
                }

                return(result);
            }
            catch (Exception e)
            {
                Logger.LogException(e);
                return(new InstallResult {
                    Successful = false
                });
            }
        }