-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHubSync update - release-2.0 (#418)
* GitHubSync update - release-2.0 * Consolidate Amazon.Lambda.Core to 2.2.0 * Consolidate Amazon.Lambda.SQSEvents to 2.2.0 * Consolidate NServiceBus.AmazonSQS to 7.0.0 * Add the direct reference to NServiceBus 9.1.2 * Bump GitHubActionsTestLogger to 2.4.1 * Bump Microsoft.NET.Test.Sdk to 17.12.0 * Bump NUnit3TestAdapter to 4.6.0 * Fix typo * Bump Particular.Approvals to 2.0.0 * Bump Particular.Packaging to 4.2.0 * Bump PublicApiGenerator to 11.3.0 * Update NServiceBus.AmazonSQS --------- Co-authored-by: internalautomation[bot] <85681268+internalautomation[bot]@users.noreply.github.com> Co-authored-by: Tamara Rivera <[email protected]> Co-authored-by: Brandon Ording <[email protected]>
- Loading branch information
1 parent
f080e06
commit 4c29df9
Showing
9 changed files
with
120 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<NuGetAuditMode Condition="'$(PackAsTool)' == 'true'">all</NuGetAuditMode> | ||
</PropertyGroup> | ||
<Import Project="msbuild\AutomaticVersionRanges.targets" Condition="Exists('msbuild\AutomaticVersionRanges.targets')" /> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(Configuration)' == 'Debug'">false</AutomaticVersionRangesEnabled> | ||
<AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(IsPackable)' == 'false'">false</AutomaticVersionRangesEnabled> | ||
<AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == '' And '$(ManagePackageVersionsCentrally)' == 'true'">false</AutomaticVersionRangesEnabled> | ||
<AutomaticVersionRangesEnabled Condition="'$(AutomaticVersionRangesEnabled)' == ''">true</AutomaticVersionRangesEnabled> | ||
</PropertyGroup> | ||
|
||
<UsingTask TaskName="ConvertToVersionRange" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> | ||
<Task> | ||
<Code Source="$(MSBuildThisFileDirectory)ConvertToVersionRange.cs" /> | ||
</Task> | ||
</UsingTask> | ||
|
||
<Target Name="ConvertProjectReferenceVersionsToVersionRanges" AfterTargets="_GetProjectReferenceVersions" Condition="'$(AutomaticVersionRangesEnabled)' == 'true'"> | ||
<PropertyGroup> | ||
<NumberOfProjectReferences>@(_ProjectReferencesWithVersions->Count())</NumberOfProjectReferences> | ||
</PropertyGroup> | ||
<ConvertToVersionRange Condition="$(NumberOfProjectReferences) > 0" References="@(_ProjectReferencesWithVersions)" VersionProperty="ProjectVersion"> | ||
<Output TaskParameter="ReferencesWithVersionRanges" ItemName="_ProjectReferencesWithVersionRanges" /> | ||
</ConvertToVersionRange> | ||
<ItemGroup Condition="$(NumberOfProjectReferences) > 0"> | ||
<_ProjectReferencesWithVersions Remove="@(_ProjectReferencesWithVersions)" /> | ||
<_ProjectReferencesWithVersions Include="@(_ProjectReferencesWithVersionRanges)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="ConvertPackageReferenceVersionsToVersionRanges" BeforeTargets="CollectPackageReferences" Condition="'$(AutomaticVersionRangesEnabled)' == 'true'"> | ||
<PropertyGroup> | ||
<NumberOfPackageReferences>@(PackageReference->Count())</NumberOfPackageReferences> | ||
</PropertyGroup> | ||
<ConvertToVersionRange Condition="$(NumberOfPackageReferences) > 0" References="@(PackageReference)" VersionProperty="Version"> | ||
<Output TaskParameter="ReferencesWithVersionRanges" ItemName="_PackageReferencesWithVersionRanges" /> | ||
</ConvertToVersionRange> | ||
<ItemGroup Condition="$(NumberOfPackageReferences) > 0"> | ||
<PackageReference Remove="@(PackageReference)" /> | ||
<PackageReference Include="@(_PackageReferencesWithVersionRanges)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |