// ReSharper disable once CyclomaticComplexity private static void ApplyRuntimeInformation( Tool tool, string specificationFile, [CanBeNull] Func <Tool, string> sourceFileProvider, [CanBeNull] Func <Tool, string> namespaceProvider) { foreach (var task in tool.Tasks) { task.Tool = tool; task.SettingsClass.Tool = tool; task.SettingsClass.Task = task; bool NotExistent(Property property) { var nonExistent = task.SettingsClass.Properties.All(x => x.Name != property.Name); ControlFlow.AssertWarn(nonExistent, $"Property '{property.Name}' for task '{task.GetTaskMethodName()}' already exists."); return(nonExistent); } foreach (var commonPropertySet in task.CommonPropertySets) { ControlFlow.Assert(tool.CommonTaskPropertySets.TryGetValue(commonPropertySet, out var properties), $"commonPropertySets[{commonPropertySet}] != null"); properties.Where(NotExistent).ForEach(x => task.SettingsClass.Properties.Add(x.Clone())); } if (!task.OmitCommonProperties) { tool.CommonTaskProperties.Where(NotExistent).ForEach(x => task.SettingsClass.Properties.Add(x.Clone())); } foreach (var property in task.SettingsClass.Properties) { property.DataClass = task.SettingsClass; foreach (var delegateProperty in property.Delegates) { delegateProperty.DataClass = task.SettingsClass; } } } foreach (var dataClass in tool.DataClasses) { dataClass.Tool = tool; foreach (var property in dataClass.Properties) { property.DataClass = dataClass; foreach (var delegateProperty in property.Delegates) { delegateProperty.DataClass = dataClass; } } } foreach (var enumeration in tool.Enumerations) { enumeration.Tool = tool; } }
public void ImportData( TeamCityImportType type, string path, TeamCityImportTool?tool = null, bool?verbose = null, bool?parseOutOfDate = null, TeamCityNoDataPublishedAction?action = null) { ControlFlow.Assert( type != TeamCityImportType.dotNetCoverage || tool != null, $"Importing data of type '{type}' requires to specify the tool."); ControlFlow.AssertWarn( !(tool == TeamCityImportTool.dotcover && ConfigurationProperties["teamcity.dotCover.home"].EndsWithOrdinalIgnoreCase("bundled")), new[] { "Configuration parameter 'teamcity.dotCover.home' is set to the bundled version.", $"Adding the '{nameof(TeamCitySetDotCoverHomePathAttribute)}' will automatically set " + $"it to '{nameof(DotCoverTasks)}.{nameof(DotCoverTasks.DotCoverPath)}'." }.JoinNewLine()); Write("importData", x => x .AddPair("type", type) .AddPair("path", path) .AddPairWhenValueNotNull("tool", tool) .AddPairWhenValueNotNull("verbose", verbose) .AddPairWhenValueNotNull("parseOutOfDate", parseOutOfDate) .AddPairWhenValueNotNull("whenNoDataPublished", action)); }
public void OnBuildInitialized( NukeBuild build, IReadOnlyCollection <ExecutableTarget> executableTargets, IReadOnlyCollection <ExecutableTarget> executionPlan) { ControlFlow.AssertWarn(Task.Run(CheckConfiguration).Wait(TimeoutInMilliseconds), $"Could not complete checking build configurations within {TimeoutInMilliseconds} milliseconds.");
public void OnAfterLogo( NukeBuild build, IReadOnlyCollection <ExecutableTarget> executableTargets, IReadOnlyCollection <ExecutableTarget> executionPlan) { ControlFlow.AssertWarn(Task.Run(CheckConfiguration).Wait(TimeoutInMilliseconds), $"Could not complete checking build configurations within {TimeoutInMilliseconds} milliseconds."); Task CheckConfiguration() { var rootDirectory = new DirectoryInfo(NukeBuild.RootDirectory); new[] { rootDirectory } .Concat(rootDirectory.EnumerateDirectories("*", SearchOption.AllDirectories).Where(x => !x.Name.StartsWith("."))) .SelectMany(x => x.GetFiles("*.sln", SearchOption.TopDirectoryOnly)) .Select(x => x.FullName) .Select(ProjectModelTasks.ParseSolution) .SelectMany(x => x.Projects) .Where(x => x.Directory.Equals(NukeBuild.BuildProjectDirectory)) .Where(x => x.Configurations.Any(y => y.Key.Contains("Build"))) .ForEach(x => Logger.Warn($"Solution {x.Solution} has an active build configuration for {x}.")); return(Task.CompletedTask); } }
public void Execute(NukeBuild build) { ControlFlow.AssertWarn(Task.Run(CheckConfiguration).Wait(TimeoutInMilliseconds), $"Could not complete checking build configurations within {TimeoutInMilliseconds} milliseconds."); Task CheckConfiguration() { Directory.GetFiles(NukeBuild.RootDirectory, "*.sln", SearchOption.AllDirectories) .Select(ProjectModelTasks.ParseSolution) .SelectMany(x => x.Projects) .Where(x => x.Directory.Equals(NukeBuild.BuildProjectDirectory)) .Where(x => x.Configurations.Any(y => y.Key.Contains("Build"))) .ForEach(x => Logger.Warn($"Solution {x.Solution} has an active build configuration for {x}.")); return(Task.CompletedTask); } }
static partial void PreProcess(GitLink2Settings toolSettings) { ControlFlow.AssertWarn(toolSettings.ToolPath.Contains("gitlink\\2"), "toolSettings.ToolPath.Contains('gitlink\\2')"); }
private static void PreProcess(ref GitLink3Settings toolSettings) { ControlFlow.AssertWarn(toolSettings.ToolPath.Contains("gitlink\\3"), "toolSettings.ToolPath.Contains('gitlink\\3')"); }
/// <summary> /// This is the Main Branch Commit stage /// </summary> public void CommitMainVersionChanges() { string gitArgs; List <Output> gitOutput; // This is not an update, it is a redo of a previous run that may have errored or its a clean run, but no changes have been committed. So we skip this. if (WasVersionPreviouslyCommitted) { return; } try { // Checkout main and merge the current branch in if (!IsCurrentBranchMainBranch()) { gitArgs = "checkout " + MainBranchName; if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitMainVersionChanges::: .Git Command failed: git " + gitArgs); } gitArgs = string.Format("merge {0} --no-ff --no-edit -m \"Merging Branch: {0} | {1}\"", CurrentBranch, GitVersion.MajorMinorPatch); if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitMainVersionChanges::: .Git Command failed: git " + gitArgs); } } gitArgs = "add ."; if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } gitArgs = string.Format("commit -m \"{0} {1}", COMMIT_MARKER, GitTagDesc); if (!ExecuteGit(gitArgs, out gitOutput)) { if (!gitOutput.Last().Text.Contains("nothing to commit")) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } } gitArgs = string.Format("tag -a {0} -m \"{1}\"", GitTagName, GitTagDesc); if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } gitArgs = "push origin "; if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } gitArgs = "push --tags origin"; if (!ExecuteGit_NoOutput(gitArgs)) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } // Delete the Feature Branch if (CurrentBranch != MainBranchName) { // See if branch exists on origin. If not we expect an error below. gitArgs = "ls-remote --exit-code --heads origin " + CurrentBranch; bool bErrorIsExpected = false; if (!ExecuteGit_NoOutput(gitArgs)) { bErrorIsExpected = true; } gitArgs = "branch -d " + CurrentBranch; if (!ExecuteGit_NoOutput(gitArgs) && !bErrorIsExpected) { ControlFlow.AssertWarn(1 == 0, "Unable to delete the local branch [" + CurrentBranch + "see Git Errors below. Will continue to process since this is not a fatal error. You may need to perform branch cleanup manually."); PrintGitHistory(); // We will probably fail the next error too... bErrorIsExpected = true; } gitArgs = "push origin --delete " + CurrentBranch; if (!ExecuteGit_NoOutput(gitArgs)) { if (!bErrorIsExpected) { throw new ApplicationException("CommitVersionChanges::: .Git Command failed: git " + gitArgs); } } Logger.Success("The previous 2 commits will issue errors if the local branch was never pushed to origin. They can be safely ignored."); } } catch (Exception e) { PrintGitHistory(); throw e; } }