-
Notifications
You must be signed in to change notification settings - Fork 6
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-6.1 (#703)
* GitHubSync update - release-6.1 * Consolidate Azure.Storage.Blobs to 12.21.2 * Consolidate NServiceBus.ClaimCheck to 1.0.1 * Bump Particular.Approvals to 2.0.0 * Bump Particular.Packaging to 4.2.0 * Bump Microsoft.NET.Test.Sdk to 17.12.0 * Clean up the declaration of the reference for GitHubActionsTestLogger * Remove unnecessary dependency. * Add NServiceBus reference * Update testing packages * Update Fody * Add NUnit.Analyzers * Disable automatic version range for package --------- Co-authored-by: internalautomation[bot] <85681268+internalautomation[bot]@users.noreply.github.com> Co-authored-by: Tamara Rivera <tamita.rivera@gmail.com> Co-authored-by: Brandon Ording <bording@gmail.com>
- Loading branch information
1 parent
583bd86
commit 424f909
Showing
16 changed files
with
136 additions
and
54 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
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
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 |
---|---|---|
@@ -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
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; | ||
} | ||
} |