예제 #1
0
    public override void Setup(T context)
    {
        var buildSystem = context.BuildSystem();

        context.IsLocalBuild         = buildSystem.IsLocalBuild;
        context.IsAzurePipelineBuild = buildSystem.IsRunningOnAzurePipelines || buildSystem.IsRunningOnAzurePipelinesHosted;
        context.IsGitHubActionsBuild = buildSystem.IsRunningOnGitHubActions;

        context.IsPullRequest  = buildSystem.IsPullRequest;
        context.IsOriginalRepo = context.IsOriginalRepo();
        context.IsMainBranch   = context.IsMainBranch();
        context.IsTagged       = context.IsTagged();

        context.IsOnWindows = context.IsRunningOnWindows();
        context.IsOnLinux   = context.IsRunningOnLinux();
        context.IsOnMacOS   = context.IsRunningOnMacOs();

        var gitVersion = context.GitVersion(new GitVersionSettings
        {
            OutputTypes = new HashSet <GitVersionOutput> {
                GitVersionOutput.Json, GitVersionOutput.BuildServer
            }
        });

        context.Version = BuildVersion.Calculate(gitVersion);
    }
예제 #2
0
        public override void Setup(DotNetCoreContext context)
        {
            GitVersionTool.Install(context);

            context.Target                       = context.Argument("target", "Default");
            context.Configuration                = context.Argument("configuration", "Release");
            context.SolutionRoot                 = context.FileSystem.GetDirectory(".").Path.MakeAbsolute(context.Environment);
            context.BuildVersion                 = BuildVersion.Calculate(context);
            context.Artifacts                    = context.Argument("artifacts", "./artifacts");
            context.NugetDefaultPushSourceUrl    = GetEnvOrArg(context, "nugetDefaultPushSourceUrl", "NUGET_DEFAULT_PUSH_SOURCE_URL");
            context.NugetDefaultPushSourceApiKey = GetEnvOrArg(context, "NUGET_DEFAULT_PUSH_SOURCE_URL_API_KEY", "nugetDefaultPushSourceApiKey");

            if (!context.HasArgument("solutionFilePath"))
            {
                var slnPaths = context.Globber.Match("*.sln", x => true).Where(x => !x.FullPath.EndsWith("Build.sln", System.StringComparison.OrdinalIgnoreCase));

                if (slnPaths != null && slnPaths.Count() == 1)
                {
                    context.SolutionFilePath = slnPaths.Single().FullPath;
                }
                else if (slnPaths != null && slnPaths.Count() > 1)
                {
                    throw new CakeException("More than 1 sln files found. Specify the sln file to used with the solutionFilePath argument.");
                }
            }
            else
            {
                context.SolutionFilePath = context.Argument <string>("solutionFilePath", null);
            }

            if (context.SolutionFilePath != null)
            {
                context.Information("Using solution: {0}", context.SolutionFilePath.FullPath);
                var slnResult = context.ParseSolution(context.SolutionFilePath);
                context.Projects = slnResult.Projects.Where(x => !x.Path.FullPath.EndsWith("Solution Items")).Select(x => new Project(x.Path, context.ParseProject(x.Path, context.Configuration))).ToList().AsReadOnly();
            }
            else
            {
                context.Projects = new Project[0];
            }

            var buildSystem = context.BuildSystem();

            context.IsLocalBuild = buildSystem.IsLocalBuild;

            context.DirectoriesToClean = new DirectoryPath[] { context.Artifacts };

            context.Verbose("\n\nDumping context...\n\n{0}", context.ToString());
        }
예제 #3
0
    public override void Setup(Context context)
    {
        // Arguments
        context.Target        = context.Argument <string>("target", "Default");
        context.Configuration = context.Argument <string>("configuration", "Release");
        context.ForcePublish  = context.Argument <bool>("forcepublish", false);
        context.MyGetSource   = GetEnvironmentValueOrArgument(context, "FROSTING_MYGET_SOURCE", "mygetsource");
        context.MyGetApiKey   = GetEnvironmentValueOrArgument(context, "FROSTING_MYGET_API_KEY", "mygetapikey");

        // Directories
        context.Artifacts = new DirectoryPath("./artifacts");

        // Build system information.
        var buildSystem = context.BuildSystem();

        context.AppVeyor       = buildSystem.AppVeyor.IsRunningOnAppVeyor;
        context.IsLocalBuild   = buildSystem.IsLocalBuild;
        context.IsPullRequest  = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
        context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("cake-build/frosting", buildSystem.AppVeyor.Environment.Repository.Name);
        context.IsTagged       = IsBuildTagged(buildSystem);
        context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch);

        // Install tools
        context.Information("Installing tools...");
        ToolInstaller.Install(context, "GitVersion.CommandLine", "3.6.2");

        // Calculate semantic version.
        context.Version            = BuildVersion.Calculate(context);
        context.Version.Version    = context.Argument <string>("version", context.Version.Version);
        context.Version.SemVersion = context.Argument <string>("suffix", context.Version.SemVersion);

        // MSBuild Settings
        context.MSBuildSettings = new DotNetCoreMSBuildSettings()
                                  .WithProperty("Version", context.Version.SemVersion)
                                  .WithProperty("AssemblyVersion", context.Version.Version)
                                  .WithProperty("FileVersion", context.Version.Version);

        context.Information("Version: {0}", context.Version);
        context.Information("Sem version: {0}", context.Version.SemVersion);
        context.Information("Configuration: {0}", context.Configuration);
        context.Information("Target: {0}", context.Target);
        context.Information("AppVeyor: {0}", context.AppVeyor);
    }
예제 #4
0
    public override void Setup(Context context)
    {
        context.Target        = context.Argument("target", "Default");
        context.Configuration = context.Argument("configuration", "Release");
        context.LinkSources   = context.Argument("linkSources", false);
        context.CoreOnly      = context.Argument("CoreOnly", !context.IsRunningOnWindows());

        context.Artifacts = "./packaging/";

        // Build system information.
        var buildSystem = context.BuildSystem();

        context.IsLocalBuild = buildSystem.IsLocalBuild;

        if (context.CoreOnly && !context.IsLocalBuild)
        {
            context.Warning("CoreOnly was specified on a non-local build. Artifacts may be versioned incorrectly!");
        }

        context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor;
        context.TravisCI = buildSystem.TravisCI.IsRunningOnTravisCI;
        context.IsTagged = IsBuildTagged(buildSystem);

        if (context.AppVeyor)
        {
            context.IsPullRequest  = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
            context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.AppVeyor.Environment.Repository.Name);
            context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch);
        }
        else if (context.TravisCI)
        {
            context.IsPullRequest  = !string.IsNullOrEmpty(buildSystem.TravisCI.Environment.Repository.PullRequest);
            context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.TravisCI.Environment.Repository.Slug);
            context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.TravisCI.Environment.Build.Branch);
        }

        // Force publish?
        context.ForcePublish = context.Argument <bool>("forcepublish", false);

        // Setup projects.
        context.Projects = new Project[]
        {
            new Project {
                Name = "Octokit", Path = "./Octokit/Octokit.csproj", Publish = true
            },
            new Project {
                Name = "Octokit.Reactive", Path = "./Octokit.Reactive/Octokit.Reactive.csproj", Publish = true
            },
            new Project {
                Name = "Octokit.Tests", Path = "./Octokit.Tests/Octokit.Tests.csproj", UnitTests = true
            },
            new Project {
                Name = "Octokit.Tests.Conventions", Path = "./Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj", ConventionTests = true
            },
            new Project {
                Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/Octokit.Tests.Integration.csproj", IntegrationTests = true
            }
        };

        // Install tools
        if (context.CoreOnly)
        {
            context.Information("Skipping tool installation for core-only build");
        }
        else
        {
            context.Information("Installing tools...");
            ToolInstaller.Install(context, "Octokit.CodeFormatter", "1.0.0-preview");
        }


        context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.0.0", "dotnet-gitversion");

        // Calculate semantic version.
        context.Version        = BuildVersion.Calculate(context);
        context.Version.Prefix = context.Argument <string>("version", context.Version.Prefix);
        context.Version.Suffix = context.Argument <string>("suffix", context.Version.Suffix);

        context.Information("Version:        {0}", context.Version.Prefix);
        context.Information("Version suffix: {0}", context.Version.Suffix);
        context.Information("Configuration:  {0}", context.Configuration);
        context.Information("LinkSources:    {0}", context.LinkSources);
        context.Information("CoreOnly:       {0}", context.CoreOnly);
        context.Information("Target:         {0}", context.Target);
        context.Information("AppVeyor:       {0}", context.AppVeyor);
        context.Information("TravisCI:       {0}", context.TravisCI);
    }
예제 #5
0
    public override void Setup(Context context)
    {
        context.Target        = context.Argument("target", "Default");
        context.Configuration = context.Argument("configuration", "Release");
        context.LinkSources   = context.Argument("linkSources", false);
        context.FormatCode    = context.Argument("formatCode", false);

        context.Artifacts    = "./packaging/";
        context.CodeCoverage = "./coverage-results/";

        // Build system information.
        var buildSystem = context.BuildSystem();

        context.IsLocalBuild = buildSystem.IsLocalBuild;

        context.GitHubActions = buildSystem.GitHubActions.IsRunningOnGitHubActions;
        context.AppVeyor      = buildSystem.AppVeyor.IsRunningOnAppVeyor;
        context.IsTagged      = IsBuildTagged(buildSystem);

        if (context.AppVeyor)
        {
            context.IsPullRequest  = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
            context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.AppVeyor.Environment.Repository.Name);
            context.IsMainBranch   = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.AppVeyor.Environment.Repository.Branch);
        }
        else if (context.GitHubActions)
        {
            context.IsPullRequest  = buildSystem.GitHubActions.Environment.PullRequest.IsPullRequest;
            context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.GitHubActions.Environment.Workflow.Repository);
            context.IsMainBranch   = StringComparer.OrdinalIgnoreCase.Equals("main", buildSystem.GitHubActions.Environment.Workflow.Ref);
        }

        // Force publish?
        context.ForcePublish = context.Argument <bool>("forcepublish", false);

        // Setup projects.
        context.Projects = new Project[]
        {
            new Project {
                Name = "Octokit", Path = "./Octokit/Octokit.csproj", Publish = true
            },
            new Project {
                Name = "Octokit.Reactive", Path = "./Octokit.Reactive/Octokit.Reactive.csproj", Publish = true
            },
            new Project {
                Name = "Octokit.Tests", Path = "./Octokit.Tests/Octokit.Tests.csproj", UnitTests = true
            },
            new Project {
                Name = "Octokit.Tests.Conventions", Path = "./Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj", ConventionTests = true
            },
            new Project {
                Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/Octokit.Tests.Integration.csproj", IntegrationTests = true
            }
        };

        context.GitVersionToolPath = ToolInstaller.DotNetCoreToolInstall(context, "GitVersion.Tool", "5.1.3", "dotnet-gitversion");

        // Calculate semantic version.
        context.Version        = BuildVersion.Calculate(context);
        context.Version.Prefix = context.Argument <string>("version", context.Version.Prefix);
        context.Version.Suffix = context.Argument <string>("suffix", context.Version.Suffix);

        context.Information("Version:        {0}", context.Version.Prefix);
        context.Information("Version suffix: {0}", context.Version.Suffix);
        context.Information("Configuration:  {0}", context.Configuration);
        context.Information("LinkSources:    {0}", context.LinkSources);
        context.Information("Target:         {0}", context.Target);
        context.Information("AppVeyor:       {0}", context.AppVeyor);
        context.Information("GitHub Actions: {0}", context.GitHubActions);
    }
예제 #6
0
        public override void Setup(DotNetCoreContext context)
        {
            context.Information("v{0}", GetType().Assembly.GetName().Version);
            _lifetimeActions?.BeforeSetup(context);
            if (!context.DisableGitVersion)
            {
                GitVersionTool.InstallGitVersion(context, version: context.GitVersionToolVersion);
            }

            context.Target        = context.Argument("target", "Default");
            context.Configuration = context.Argument("configuration", "Release");
            context.SolutionRoot  = context.FileSystem.GetDirectory(".").Path.MakeAbsolute(context.Environment);
            if (!context.DisableGitVersion)
            {
                context.BuildVersion = BuildVersion.Calculate(context);
            }

            context.Artifacts = context.Argument("artifacts", "./artifacts");
            context.NugetDefaultPushSourceUrl    = GetEnvOrArg(context, "NUGET_DEFAULT_PUSH_SOURCE_URL", "nugetDefaultPushSourceUrl");
            context.NugetDefaultPushSourceApiKey = GetEnvOrArg(context, "NUGET_DEFAULT_PUSH_SOURCE_API_KEY", "nugetDefaultPushSourceApiKey");

            if (!context.HasArgument("solutionFilePath"))
            {
                var slnPaths = context.Globber.Match("*.sln", x => true).Where(x => !x.FullPath.EndsWith("Build.sln", System.StringComparison.OrdinalIgnoreCase));

                if (slnPaths != null && slnPaths.Count() == 1)
                {
                    context.SolutionFilePath = slnPaths.Single().FullPath;
                }
                else if (slnPaths != null && slnPaths.Count() > 1)
                {
                    throw new CakeException("More than 1 sln files found. Specify the sln file to used with the solutionFilePath argument.");
                }
            }
            else
            {
                context.SolutionFilePath = context.SolutionFilePath != null && context.SolutionFilePath.IsSolution() ? context.SolutionFilePath : context.Argument <string>("solutionFilePath", null);
            }

            if (context.SolutionFilePath != null)
            {
                context.Information("Using solution: {0}", context.SolutionFilePath.FullPath);
                var slnResult = context.ParseSolution(context.SolutionFilePath);
                context.Projects = slnResult.Projects.Where(x => {
                    return(!x.IsSolutionFolder());
                }).Select(x => new Project(x.Path, context.ParseProject(x.Path, context.Configuration))).ToList().AsReadOnly();
            }
            else
            {
                context.Projects = new Project[0];
            }

            var buildSystem = context.BuildSystem();

            context.IsLocalBuild = buildSystem.IsLocalBuild;
            if (buildSystem.IsRunningOnTeamCity)
            {
                //do specific TC stuff here
            }

            context.DirectoriesToClean = new DirectoryPath[] { context.Artifacts };

            _lifetimeActions?.AfterSetup(context);
        }
예제 #7
0
    public override void Setup(Context context)
    {
        // Arguments
        context.Target                            = context.Argument <string>("target", "Default");
        context.BuildConfiguration                = context.Argument <string>("configuration", "Release");
        context.ForcePublish                      = context.Argument <bool>("forcepublish", false);
        context.AzureArtifactsSourceUrl           = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_URL", "azureartifactssourceurl");
        context.AzureArtifactsPersonalAccessToken = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN", "mygetapikey");
        context.AzureArtifactsSourceName          = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_NAME", "azureartifactssourcename");
        context.AzureArtifactsSourceUserName      = GetEnvironmentValueOrArgument(context, "FROSTING_AZURE_ARTIFACTS_SOURCE_USER_NAME", "azureartifactssourceusername");
        context.GitHubToken                       = GetEnvironmentValueOrArgument(context, "FROSTING_GITHUB_TOKEN", "githubtoken");

        // Directories
        context.Artifacts = new DirectoryPath("./artifacts");

        // Build system information.
        var buildSystem = context.BuildSystem();

        context.AppVeyor          = buildSystem.AppVeyor.IsRunningOnAppVeyor;
        context.IsLocalBuild      = buildSystem.IsLocalBuild;
        context.IsPullRequest     = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
        context.PrimaryBranchName = "master";
        context.RepositoryOwner   = "cake-build";
        context.RepositoryName    = "frosting";
        context.IsOriginalRepo    = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(context.RepositoryOwner, "/", context.RepositoryName), buildSystem.AppVeyor.Environment.Repository.Name);
        context.IsTagged          = IsBuildTagged(buildSystem);
        context.IsPrimaryBranch   = StringComparer.OrdinalIgnoreCase.Equals(context.PrimaryBranchName, buildSystem.AppVeyor.Environment.Repository.Branch);
        context.BuildSystem       = buildSystem;

        // Install Global .Net Tools
        context.Information("Installing .Net Global Tools...");
        context.DotNetCoreToolInstall("GitReleaseManager.Tool", "0.11.0", "dotnet-gitreleasemanager");
        context.DotNetCoreToolInstall("SignClient", "1.2.109", "SignClient");
        context.DotNetCoreToolInstall("GitVersion.Tool", "5.1.2", "dotnet-gitversion");

        // Calculate semantic version.
        context.Version            = BuildVersion.Calculate(context);
        context.Version.Version    = context.Argument <string>("version", context.Version.Version);
        context.Version.SemVersion = context.Argument <string>("suffix", context.Version.SemVersion);

        // MSBuild Settings
        context.MSBuildSettings = new DotNetCoreMSBuildSettings()
                                  .WithProperty("Version", context.Version.SemVersion)
                                  .WithProperty("AssemblyVersion", context.Version.Version)
                                  .WithProperty("FileVersion", context.Version.Version);

        if (context.AppVeyor)
        {
            context.MSBuildSettings.WithProperty("ContinuousIntegrationBuild", "true");
        }

        if (!context.IsRunningOnWindows())
        {
            var frameworkPathOverride = context.Environment.Runtime.IsCoreClr
                                        ?   new [] {
                new DirectoryPath("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono"),
                new DirectoryPath("/usr/lib/mono"),
                new DirectoryPath("/usr/local/lib/mono")
            }
            .Select(directory => directory.Combine("4.5"))
            .FirstOrDefault(directory => context.FileSystem.Exist(directory))
            ?.FullPath + "/"
                                        : new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/";

            // Use FrameworkPathOverride when not running on Windows.
            context.Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride);
            context.MSBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
        }

        context.Information("Version: {0}", context.Version);
        context.Information("Sem version: {0}", context.Version.SemVersion);
        context.Information("Configuration: {0}", context.BuildConfiguration);
        context.Information("Target: {0}", context.Target);
        context.Information("AppVeyor: {0}", context.AppVeyor);
    }