Example #1
0
        internal static AppConfig ValidateAndCreate(AppConfigRaw rawConfig)
        {
            if (IsNoStorageOptionsSet(rawConfig) || IsBothStorageOptionsSet(rawConfig))
            {
                return(new InvalidAppConfig("Invalid storage settings"));
            }

            if (rawConfig.UseAzureStorage.HasValue() && !AllAzureSettingsHasValue(rawConfig))
            {
                return(new InvalidAppConfig("Missing Azure Storage settings"));
            }

            if (rawConfig.UseLocalStorage.HasValue() && !AllLocalSettingsHasValue(rawConfig))
            {
                return(new InvalidAppConfig("Missing Local Storage settings"));
            }

            if (!rawConfig.ConfigFileName.HasValue())
            {
                return(new InvalidAppConfig("Missing config file name"));
            }

            if (!rawConfig.SolutionFile.HasValue())
            {
                return(new InvalidAppConfig("Missing solution file name"));
            }

            if (!rawConfig.UniqueVersionIdentifier.HasValue())
            {
                return(new InvalidAppConfig("Missing Unique Version Identifier"));
            }

            var config = new AppConfig
            {
                UseAzureStorage              = rawConfig.UseAzureStorage.HasValue(),
                AzureStorageAccountName      = rawConfig.AzureStorageAccountName.Value(),
                AzureStorageAccountSecret    = rawConfig.AzureStorageAccountSecret.Value(),
                AzureStorageAccountContainer = rawConfig.AzureStorageAccountContainer.Value(),
                UseLocalStorage              = rawConfig.UseLocalStorage.HasValue(),
                LocalStoragePath             = rawConfig.LocalStoragePath.HasValue() ? new DirectoryInfo(rawConfig.LocalStoragePath.Value()) : new DirectoryInfo("c:"),
                ConfigFileName          = rawConfig.ConfigFileName.Value(),
                SolutionFile            = new FileInfo(rawConfig.SolutionFile.Value()),
                BuildConfiguration      = rawConfig.BuildConfiguration.HasValue() ? rawConfig.BuildConfiguration.Value() : "Release",
                UniqueVersionIdentifier = rawConfig.UniqueVersionIdentifier.Value(),
                UseSecureCluster        = rawConfig.UseSecureCluster.HasValue(),
                ForcePackageAll         = rawConfig.ForcePackageAll.HasValue(),
                CleanOutputFolder       = rawConfig.CleanOutputFolder.HasValue(),
                PackageOutputPath       = GetPackageOutputPath(rawConfig),
                VerboseOutput           = rawConfig.VerboseOutput.HasValue(),
                SelfPath = new DirectoryInfo(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)),
                DotNetPublishExtraArgs = rawConfig.DotNetPublishExtraArgs.Value(),
            };

            config.SourcePath = config.SolutionFile.Directory;

            return(config);
        }
Example #2
0
 private static bool IsNoStorageOptionsSet(AppConfigRaw rawConfig)
 {
     return(!rawConfig.UseAzureStorage.HasValue() &&
            !rawConfig.UseLocalStorage.HasValue());
 }
Example #3
0
 private static bool AllLocalSettingsHasValue(AppConfigRaw rawConfig)
 {
     return(rawConfig.LocalStoragePath.HasValue());
 }
Example #4
0
 private static bool AllAzureSettingsHasValue(AppConfigRaw rawConfig)
 {
     return(rawConfig.AzureStorageAccountContainer.HasValue() &&
            rawConfig.AzureStorageAccountName.HasValue() &&
            rawConfig.AzureStorageAccountSecret.HasValue());
 }
Example #5
0
 private static DirectoryInfo GetPackageOutputPath(AppConfigRaw rawConfig)
 {
     return(rawConfig.PackageOutputPath.HasValue()
         ? new DirectoryInfo(rawConfig.PackageOutputPath.Value())
         : new DirectoryInfo(Path.Combine(rawConfig.SolutionFile.Value(), "sfpackaging")));
 }