public override void Run(ICakeContext context) { CakeLicenseHeaderUpdaterSettings settings = new CakeLicenseHeaderUpdaterSettings { // Need the "my_" in front because otherwise Cake things its the dry run for *it* // not for us. DryRun = context.Argument <bool>($"my_{nameof( CakeLicenseHeaderUpdaterSettings.DryRun )}", false), LicenseString = context.Argument(nameof(CakeLicenseHeaderUpdaterSettings.LicenseString), string.Empty), Threads = 1, Verbosity = Verbosity.Diagnostic }; for (int i = 1; i <= MaximumRegexes; ++i) { string argName = $"{nameof( CakeLicenseHeaderUpdaterSettings.OldHeaderRegexPatterns )}_{i}"; if (context.HasArgument(argName)) { settings.OldHeaderRegexPatterns.Add(context.Arguments.GetArgument(argName)); } } string globPattern = context.Argument("files", string.Empty); if (string.IsNullOrWhiteSpace(globPattern)) { throw new ArgumentException("'files' can not be empty"); } context.UpdateLicenseHeaders(context.GetFiles(globPattern), settings); }
public static void Configure(ICakeContext context) { Context = context; Configuration = Context.Argument("configuration", "Release"); UseXBuildOnWindows = Context.Argument("forcexbuild", false); var targetDir = Context.Argument <string>("targetdir", null); if (targetDir != null) { TargetDirectory = targetDir; } var platform = Context.Argument("platforms", Context.Argument <string>("platforms", null)); if (platform != null) { var allPlatforms = platform.Split(';'); foreach (var p in allPlatforms) { PlatformTarget parsed; if (Enum.TryParse(p, true, out parsed)) { Platforms.Add(parsed); } else { var strings = Enum.GetNames(typeof(PlatformTarget)); throw new ArgumentException( "Not a valid platform specifier. Valid values are " + string.Join(", ", strings) + ".", "platform"); } } } }
public BuildContext(ICakeContext context) : base(context) { BuildConfiguration = context.Argument("Configuration", "Release"); SkipTests = context.Argument("SkipTests", false); SkipSlowTests = context.Argument("SkipSlowTests", false); RootDirectory = new DirectoryPath(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName); ArtifactsDirectory = RootDirectory.Combine("artifacts"); ToolsDirectory = RootDirectory.Combine("tools"); DocsDirectory = RootDirectory.Combine("docs"); DocfxDirectory = ToolsDirectory.Combine("docfx"); DocfxExeFile = DocfxDirectory.CombineWithFilePath("docfx.exe"); DocfxJsonFile = DocsDirectory.CombineWithFilePath("docfx.json"); TestOutputDirectory = RootDirectory.Combine("TestResults"); ChangeLogDirectory = RootDirectory.Combine("docs").Combine("changelog"); ChangeLogGenDirectory = RootDirectory.Combine("docs").Combine("_changelog"); SolutionFile = RootDirectory.CombineWithFilePath("BenchmarkDotNet.sln"); UnitTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.Tests") .CombineWithFilePath("BenchmarkDotNet.Tests.csproj"); IntegrationTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.IntegrationTests") .CombineWithFilePath("BenchmarkDotNet.IntegrationTests.csproj"); TemplatesTestsProjectFile = RootDirectory.Combine("templates") .CombineWithFilePath("BenchmarkDotNet.Templates.csproj"); AllPackableSrcProjects = new FilePathCollection(context.GetFiles(RootDirectory.FullPath + "/src/**/*.csproj") .Where(p => !p.FullPath.Contains("Disassembler"))); MsBuildSettings = new DotNetCoreMSBuildSettings { MaxCpuCount = 1 }; MsBuildSettings.WithProperty("UseSharedCompilation", "false"); }
public static void Configure(ICakeContext context) { Context = context; StagingBranchPattern = "release-{0}"; VersionTagPattern = "v{0}"; ReleaseTargetBranch = context.Argument("release", "master"); DevelopBranch = context.Argument("dev", "develop"); PushTarget = context.Argument <string>("push", null); }
public static void Configure(ICakeContext context) { Context = context; Version = Context.Argument("version", AutoConfigureVersion()); ApiVersion = Context.Argument("api-version", AutoConfigureApiVersion()); PushSettings.SymbolsApiKey = Context.Environment.GetEnvironmentVariable("NUGET_SYMBOLS_API_KEY"); PushSettings.SymbolsSource = Context.Environment.GetEnvironmentVariable("NUGET_SYMBOLS_SOURCE"); PushSettings.ApiKey = Context.Environment.GetEnvironmentVariable("NUGET_API_KEY"); PushSettings.Source = Context.Environment.GetEnvironmentVariable("NUGET_SOURCE"); }
public Context(ICakeContext context) : base(context) { try { ////////////////////////////////////////////////////////////////////// // ARGUMENTS ////////////////////////////////////////////////////////////////////// this.target = context.Argument("target", "Default"); context.Information($"Target: {target}"); this.configuration = context.Argument("configuration", "Release"); context.Information($"Configuration: {configuration}"); ////////////////////////////////////////////////////////////////////// // PREPARATION ////////////////////////////////////////////////////////////////////// // Define directories. this.tempFolder = "./Temp/"; this.tempDir = context.Directory(tempFolder); context.Information($"TempDir: {tempDir}"); this.artifactsFolder = "./Artifacts/"; this.artifactsDir = context.Directory(this.artifactsFolder); context.Information($"ArtifactsDir: {artifactsDir}"); this.websiteFolder = "./Website/"; this.websiteDir = context.Directory(this.websiteFolder); context.Information($"WebsiteDir: {websiteDir}"); // Global information variables this.isRunningInCI = false; this.dnnSolutionPath = "./DNN_Platform.sln"; this.sqlDataProviderExists = false; var settingsFile = "../settings.local.json"; this.Settings = this.LoadSettings(settingsFile); WriteSettings(settingsFile); this.buildId = context.EnvironmentVariable("BUILD_BUILDID") ?? "0"; context.Information($"BuildId: {buildId}"); this.buildNumber = ""; this.productVersion = ""; } catch (Exception exc) { this.Error(exc); throw; } }
/// <summary>Initializes a new instance of the <see cref="Context"/> class.</summary> /// <param name="context">The base context.</param> public Context(ICakeContext context) : base(context, RepositoryInfoProviderType.CakeGit) { try { ////////////////////////////////////////////////////////////////////// // ARGUMENTS ////////////////////////////////////////////////////////////////////// this.Target = context.Argument("target", "Default"); context.Information($"Target: {this.Target}"); this.BuildConfiguration = context.Argument("configuration", "Release"); context.Information($"Configuration: {this.BuildConfiguration}"); ////////////////////////////////////////////////////////////////////// // PREPARATION ////////////////////////////////////////////////////////////////////// // Define directories. this.TempFolder = "./Temp/"; this.TempDir = context.Directory(this.TempFolder); context.Information($"TempDir: {this.TempDir}"); this.ArtifactsFolder = "./Artifacts/"; this.ArtifactsDir = context.Directory(this.ArtifactsFolder); context.Information($"ArtifactsDir: {this.ArtifactsDir}"); this.WebsiteFolder = "./Website/"; this.WebsiteDir = context.Directory(this.WebsiteFolder); context.Information($"WebsiteDir: {this.WebsiteDir}"); // Global information variables this.IsRunningInCI = false; this.DnnSolutionPath = "./DNN_Platform.sln"; this.SqlDataProviderExists = false; const string settingsFile = "./settings.local.json"; this.Settings = LoadSettings(context, settingsFile); this.WriteSettings(context, settingsFile); this.BuildId = context.EnvironmentVariable("BUILD_BUILDID") ?? "0"; context.Information($"BuildId: {this.BuildId}"); this.BuildNumber = string.Empty; this.ProductVersion = string.Empty; } catch (Exception exc) { this.Error(exc); throw; } }
private static string EvaluateVariable(ICakeContext context, string variableName, bool hasDefaultValue, string defaultValue) { string envVariablename = EnvNameFromVariableName(variableName); string value; if (context.HasArgument(variableName)) { value = context.Argument <string>(variableName); } else if (context.HasEnvironmentVariable(envVariablename)) { value = context.EnvironmentVariable(envVariablename); } else { if (hasDefaultValue) { return(defaultValue); } else { throw new ArgumentException($"No argument found with name {variableName} and no environment variable found with name {envVariablename}!"); } } return(value); }
public Context(ICakeContext context) : base(context) { BuildConfiguration = context.Argument("configuration", "Release"); Runtime = context.Argument("runtime", RuntimeEnvironment.GetRuntimeIdentifier()); VersionSuffix = context.Argument("version-suffix", string.Empty); var distFormat = context.Argument("dist-format", "zip").ToLowerInvariant(); switch (distFormat) { case "bz": case "bz2": case "bzip": case "bzip2": DistributeFormat = DistributeFormat.BZip2; break; case "gz": case "gzip": DistributeFormat = DistributeFormat.GZip; break; // "z" // "zip" default: if (!string.IsNullOrEmpty(distFormat) && !new[] { "z", "zip" }.Contains(distFormat)) { context.Log.Warning($"Invalid \"dist-format\" parameter. Assuming the default value \"{DistributeFormat.Zip}\""); } DistributeFormat = DistributeFormat.Zip; break; } var path = SearchBuildConfigFile(); ConfigFile = !string.IsNullOrWhiteSpace(path) ? LoadBuildConfigFromFile(path) : ConfigFile.Default; ConfigFile.Ensure(); BasePath = BasePath ?? Directory.GetCurrentDirectory(); }
public BuildContext(ICakeContext context) : base(context) { BuildConfiguration = context.Argument("Configuration", "Release"); SkipTests = context.Argument("SkipTests", false); SkipSlowTests = context.Argument("SkipSlowTests", false); RootDirectory = new DirectoryPath(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.FullName); ArtifactsDirectory = RootDirectory.Combine("artifacts"); ToolsDirectory = RootDirectory.Combine("tools"); DocsDirectory = RootDirectory.Combine("docs"); DocfxDirectory = ToolsDirectory.Combine("docfx"); DocfxExeFile = DocfxDirectory.CombineWithFilePath("docfx.exe"); DocfxJsonFile = DocsDirectory.CombineWithFilePath("docfx.json"); TestOutputDirectory = RootDirectory.Combine("TestResults"); ChangeLogDirectory = RootDirectory.Combine("docs").Combine("changelog"); ChangeLogGenDirectory = RootDirectory.Combine("docs").Combine("_changelog"); SolutionFile = RootDirectory.CombineWithFilePath("BenchmarkDotNet.sln"); UnitTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.Tests") .CombineWithFilePath("BenchmarkDotNet.Tests.csproj"); IntegrationTestsProjectFile = RootDirectory.Combine("tests").Combine("BenchmarkDotNet.IntegrationTests") .CombineWithFilePath("BenchmarkDotNet.IntegrationTests.csproj"); TemplatesTestsProjectFile = RootDirectory.Combine("templates") .CombineWithFilePath("BenchmarkDotNet.Templates.csproj"); AllPackableSrcProjects = new FilePathCollection(context.GetFiles(RootDirectory.FullPath + "/src/**/*.csproj") .Where(p => !p.FullPath.Contains("Disassembler"))); MsBuildSettings = new DotNetCoreMSBuildSettings { MaxCpuCount = 1 }; MsBuildSettings.WithProperty("UseSharedCompilation", "false"); // NativeAOT build requires VS C++ tools to be added to $path via vcvars64.bat // but once we do that, dotnet restore fails with: // "Please specify a valid solution configuration using the Configuration and Platform properties" if (context.IsRunningOnWindows()) { MsBuildSettings.WithProperty("Platform", "Any CPU"); } }
public BuildContext(ICakeContext context) : base(context) { BuildConfiguration = context.Argument <string>("configuration", "Debug"); DoClean = context.HasArgument("clean"); RepoDir = context.Directory(System.Environment.CurrentDirectory); BuildDir = RepoDir + context.Directory("build"); PublishDir = RepoDir + context.Directory("publish"); SolutionFile = RepoDir + context.File("Textrude.sln"); Solution = context.ParseSolution(SolutionFile); }
private static string?GetEnvironmentValueOrArgument(this ICakeContext context, string environmentVariable, string argumentName) { var arg = context.EnvironmentVariable(environmentVariable); if (string.IsNullOrWhiteSpace(arg)) { arg = context.Argument <string?>(argumentName, null); } return(arg); }
/// <summary> /// Gets argument value from Cake commandline. /// </summary> /// <param name="arg">Command Argument</param> /// <param name="context">Cake Context</param> /// <returns>Value as string if defined. Empty string if not defined.</returns> /// <example> /// <code> /// var newArg = CommandHelper.AddArgument("test", "t", "Testing stuff"); /// var argVal = newArg.GetArgumentValue(Context) /// </code> /// </example> public static string GetArgumentValue(this ICommandArgument arg, ICakeContext context) { if (arg == null) { throw new ArgumentNullException(nameof(arg)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } var longArgValue = context.Argument(arg.Name, string.Empty); if (!string.IsNullOrWhiteSpace(longArgValue)) { return(longArgValue); } var shortArgValue = context.Argument(arg.Shortname, string.Empty); return(shortArgValue); }
public static string Prompt(this ICakeContext context, string message) { if (context == null) { throw new ArgumentNullException("context"); } var interactive = context.HasArgument(InteractiveOption) ? context.Argument <bool>(InteractiveOption) : false; Console.Write("{0}", message); return(Console.ReadLine()); }
public BuildContext(ICakeContext context) : base(context) { this.MsBuildConfiguration = context.Argument("configuration", "Release"); // walk backwards until git directory found - that's root var dir = new DirectoryPath("."); while (!context.GitIsValidRepository(dir)) { dir = new DirectoryPath(Directory.GetParent(dir.FullPath).FullName); } context.Environment.WorkingDirectory = dir; this.Branch = context.GitBranchCurrent("."); }
public static void buildTasks(this ICakeContext context) { OctopusDeployUrl = "https://deploy.hhaexchange.com"; Target = context.Argument("target", "OctoRelease"); BuildNumber = context.ArgumentOrEnvironmentVariable("build.number", "", "0.0.1-local.0"); OctopusDeployApiKey = context.ArgumentOrEnvironmentVariable("OctopusDeployApiKey", ""); MsBuildLogger = context.ArgumentOrEnvironmentVariable("MsBuildLogger", "", ""); ProjectName = context.ArgumentOrEnvironmentVariable("ProjectName", "", "ENT"); ProcessesProjectName = context.ArgumentOrEnvironmentVariable("ProcessesProjectName", "", "ENT Processes"); APIProjectName = context.ArgumentOrEnvironmentVariable("APIProjectName", "", "ENT.Internal.API"); DeploymentBranches = context.ArgumentOrEnvironmentVariable("DeploymentBranches", "", " "); TeamCityBuildAgentDirectory = context.ArgumentOrEnvironmentVariable("teamcity.agent.home.dir", "", "c:\\BuildAgent"); NodeBackupPath = TeamCityBuildAgentDirectory + "\\node_backup\\ENTP\\node_modules"; BranchName = null; tenant = null; TaskBuild(context); }
public static string ArgOrEnv(this ICakeContext context, string prefix, string propertyName, string defaultValue = null) { var envName = _variableNameFormatter.FormatEnvironmentVariable(prefix, propertyName); var argName = _variableNameFormatter.FormatArgument(prefix, propertyName); if (context.HasEnvironmentVariable(envName)) { return(context.EnvironmentVariable(envName)); } if (context.HasArgument(argName)) { return(context.Argument <string>(argName)); } if (defaultValue == null) { throw new CakeException($"Could not find environment variable {envName} or argument {argName}"); } return(defaultValue); }
public static DirectoryPath Coverage(this ICakeContext context) { return(DirectoryPath.FromString(context.Argument("coverage", "./coverage")).MakeAbsolute(context.Environment)); }
public void Execute(IConfiguration configuration, StepType currentStep) { ICakeContext cake = configuration.Context.CakeContext; CleanLevel cleanLevel = CleanLevel.All; if (cake.HasArgument("no-clean")) { string noCleanArgument = cake.Argument <string>("no-clean"); string[] splitted = noCleanArgument.ToLowerInvariant().Split('#'); foreach (string s in splitted) { switch (s) { case "binobj": cleanLevel &= ~CleanLevel.BinObj; break; case "build": cleanLevel &= ~CleanLevel.Build; break; case "artifacts": cleanLevel &= ~CleanLevel.Artifacts; break; case "all": cleanLevel &= ~CleanLevel.All; break; default: configuration.Context.CakeContext.LogAndThrow($"no-clean option {s} is not supported, only binobj, build, artifacts and all are valid arguments"); break; } } } if (cleanLevel.HasFlag(CleanLevel.Artifacts)) { DirectoryPath directoryPath = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.ARTIFACTS_PATH_KEY); cake.Log.Information($"Clean artifacts {directoryPath.FullPath}"); if (cake.DirectoryExists(directoryPath)) { IDirectory directory = cake.FileSystem.GetDirectory(directoryPath); directory.Delete(true); } } if (cleanLevel.HasFlag(CleanLevel.Build)) { DirectoryPath directoryPath = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.BUILD_PATH_KEY); cake.Log.Information($"Clean build {directoryPath.FullPath}"); if (cake.DirectoryExists(directoryPath)) { IDirectory directory = cake.FileSystem.GetDirectory(directoryPath); directory.Delete(true); } } if (cleanLevel.HasFlag(CleanLevel.BinObj)) { DirectoryPath rootPath = configuration.GetSimple <DirectoryPath>(ConfigurationConstants.ROOT_PATH_KEY); cake.Log.Information($"Clean bin and obj in {rootPath.FullPath}"); cake.DeleteDirectories(cake.GetDirectories(Path.Combine(rootPath.FullPath, "**/bin")), new DeleteDirectorySettings { Force = true, Recursive = true }); cake.DeleteDirectories(cake.GetDirectories(Path.Combine(rootPath.FullPath, "**/obj")), new DeleteDirectorySettings { Force = true, Recursive = true }); } }
public BuildContext(ICakeContext context) : base(context) { MsBuildConfiguration = context.Argument("configuration", "Release"); }
public MyContext(ICakeContext context) : base(context) { //Force Release so Aero.Build can reference Aero.Cake and not a NuGet. context.Argument("configuration", "Release"); BuildConfiguration = context.Argument(ArgumentNames.BuildConfiguration, "Release"); }
public BuildContext(ICakeContext context) : base(context) { this.BuildConfiguration = context.Argument("configuration", "Release"); this.BuildPlatform = context.Argument("platform", "Any CPU"); }
public static void Configure(ICakeContext context) { Context = context; SkipTests = Context.Argument("skiptests", false); }
public static void BuildConfigure(this ICakeContext context) { // Build args Build.Target = CoerceTarget(context.Argument("target", Build.Target)); Build.Configuration = context.Argument("configuration", Build.Configuration); Build.Verbosity = context.Argument("verbosity", Build.Verbosity); Build.Local = context.Argument("local", Build.Local); // Check args Build.CheckStagedChanges = context.Argument("check-staged", Build.CheckStagedChanges); Build.CheckUncommittedChanges = context.Argument("check-uncommitted", Build.CheckUncommittedChanges); Build.CheckUntrackedFiles = context.Argument("check-untracked", Build.CheckUntrackedFiles); // Git args Build.GitRoot = context.GitFindRootFromPath(context.MakeAbsolute(context.Directory("."))); Build.GitUserName = context.Argument("git-username", Build.GitUserName); Build.GitEmail = context.Argument("git-email", Build.GitEmail); Build.GitRemoteName = context.Argument("git-remote", Build.GitRemoteName); Build.EnableCommits = context.Argument("enable-commits", Build.EnableCommits); Build.EnableTags = context.Argument("enable-tags", Build.EnableTags); Build.EnablePush = context.Argument("enable-push", Build.EnablePush); // NuGet args Build.NuGetSource = context.Argument( "nuget-source", context.EnvironmentVariable("NUGET_SOURCE") ?? Build.NuGetSource); Build.NuGetLocalSource = context.Argument( "nuget-local-source", context.EnvironmentVariable("NUGET_LOCAL_SOURCE") ?? Build.NuGetLocalSource); Build.NuGetApiKey = context.Argument("nuget-api-key", context.EnvironmentVariable("NUGET_API_KEY")); // Artefact args Build.ArtefactsRepository = context.Argument( "artefacts-repo", context.EnvironmentVariable("ARTEFACTS_REPO") ?? Build.ArtefactsRepository); Build.ArtefactsLocalRepository = context.Argument( "artefacts-local-repo", context.EnvironmentVariable("ARTEFACTS_LOCAL_REPO") ?? Build.ArtefactsLocalRepository); // Squirrel args Build.SquirrelCentralRepository = context.Argument( "squirrel-repo", context.EnvironmentVariable("SQUIRREL_REPO") ?? Build.SquirrelCentralRepository); Build.SquirrelLocalRepository = context.Argument( "squirrel-local-repo", context.EnvironmentVariable("SQUIRREL_LOCAL_REPO") ?? Build.SquirrelLocalRepository); }
public static string Configuration(this ICakeContext context) { return(context.Argument("configuration", "Debug")); }
public static string Target(this ICakeContext context) { return(context.Argument("target", "Build")); }
public static bool IsDryRun(this ICakeContext context) { return((context.Argument <bool?>("dryrun", false) ?? true) || (context.Argument <bool?>("noop", false) ?? true) || (context.Argument <bool?>("whatif", false) ?? true)); }
public static DirectoryPath Artifacts(this ICakeContext context) { return(DirectoryPath.FromString(context.Argument("artifacts", "./artifacts")).MakeAbsolute(context.Environment)); }