diff --git a/Versionize/ConfigurationContract.cs b/Versionize/ConfigurationContract.cs index ae76b38..00c818c 100644 --- a/Versionize/ConfigurationContract.cs +++ b/Versionize/ConfigurationContract.cs @@ -13,4 +13,5 @@ public class ConfigurationContract public String CommitSuffix { get; set; } public ChangelogOptions Changelog { get; set; } public string Prerelease { get; set; } + public bool? AllowDifferentVersions { get; set; } } diff --git a/Versionize/Program.cs b/Versionize/Program.cs index 3724131..7b80456 100644 --- a/Versionize/Program.cs +++ b/Versionize/Program.cs @@ -1,5 +1,5 @@ -using System.Text.Json; -using McMaster.Extensions.CommandLineUtils; +using McMaster.Extensions.CommandLineUtils; +using System.Text.Json; using Versionize.CommandLine; using Versionize.Versioning; @@ -36,6 +36,7 @@ public static int Main(string[] args) var optionPrerelease = app.Option("-p|--pre-release", "Release as pre-release version with given pre release label.", CommandOptionType.SingleValue); var optionAggregatePrereleases = app.Option("-a|--aggregate-pre-releases", "Include all pre-release commits in the changelog since the last full version.", CommandOptionType.NoValue); var optionUseProjVersionForBumpLogic = app.Option("--proj-version-bump-logic", "Use project version for bump logic, as opposed to git tag version.", CommandOptionType.NoValue); + var optionAllowDifferentVersions = app.Option("--allow-different-versions", "Allow different version of projects in folder", CommandOptionType.NoValue); var inspectCmd = app.Command("inspect", inspectCmd => inspectCmd.OnExecute(() => { @@ -68,6 +69,7 @@ public static int Main(string[] args) Changelog = ChangelogOptions.Default, AggregatePrereleases = optionAggregatePrereleases.HasValue(), UseProjVersionForBumpLogic = optionUseProjVersionForBumpLogic.HasValue(), + AllowDifferentVersions = optionAllowDifferentVersions.HasValue() }, optionIncludeAllCommitsInChangelog.HasValue()); @@ -151,6 +153,7 @@ private static ConfigurationContract FromJsonFile(string filePath) AggregatePrereleases = configuration.AggregatePrereleases, // TODO: Consider supporting optionalConfiguration UseProjVersionForBumpLogic = configuration.UseProjVersionForBumpLogic, + AllowDifferentVersions = MergeBool(configuration.AllowDifferentVersions, optionalConfiguration?.AllowDifferentVersions), }; } diff --git a/Versionize/VersionizeOptions.cs b/Versionize/VersionizeOptions.cs index c91478c..3d88d5e 100644 --- a/Versionize/VersionizeOptions.cs +++ b/Versionize/VersionizeOptions.cs @@ -1,4 +1,4 @@ -namespace Versionize; +namespace Versionize; public class VersionizeOptions { @@ -14,4 +14,5 @@ public class VersionizeOptions public ChangelogOptions Changelog { get; set; } = ChangelogOptions.Default; public bool AggregatePrereleases { get; set; } public bool UseProjVersionForBumpLogic { get; set; } + public bool AllowDifferentVersions { get; set; } } diff --git a/Versionize/WorkingCopy.cs b/Versionize/WorkingCopy.cs index 356b1f8..e32a8d9 100644 --- a/Versionize/WorkingCopy.cs +++ b/Versionize/WorkingCopy.cs @@ -59,7 +59,7 @@ public SemanticVersion Versionize(VersionizeOptions options) Exit($"Could not find any projects files in {workingDirectory} that have a defined in their csproj file.", 1); } - if (projects.HasInconsistentVersioning()) + if (projects.HasInconsistentVersioning() && !options.AllowDifferentVersions) { Exit($"Some projects in {workingDirectory} have an inconsistent defined in their csproj file. Please update all versions to be consistent or remove the elements from projects that should not be versioned", 1); } @@ -150,7 +150,7 @@ public SemanticVersion Versionize(VersionizeOptions options) Step($"bumping version from {projects.Version} to {nextVersion} in projects"); - + // Commit changelog and version source if (!options.DryRun && (nextVersion != projects.Version)) {