Пример #1
0
    /// <summary>
    /// Pre-Processing that must occur for majority of the targets to work.
    /// </summary>
    private void PreProcessing()
    {
        if (Configuration == null)
        {
            if (InvokedTargets.Contains(PublishProd))
            {
                Configuration = Configuration.Release;
            }
            else
            {
                Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
            }
        }


        Utility.ValidateGetVersionEnvVariable();

        // Loads the Solution specific configuration information for building.
        string json = File.ReadAllText(RootDirectory / "NukeSolutionBuild.Conf");

        CustomNukeSolutionConfig = JsonSerializer.Deserialize <CustomNukeSolutionConfig>(json, CustomNukeSolutionConfig.SerializerOptions());
        ControlFlow.Assert(CustomNukeSolutionConfig.CheckRootFolders(),
                           "The DeployProdRoot or DeployTestRoot in the NukeSolutionBuild.Conf do not contain valid entries.  Run SlugNuke --Target Setup to fix.");

        // Setup the GitProcessor
        _gitProcessor = new GitProcessor(RootDirectory);


        if (_gitProcessor.GitVersion == null)
        {
            Logger.Error("GitVersion not Loaded");
        }

        // Get current branch and ensure there are no uncommitted updates.  These methods will throw if anything is out of sorts.
        _gitProcessor.GetCurrentBranch();
        _gitProcessor.IsUncommittedChanges();
        _gitProcessor.IsBranchUpToDate();

        if (_gitProcessor.IsCurrentBranchMainBranch() && InvokedTargets.Contains(Publish))
        {
            string msg =
                @"The current branch is the main branch, yet you are running a Test Publish command.  This is unsupported as it will cause version issues in Git.  " +
                "Either create a branch off master to put the changes into (this is probably what you want) OR change Target command to PublishProd.";
            ControlFlow.Assert(1 == 0, msg);
        }
    }