From d7a7e38935c990100ba3f9f3502e6ef9a78571de Mon Sep 17 00:00:00 2001 From: "internalautomation[bot]" <85681268+internalautomation[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:57:00 -0500 Subject: [PATCH] GitHubSync update - release-4.4 (#861) * GitHubSync update - release-4.4 * Update packages to prevent transitive CVE * Update testing packages * Update Microsoft.NET.Sdk.Functions * Update Particular.Approvals * Update Particular.Packaging * Clean up project files * Clean up workflow files * Fix permissions on Linux tool --------- Co-authored-by: internalautomation[bot] <85681268+internalautomation[bot]@users.noreply.github.com> Co-authored-by: Brandon Ording --- .github/workflows/ci.yml | 10 ++-- .github/workflows/release.yml | 2 +- src/Directory.Build.props | 4 +- src/Directory.Build.targets | 4 +- .../IntegrationTests.HostV4.csproj | 14 ++--- ...ceBus.AzureFunctions.Analyzer.Tests.csproj | 12 ++-- ...NServiceBus.AzureFunctions.Analyzer.csproj | 6 +- ...AzureFunctions.InProcess.ServiceBus.csproj | 26 ++++----- ...zureFunctions.SourceGenerator.Tests.csproj | 8 +-- ...eBus.AzureFunctions.SourceGenerator.csproj | 2 +- .../ServiceBus.AcceptanceTests.csproj | 11 ++-- src/ServiceBus.Tests/ServiceBus.Tests.csproj | 11 ++-- src/Testing.Handlers/Testing.Handlers.csproj | 2 +- src/msbuild/AutomaticVersionRanges.targets | 42 ++++++++++++++ src/msbuild/ConvertToVersionRange.cs | 57 +++++++++++++++++++ 15 files changed, 152 insertions(+), 59 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 89cc4f46..f3827c1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,19 +35,21 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: | - 6.0.x - - name: Setup Azure Core tools - Windows + dotnet-version: 8.0.x + - name: Setup Azure Functions Core Tools - Windows if: runner.os == 'Windows' run: | choco install azure-functions-core-tools echo "PathToFuncExe=C:\ProgramData\chocolatey\lib\azure-functions-core-tools\tools\func.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append - - name: Setup Azure Core tools - Linux + - name: Setup Azure Functions Core Tools - Linux if: runner.os == 'Linux' run: | sudo apt-get install azure-functions-core-tools -y echo "PathToFuncExe=func" >> $GITHUB_ENV shell: bash + - name: Fix Azure Functions Core Tools permissions - Linux + if: runner.os == 'Linux' + run: sudo chmod +x /usr/lib/azure-functions-core-tools/in-proc6/func - name: Build run: dotnet build src --configuration Release - name: Upload packages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4908ea7d..65aa2fdf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4.0.0 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Build run: dotnet build src --configuration Release - name: Sign NuGet packages diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 7e3a698c..4b7369cc 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 d47a6af6..98966408 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,7 +1,5 @@ - - all - + diff --git a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj index 0d8f6ac7..71a9094a 100644 --- a/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj +++ b/src/IntegrationTests.HostV4/IntegrationTests.HostV4.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -13,16 +13,14 @@ - - - + + + + - - - - + diff --git a/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj b/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj index fd195d7a..ef3426e9 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj +++ b/src/NServiceBus.AzureFunctions.Analyzer.Tests/NServiceBus.AzureFunctions.Analyzer.Tests.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -7,17 +7,15 @@ - - - - + + - + - + diff --git a/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj b/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj index 2b130d71..761ec1c2 100644 --- a/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj +++ b/src/NServiceBus.AzureFunctions.Analyzer/NServiceBus.AzureFunctions.Analyzer.csproj @@ -1,4 +1,4 @@ - + $(AnalyzerTargetFramework) @@ -10,9 +10,9 @@ - + @@ -20,5 +20,5 @@ $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).0 - + diff --git a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj index 652a9b48..d412a593 100644 --- a/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj +++ b/src/NServiceBus.AzureFunctions.InProcess.ServiceBus/NServiceBus.AzureFunctions.InProcess.ServiceBus.csproj @@ -10,18 +10,23 @@ + + + + + + + + + + - + - - - - - - - + + @@ -29,11 +34,6 @@ - - - - - diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj b/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj index 6907e5ba..2f70cd2f 100644 --- a/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj +++ b/src/NServiceBus.AzureFunctions.SourceGenerator.Tests/NServiceBus.AzureFunctions.SourceGenerator.Tests.csproj @@ -12,15 +12,15 @@ - - + + - + - + \ No newline at end of file diff --git a/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj b/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj index 608b2664..48ef387b 100644 --- a/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj +++ b/src/NServiceBus.AzureFunctions.SourceGenerator/NServiceBus.AzureFunctions.SourceGenerator.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj index fe95e9f4..10d5b350 100644 --- a/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj +++ b/src/ServiceBus.AcceptanceTests/ServiceBus.AcceptanceTests.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -12,16 +12,15 @@ - - + + - + - + - diff --git a/src/ServiceBus.Tests/ServiceBus.Tests.csproj b/src/ServiceBus.Tests/ServiceBus.Tests.csproj index b8b7af05..c8645caa 100644 --- a/src/ServiceBus.Tests/ServiceBus.Tests.csproj +++ b/src/ServiceBus.Tests/ServiceBus.Tests.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -11,15 +11,14 @@ - - + + - + - - + diff --git a/src/Testing.Handlers/Testing.Handlers.csproj b/src/Testing.Handlers/Testing.Handlers.csproj index 81d66ade..8e209c3d 100644 --- a/src/Testing.Handlers/Testing.Handlers.csproj +++ b/src/Testing.Handlers/Testing.Handlers.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/msbuild/AutomaticVersionRanges.targets b/src/msbuild/AutomaticVersionRanges.targets new file mode 100644 index 00000000..97372103 --- /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 00000000..d9184784 --- /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; + } +}