diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs similarity index 99% rename from nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs rename to nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs index 20bc39ebf5..758a532647 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs @@ -10,7 +10,7 @@ namespace NuGetUpdater.Core.Test.Update; public partial class UpdateWorkerTests { - public class Sdk : UpdateWorkerTestBase + public class PackageReference : UpdateWorkerTestBase { [Theory] [InlineData("net472")] diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs index bfc669b9e5..be0cf0ed8f 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs @@ -18,6 +18,16 @@ internal static class BindingRedirectManager private static readonly XName DependentAssemblyName = AssemblyBinding.GetQualifiedName("dependentAssembly"); private static readonly XName BindingRedirectName = AssemblyBinding.GetQualifiedName("bindingRedirect"); + /// + /// Updates assembly binding redirects for a project build file. + /// + /// + /// Assembly binding redirects are only applicable to projects targeting .NET Framework. + /// .NET Framework targets can appear in SDK-style OR non-SDK-style project files, using either packages.config OR `` MSBuild items. + /// See: https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/redirect-assembly-versions + /// https://learn.microsoft.com/en-us/nuget/resources/check-project-format + /// + /// The project build file (*.xproj) to be updated public static async ValueTask UpdateBindingRedirectsAsync(ProjectBuildFile projectBuildFile) { var configFile = await TryGetRuntimeConfigurationFile(projectBuildFile); @@ -33,7 +43,7 @@ public static async ValueTask UpdateBindingRedirectsAsync(ProjectBuildFile proje var bindings = BindingRedirectResolver.GetBindingRedirects(projectBuildFile.Path, references.Select(static x => x.Include)); if (!bindings.Any()) { - // no bindings to update + // no bindings found in the project file, nothing to update return; } diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs similarity index 97% rename from nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs rename to nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs index b3da76eaaa..f73371c7d6 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs @@ -6,7 +6,18 @@ namespace NuGetUpdater.Core; -internal static class SdkPackageUpdater +/// +/// Handles package updates for projects containing `` MSBuild items. +/// +/// +/// PackageReference items can appear in both SDK-style AND non-SDK-style project files. +/// By default, PackageReference is used by [SDK-style] projects targeting .NET Core, .NET Standard, and UWP. +/// By default, packages.config is used by [non-SDK-style] projects targeting .NET Framework; However, they can be migrated to PackageReference too. +/// See: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#project-type-support +/// https://learn.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference +/// https://learn.microsoft.com/en-us/nuget/resources/check-project-format +/// +internal static class PackageReferenceUpdater { public static async Task UpdateDependencyAsync( string repoRootPath, @@ -17,8 +28,8 @@ public static async Task UpdateDependencyAsync( bool isTransitive, ILogger logger) { - // SDK-style project, modify the XML directly - logger.Log(" Running for SDK-style project"); + // PackageReference project; modify the XML directly + logger.Log(" Running 'PackageReference' project direct XML update"); (ImmutableArray buildFiles, string[] tfms) = await MSBuildHelper.LoadBuildFilesAndTargetFrameworksAsync(repoRootPath, projectPath); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs index ae96cf3671..f4d32f8aeb 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs @@ -13,6 +13,14 @@ namespace NuGetUpdater.Core; +/// +/// Handles package updates for projects that use packages.config. +/// +/// +/// packages.config can appear in non-SDK-style projects, but not in SDK-style projects. +/// See: https://learn.microsoft.com/en-us/nuget/reference/packages-config +/// https://learn.microsoft.com/en-us/nuget/resources/check-project-format +/// internal static class PackagesConfigUpdater { public static async Task UpdateDependencyAsync( @@ -25,9 +33,8 @@ public static async Task UpdateDependencyAsync( ILogger logger ) { - logger.Log($" Found {NuGetHelper.PackagesConfigFileName}; running with NuGet.exe"); - - // use NuGet.exe to perform update + // packages.config project; use NuGet.exe to perform update + logger.Log($" Found '{NuGetHelper.PackagesConfigFileName}' project; running NuGet.exe update"); // ensure local packages directory exists var projectBuildFile = ProjectBuildFile.Open(repoRootPath, projectPath); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs index bf1092faf9..5eadf4f475 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs @@ -221,7 +221,7 @@ private async Task RunUpdaterAsync( } // Some repos use a mix of packages.config and PackageReference - await SdkPackageUpdater.UpdateDependencyAsync(repoRootPath, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, _logger); + await PackageReferenceUpdater.UpdateDependencyAsync(repoRootPath, projectPath, dependencyName, previousDependencyVersion, newDependencyVersion, isTransitive, _logger); // Update lock file if exists if (File.Exists(Path.Combine(Path.GetDirectoryName(projectPath), "packages.lock.json")))