From 00b14a737df21363d9b92f0fc3a26943912f2412 Mon Sep 17 00:00:00 2001 From: "internalautomation[bot]" <85681268+internalautomation[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:47:29 -0500 Subject: [PATCH] GitHubSync update - release-7.0 (#1609) * GitHubSync update - release-7.0 * Update packages to prevent transitive CVE * Update Fody * Update NServiceBus packages * Update testing packages * Update Particular.Packaging * Use LinkBase * Update tests for updated Particular.Approvals * Update MySQL connection string --------- Co-authored-by: internalautomation[bot] <85681268+internalautomation[bot]@users.noreply.github.com> Co-authored-by: Brandon Ording --- .github/workflows/ci.yml | 2 +- .../AcceptanceTestHelper.csproj | 4 -- .../NoPersistenceServer.cs | 6 +- ...viceBus.Persistence.Sql.CommandLine.csproj | 2 +- src/Directory.Build.props | 4 +- src/Directory.Build.targets | 4 +- ...lMicrosoftDataClientAcceptanceTests.csproj | 10 ++-- ...taClientSqlTransportAcceptanceTests.csproj | 17 +++--- ...sSqlSystemDataClientAcceptanceTests.csproj | 10 ++-- ...taClientSqlTransportAcceptanceTests.csproj | 17 +++--- .../MySqlAcceptanceTests.csproj | 10 ++-- ...ersistence.Sql.TransactionalSession.csproj | 4 +- .../OracleAcceptanceTests.csproj | 10 ++-- .../PostgreSqlAcceptanceTests.csproj | 10 ++-- .../CoreSagaMetadata/CoreSagaMetadataTests.cs | 18 +++--- .../ScriptBuilder.Tests.csproj | 13 ++--- .../AttributeReading/Settings.cs | 12 ++-- src/ScriptBuilder/ScriptBuilder.csproj | 2 +- .../ScriptBuilderTask.Tests.csproj | 8 +-- .../SqlPersistence.PersistenceTests.csproj | 10 ++-- .../SqlPersistence.Tests.csproj | 12 ++-- .../SubscriptionPersisterTests.cs | 5 +- src/SqlPersistence/Saga/SagaPersister.cs | 8 +-- src/SqlPersistence/SqlPersistence.csproj | 8 +-- src/TestHelper/TestHelper.csproj | 10 +++- ...MicrosoftDataClient.AcceptanceTests.csproj | 16 ++---- ...SqlSystemDataClient.AcceptanceTests.csproj | 20 +++---- .../TransactionalSession.Tests.csproj | 20 +++---- src/VBTestCode/VBTestCode.vbproj | 2 +- src/msbuild/AutomaticVersionRanges.targets | 42 ++++++++++++++ src/msbuild/ConvertToVersionRange.cs | 57 +++++++++++++++++++ 31 files changed, 227 insertions(+), 146 deletions(-) create mode 100644 src/msbuild/AutomaticVersionRanges.targets create mode 100644 src/msbuild/ConvertToVersionRange.cs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 549e76c89..7ebb657e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,7 +103,7 @@ jobs: echo "Giving user particular access to schema nservicebus" mysql --defaults-extra-file=mysql-login -D mysql -e "grant all on *.* to particular@'%' ;" - $connectionString = "Data Source=localhost;Initial Catalog=nservicebus;User ID=particular;Password=Welcome1;AllowUserVariables=True;AutoEnlist=false;Connect Timeout=60" + $connectionString = "Data Source=localhost;Initial Catalog=nservicebus;User ID=particular;Password=Welcome1;AllowUserVariables=True;AutoEnlist=false;ConnectionReset=true;Connect Timeout=60" echo "MySQLConnectionString=$connectionString" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append - name: Setup Oracle id: setup-oracle diff --git a/src/AcceptanceTestHelper/AcceptanceTestHelper.csproj b/src/AcceptanceTestHelper/AcceptanceTestHelper.csproj index e96794a32..b17f23197 100644 --- a/src/AcceptanceTestHelper/AcceptanceTestHelper.csproj +++ b/src/AcceptanceTestHelper/AcceptanceTestHelper.csproj @@ -12,8 +12,4 @@ - - - - \ No newline at end of file diff --git a/src/AcceptanceTestsShared/NoPersistenceServer.cs b/src/AcceptanceTestsShared/NoPersistenceServer.cs index 1c0d5ddba..58e635e3a 100644 --- a/src/AcceptanceTestsShared/NoPersistenceServer.cs +++ b/src/AcceptanceTestsShared/NoPersistenceServer.cs @@ -25,10 +25,6 @@ public async Task GetConfiguration(RunDescriptor runDescr Func configurationBuilderCustomization) #pragma warning restore PS0013 { - var types = endpointConfiguration.GetTypesScopedByTestClass(); - - typesToInclude.AddRange(types); - var configuration = new EndpointConfiguration(endpointConfiguration.EndpointName); configuration.TypesToIncludeInScan(typesToInclude); @@ -44,6 +40,8 @@ public async Task GetConfiguration(RunDescriptor runDescr configuration.GetSettings().SetDefault("ScaleOut.UseSingleBrokerQueue", true); await configurationBuilderCustomization(configuration).ConfigureAwait(false); + configuration.ScanTypesForTest(endpointConfiguration); + return configuration; } diff --git a/src/CommandLine/NServiceBus.Persistence.Sql.CommandLine.csproj b/src/CommandLine/NServiceBus.Persistence.Sql.CommandLine.csproj index 9202a75e8..d118d7080 100644 --- a/src/CommandLine/NServiceBus.Persistence.Sql.CommandLine.csproj +++ b/src/CommandLine/NServiceBus.Persistence.Sql.CommandLine.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7e3a698c3..4b7369cc5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -7,10 +7,10 @@ true 5.0 true - low + all - 2.1.2 + 2.1.3 0024000004800000940000000602000000240000525341310004000001000100dde965e6172e019ac82c2639ffe494dd2e7dd16347c34762a05732b492e110f2e4e2e1b5ef2d85c848ccfb671ee20a47c8d1376276708dc30a90ff1121b647ba3b7259a6bc383b2034938ef0e275b58b920375ac605076178123693c6c4f1331661a62eba28c249386855637780e3ff5f23a6d854700eaa6803ef48907513b92 00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5 diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index d47a6af61..98966408a 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,7 +1,5 @@ - - all - + diff --git a/src/MsSqlMicrosoftDataClientAcceptanceTests/MsSqlMicrosoftDataClientAcceptanceTests.csproj b/src/MsSqlMicrosoftDataClientAcceptanceTests/MsSqlMicrosoftDataClientAcceptanceTests.csproj index 6684b7690..1ffaf1a0a 100644 --- a/src/MsSqlMicrosoftDataClientAcceptanceTests/MsSqlMicrosoftDataClientAcceptanceTests.csproj +++ b/src/MsSqlMicrosoftDataClientAcceptanceTests/MsSqlMicrosoftDataClientAcceptanceTests.csproj @@ -12,15 +12,15 @@ - - - + + + - + - + \ No newline at end of file diff --git a/src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests.csproj b/src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests.csproj index 804872b4c..6423722f7 100644 --- a/src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests.csproj +++ b/src/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests/MsSqlMicrosoftDataClientSqlTransportAcceptanceTests.csproj @@ -11,20 +11,19 @@ - - - - + + + + - + - - - - + + + \ No newline at end of file diff --git a/src/MsSqlSystemDataClientAcceptanceTests/MsSqlSystemDataClientAcceptanceTests.csproj b/src/MsSqlSystemDataClientAcceptanceTests/MsSqlSystemDataClientAcceptanceTests.csproj index 6684b7690..1ffaf1a0a 100644 --- a/src/MsSqlSystemDataClientAcceptanceTests/MsSqlSystemDataClientAcceptanceTests.csproj +++ b/src/MsSqlSystemDataClientAcceptanceTests/MsSqlSystemDataClientAcceptanceTests.csproj @@ -12,15 +12,15 @@ - - - + + + - + - + \ No newline at end of file diff --git a/src/MsSqlSystemDataClientSqlTransportAcceptanceTests/MsSqlSystemDataClientSqlTransportAcceptanceTests.csproj b/src/MsSqlSystemDataClientSqlTransportAcceptanceTests/MsSqlSystemDataClientSqlTransportAcceptanceTests.csproj index c714d4920..a1a348f1a 100644 --- a/src/MsSqlSystemDataClientSqlTransportAcceptanceTests/MsSqlSystemDataClientSqlTransportAcceptanceTests.csproj +++ b/src/MsSqlSystemDataClientSqlTransportAcceptanceTests/MsSqlSystemDataClientSqlTransportAcceptanceTests.csproj @@ -11,20 +11,19 @@ - - - - + + + + - + - - - - + + + \ No newline at end of file diff --git a/src/MySqlAcceptanceTests/MySqlAcceptanceTests.csproj b/src/MySqlAcceptanceTests/MySqlAcceptanceTests.csproj index a0fc98cbc..7bfc19a72 100644 --- a/src/MySqlAcceptanceTests/MySqlAcceptanceTests.csproj +++ b/src/MySqlAcceptanceTests/MySqlAcceptanceTests.csproj @@ -11,15 +11,15 @@ - - - + + + - + - + diff --git a/src/NServiceBus.Persistence.Sql.TransactionalSession/NServiceBus.Persistence.Sql.TransactionalSession.csproj b/src/NServiceBus.Persistence.Sql.TransactionalSession/NServiceBus.Persistence.Sql.TransactionalSession.csproj index 72dbb6d58..4b8c3a6dd 100644 --- a/src/NServiceBus.Persistence.Sql.TransactionalSession/NServiceBus.Persistence.Sql.TransactionalSession.csproj +++ b/src/NServiceBus.Persistence.Sql.TransactionalSession/NServiceBus.Persistence.Sql.TransactionalSession.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/OracleAcceptanceTests/OracleAcceptanceTests.csproj b/src/OracleAcceptanceTests/OracleAcceptanceTests.csproj index 5e61c0652..2d8eab222 100644 --- a/src/OracleAcceptanceTests/OracleAcceptanceTests.csproj +++ b/src/OracleAcceptanceTests/OracleAcceptanceTests.csproj @@ -11,15 +11,15 @@ - - - + + + - + - + diff --git a/src/PostgreSqlAcceptanceTests/PostgreSqlAcceptanceTests.csproj b/src/PostgreSqlAcceptanceTests/PostgreSqlAcceptanceTests.csproj index f2f53a1f4..0678b81ff 100644 --- a/src/PostgreSqlAcceptanceTests/PostgreSqlAcceptanceTests.csproj +++ b/src/PostgreSqlAcceptanceTests/PostgreSqlAcceptanceTests.csproj @@ -11,15 +11,15 @@ - - - + + + - + - + \ No newline at end of file diff --git a/src/ScriptBuilder.Tests/Saga/CoreSagaMetadata/CoreSagaMetadataTests.cs b/src/ScriptBuilder.Tests/Saga/CoreSagaMetadata/CoreSagaMetadataTests.cs index 82226fe80..fa5176470 100644 --- a/src/ScriptBuilder.Tests/Saga/CoreSagaMetadata/CoreSagaMetadataTests.cs +++ b/src/ScriptBuilder.Tests/Saga/CoreSagaMetadata/CoreSagaMetadataTests.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Runtime.CompilerServices; using Mono.Cecil; using NServiceBus.Persistence.Sql.ScriptBuilder; using NUnit.Framework; @@ -144,7 +145,7 @@ public void TestReverseHeaderMapping() TestSagaDefinition(); } - void TestSagaDefinition(ModuleDefinition moduleToUse = null) + void TestSagaDefinition(ModuleDefinition moduleToUse = null, [CallerMemberName] string callerMemberName = null) { #pragma warning disable IDE0079 // Remove unnecessary suppression #pragma warning disable IDE0054 //False positive @@ -164,23 +165,24 @@ void TestSagaDefinition(ModuleDefinition moduleToUse = null) try { - SagaDefinitionReader.TryGetSagaDefinition(dataType, out results.SagaDefinition); + SagaDefinitionReader.TryGetSagaDefinition(dataType, out var definition); + results.SagaDefinition = definition; } catch (Exception x) { results.Exception = x.Message; } - Approver.Verify(results); + Approver.Verify(results, callerMemberName: callerMemberName); } class SagaInspectionResults { - public bool HasUnmanagedCalls; - public bool HasUnexpectedCalls; - public bool HasBranchingLogic; - public SagaDefinition SagaDefinition; - public string Exception; + public bool HasUnmanagedCalls { get; set; } + public bool HasUnexpectedCalls { get; set; } + public bool HasBranchingLogic { get; set; } + public SagaDefinition SagaDefinition { get; set; } + public string Exception { get; set; } } diff --git a/src/ScriptBuilder.Tests/ScriptBuilder.Tests.csproj b/src/ScriptBuilder.Tests/ScriptBuilder.Tests.csproj index 8cf499295..bd84d48e8 100644 --- a/src/ScriptBuilder.Tests/ScriptBuilder.Tests.csproj +++ b/src/ScriptBuilder.Tests/ScriptBuilder.Tests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -13,14 +13,13 @@ - - - + + + - - + + - \ No newline at end of file diff --git a/src/ScriptBuilder/AttributeReading/Settings.cs b/src/ScriptBuilder/AttributeReading/Settings.cs index 59e1a6a5c..4d6b4843c 100644 --- a/src/ScriptBuilder/AttributeReading/Settings.cs +++ b/src/ScriptBuilder/AttributeReading/Settings.cs @@ -3,10 +3,10 @@ class Settings { - public List BuildDialects; - public string ScriptPromotionPath; - public bool ProduceOutboxScripts; - public bool ProduceSubscriptionScripts; - public bool ProduceTimeoutScripts; - public bool ProduceSagaScripts; + public List BuildDialects { get; set; } + public string ScriptPromotionPath { get; set; } + public bool ProduceOutboxScripts { get; set; } + public bool ProduceSubscriptionScripts { get; set; } + public bool ProduceTimeoutScripts { get; set; } + public bool ProduceSagaScripts { get; set; } } \ No newline at end of file diff --git a/src/ScriptBuilder/ScriptBuilder.csproj b/src/ScriptBuilder/ScriptBuilder.csproj index 1c8c7cafc..2e810e1c4 100644 --- a/src/ScriptBuilder/ScriptBuilder.csproj +++ b/src/ScriptBuilder/ScriptBuilder.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj b/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj index 1654de249..7f85acbb1 100644 --- a/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj +++ b/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj @@ -12,11 +12,11 @@ - - + + - - + + \ No newline at end of file diff --git a/src/SqlPersistence.PersistenceTests/SqlPersistence.PersistenceTests.csproj b/src/SqlPersistence.PersistenceTests/SqlPersistence.PersistenceTests.csproj index 633cdf475..1cd312c26 100644 --- a/src/SqlPersistence.PersistenceTests/SqlPersistence.PersistenceTests.csproj +++ b/src/SqlPersistence.PersistenceTests/SqlPersistence.PersistenceTests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -14,11 +14,11 @@ - - - + + + - + diff --git a/src/SqlPersistence.Tests/SqlPersistence.Tests.csproj b/src/SqlPersistence.Tests/SqlPersistence.Tests.csproj index 772fb8313..0e4c85ecf 100644 --- a/src/SqlPersistence.Tests/SqlPersistence.Tests.csproj +++ b/src/SqlPersistence.Tests/SqlPersistence.Tests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -14,13 +14,11 @@ - - - - + + - - + + diff --git a/src/SqlPersistence.Tests/Subscription/SubscriptionPersisterTests.cs b/src/SqlPersistence.Tests/Subscription/SubscriptionPersisterTests.cs index 5460d6c6f..eda2a809d 100644 --- a/src/SqlPersistence.Tests/Subscription/SubscriptionPersisterTests.cs +++ b/src/SqlPersistence.Tests/Subscription/SubscriptionPersisterTests.cs @@ -3,6 +3,7 @@ using System.Data.Common; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Threading.Tasks; using NServiceBus.Persistence.Sql.ScriptBuilder; using NServiceBus.Unicast.Subscriptions; @@ -137,7 +138,7 @@ public void Should_be_cached() VerifyCache(persister.Cache); } - static void VerifyCache(ConcurrentDictionary cache) + static void VerifyCache(ConcurrentDictionary cache, [CallerMemberName] string callerMemberName = null) { var items = cache .OrderBy(_ => _.Key) @@ -148,7 +149,7 @@ static void VerifyCache(ConcurrentDictionary _.Endpoint) .ThenBy(_ => _.TransportAddress); }); - Approver.Verify(items); + Approver.Verify(items, callerMemberName: callerMemberName); } [Test] diff --git a/src/SqlPersistence/Saga/SagaPersister.cs b/src/SqlPersistence/Saga/SagaPersister.cs index 48350032a..223fd7157 100644 --- a/src/SqlPersistence/Saga/SagaPersister.cs +++ b/src/SqlPersistence/Saga/SagaPersister.cs @@ -38,11 +38,11 @@ static int GetConcurrency(ContextBag context) return concurrency; } - internal struct Concurrency - where TSagaData : IContainSagaData + internal struct Concurrency where TSagaData : IContainSagaData { - public readonly TSagaData Data; - public readonly int Version; + public readonly TSagaData Data { get; } + + public readonly int Version { get; } public Concurrency(TSagaData data, int version) { diff --git a/src/SqlPersistence/SqlPersistence.csproj b/src/SqlPersistence/SqlPersistence.csproj index 12b7af26f..4716d00aa 100644 --- a/src/SqlPersistence/SqlPersistence.csproj +++ b/src/SqlPersistence/SqlPersistence.csproj @@ -10,11 +10,11 @@ - - - + + + - + diff --git a/src/TestHelper/TestHelper.csproj b/src/TestHelper/TestHelper.csproj index 2f02ee3ed..fbcf904d2 100644 --- a/src/TestHelper/TestHelper.csproj +++ b/src/TestHelper/TestHelper.csproj @@ -7,12 +7,16 @@ + + + - - - + + + + diff --git a/src/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests.csproj b/src/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests.csproj index fa7c54ada..5b4df6641 100644 --- a/src/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests.csproj +++ b/src/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests/TransactionalSession.MsSqlMicrosoftDataClient.AcceptanceTests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -11,19 +11,15 @@ - - - - - - - - - + + + + + diff --git a/src/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests.csproj b/src/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests.csproj index bd4561e26..514e2c783 100644 --- a/src/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests.csproj +++ b/src/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests/TransactionalSession.MsSqlSystemDataClient.AcceptanceTests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -11,25 +11,19 @@ - - - - - - - - - + + + + + - - Infrastructure\*.cs - + diff --git a/src/TransactionalSession.Tests/TransactionalSession.Tests.csproj b/src/TransactionalSession.Tests/TransactionalSession.Tests.csproj index b4980ea42..e31688632 100644 --- a/src/TransactionalSession.Tests/TransactionalSession.Tests.csproj +++ b/src/TransactionalSession.Tests/TransactionalSession.Tests.csproj @@ -1,4 +1,4 @@ - + net481;net8.0 @@ -6,20 +6,18 @@ $(SolutionDir)NServiceBusTests.snk - - - - - - - - + + - - + + + + + + diff --git a/src/VBTestCode/VBTestCode.vbproj b/src/VBTestCode/VBTestCode.vbproj index 15e60fc61..58e689238 100644 --- a/src/VBTestCode/VBTestCode.vbproj +++ b/src/VBTestCode/VBTestCode.vbproj @@ -7,7 +7,7 @@ - + diff --git a/src/msbuild/AutomaticVersionRanges.targets b/src/msbuild/AutomaticVersionRanges.targets new file mode 100644 index 000000000..973721032 --- /dev/null +++ b/src/msbuild/AutomaticVersionRanges.targets @@ -0,0 +1,42 @@ + + + + false + false + false + true + + + + + + + + + + + @(_ProjectReferencesWithVersions->Count()) + + + + + + <_ProjectReferencesWithVersions Remove="@(_ProjectReferencesWithVersions)" /> + <_ProjectReferencesWithVersions Include="@(_ProjectReferencesWithVersionRanges)" /> + + + + + + @(PackageReference->Count()) + + + + + + + + + + + diff --git a/src/msbuild/ConvertToVersionRange.cs b/src/msbuild/ConvertToVersionRange.cs new file mode 100644 index 000000000..d91847845 --- /dev/null +++ b/src/msbuild/ConvertToVersionRange.cs @@ -0,0 +1,57 @@ +using System; +using System.Text.RegularExpressions; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +public class ConvertToVersionRange : Task +{ + [Required] + public ITaskItem[] References { get; set; } = []; + + [Required] + public string VersionProperty { get; set; } = string.Empty; + + [Output] + public ITaskItem[] ReferencesWithVersionRanges { get; private set; } = []; + + public override bool Execute() + { + var success = true; + + foreach (var reference in References) + { + var automaticVersionRange = reference.GetMetadata("AutomaticVersionRange"); + + if (automaticVersionRange.Equals("false", StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + var privateAssets = reference.GetMetadata("PrivateAssets"); + + if (privateAssets.Equals("All", StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + var version = reference.GetMetadata(VersionProperty); + var match = Regex.Match(version, @"^\d+"); + + if (match.Value.Equals(string.Empty, StringComparison.Ordinal)) + { + Log.LogError("Reference '{0}' with version '{1}' is not valid for automatic version range conversion. Fix the version or exclude the reference from conversion by setting 'AutomaticVersionRange=\"false\"' on the reference.", reference.ItemSpec, version); + success = false; + continue; + } + + var nextMajor = Convert.ToInt32(match.Value) + 1; + + var versionRange = $"[{version}, {nextMajor}.0.0)"; + reference.SetMetadata(VersionProperty, versionRange); + } + + ReferencesWithVersionRanges = References; + + return success; + } +}