From a36e395023b16c25b9d749d4c2e9bb83a314248a Mon Sep 17 00:00:00 2001 From: William Laugesen Date: Thu, 25 Sep 2025 16:26:58 +1200 Subject: [PATCH 1/7] Re-implement SetOverrideProxySettings (cherry picked from commit 84c6e31e6aeb49ad0890e8f7d1b646fae5857204) --- .../NuGet.Configuration/Proxy/IProxyCache.cs | 2 + .../NuGet.Configuration/Proxy/ProxyCache.cs | 62 ++++++++++++ .../PublicAPI.Unshipped.txt | 5 + .../HttpHandlerResourceV3Provider.cs | 36 +++++++ .../ProxyCacheTests.cs | 99 +++++++++++++++++++ 5 files changed, 204 insertions(+) diff --git a/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs b/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs index 9304c0cfd16..717a7b69b70 100644 --- a/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs +++ b/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs @@ -9,5 +9,7 @@ namespace NuGet.Configuration public interface IProxyCache { IWebProxy? GetProxy(Uri uri); + ICredentials? GetDefaultProxyCredentials(); + bool UseProxy(); } } diff --git a/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs b/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs index 70b2840c5aa..fc35f9e6133 100644 --- a/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs +++ b/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs @@ -3,11 +3,13 @@ using System; using System.Collections.Concurrent; +using System.Diagnostics.CodeAnalysis; using System.Net; using NuGet.Common; namespace NuGet.Configuration { + [SuppressMessage("Style", "IDE1006:Naming Styles")] public class ProxyCache : IProxyCache, IProxyCredentialCache { #if !IS_CORECLR @@ -20,6 +22,21 @@ public class ProxyCache : IProxyCache, IProxyCredentialCache /// private static readonly IWebProxy _originalSystemProxy = WebRequest.GetSystemWebProxy(); #endif + /// + /// Octopus overrides the proxy so we can ensure that the credentials are refreshed every time. + /// + /// + /// This was a fix implemented on an older version of NuGet 3.6.1 + /// https://github.com/OctopusDeploy/Issues/issues/2959 + /// This fix was rejected https://github.com/NuGet/NuGet.Client/pull/1153 + /// That lead us to fork and implement this fix. + /// + /// In updating Octopus to 6.14.x we opted to maintain this fix as a work around. + /// + private IWebProxy? _overrideProxy; + private ICredentials? _overrideProxyCredentials; + private bool _overrideProxySet; + private readonly ConcurrentDictionary _cachedCredentials = new ConcurrentDictionary(); private readonly ISettings _settings; @@ -60,6 +77,18 @@ public ProxyCache(ISettings settings, IEnvironmentVariableReader environment) public IWebProxy? GetProxy(Uri sourceUri) { + // Use the override proxy if someone has set it in code + if (_overrideProxy != null) + { + return _overrideProxy; + } + + if (_overrideProxySet) + { + return null; + } + + // Original NuGet Code below: // Check if the user has configured proxy details in settings or in the environment. var configuredProxy = GetUserConfiguredProxy(); if (configuredProxy != null) @@ -81,6 +110,20 @@ public ProxyCache(ISettings settings, IEnvironmentVariableReader environment) return null; } + /// + /// Get the manually overwritten proxy credentials + /// + /// + public ICredentials? GetDefaultProxyCredentials() + { + return _overrideProxyCredentials; + } + + public bool UseProxy() + { + return _overrideProxySet; + } + // Adds new proxy credentials to cache if there's not any in there yet private bool TryAddProxyCredentialsToCache(WebProxy configuredProxy) { @@ -89,6 +132,25 @@ private bool TryAddProxyCredentialsToCache(WebProxy configuredProxy) return _cachedCredentials.TryAdd(configuredProxy.ProxyAddress, proxyCredentials); } + /// + /// Set the manually overwritten proxy settings(these will be used by various v3 providers) + /// + /// + /// + /// var proxy = new WebProxy("http://proxy.com"); + /// var credentials = new NetworkCredential("username", "password"); + /// ProxyCache.Instance.SetOverrideProxySettings(proxy, credentials); + /// + /// + /// + /// + public void SetOverrideProxySettings(IWebProxy proxy, ICredentials credentials) + { + _overrideProxy = proxy; + _overrideProxyCredentials = credentials; + _overrideProxySet = true; + } + public WebProxy? GetUserConfiguredProxy() { // Try reading from the settings. The values are stored as 3 config values http_proxy, http_proxy.user, http_proxy.password diff --git a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt index 7dc5c58110b..fd5b57ce298 100644 --- a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt @@ -1 +1,6 @@ #nullable enable +NuGet.Configuration.IProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? +NuGet.Configuration.IProxyCache.UseProxy() -> bool +NuGet.Configuration.ProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? +NuGet.Configuration.ProxyCache.SetOverrideProxySettings(System.Net.IWebProxy! proxy, System.Net.ICredentials! credentials) -> void +NuGet.Configuration.ProxyCache.UseProxy() -> bool diff --git a/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs b/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs index f6b2102e7d9..6d4d7faf719 100644 --- a/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs +++ b/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs @@ -18,6 +18,18 @@ namespace NuGet.Protocol { + /// + /// Provides an HttpHandlerResourceV3 for a given package source. + /// + /// + /// HttpHandlerResourceV3Provider + /// โ†“ (provides HttpHandlerResource) + /// HttpSourceResourceProvider + /// โ†“ (uses HttpHandlerResource to create HttpSource) + /// HttpSourceResource + /// โ†“ (used by all HTTP-based providers) + /// All V3 and V2 Resources that need HTTP access + /// public class HttpHandlerResourceV3Provider : ResourceProvider { private readonly IProxyCache _proxyCache; @@ -54,15 +66,39 @@ internal HttpHandlerResourceV3Provider(IProxyCache proxyCache) return Task.FromResult(new Tuple(curResource != null, curResource)); } + // To save time of someone coming back to this code later, here is a list of resources that use HttpHandlerResourceV3Provider: + // + // All V3 Resources that depend on HttpSourceResource - INDIRECT USERS + // Based on the grep results, these all call await source.GetResourceAsync(token): + // PackageUpdateResource (via PackageUpdateResourceV3Provider) + // RegistrationResourceV3 (via RegistrationResourceV3Provider) + // ServiceIndexResourceV3 (via ServiceIndexResourceV3Provider) + // PackageSearchResource (via PackageSearchResourceV3Provider) + // PackageMetadataResource (via PackageMetadataResourceV3Provider) + // DownloadResource (via DownloadResourceV3Provider) + // DependencyInfoResource (via DependencyInfoResourceV3Provider) + // AutoCompleteResource (via AutoCompleteResourceV3Provider) + // + // All V2 Resources that depend on HttpSourceResource - INDIRECT USERS + // ODataServiceDocumentResourceV2 (via ODataServiceDocumentResourceV2Provider) + // Plus all V2 feed providers (search, metadata, download, etc.) private HttpHandlerResourceV3 CreateResource(PackageSource packageSource) { var sourceUri = packageSource.SourceUri; var proxy = _proxyCache.GetProxy(sourceUri); + var useProxy = _proxyCache.UseProxy(); +#if IS_CORECLR + var defaultProxyCredentials = ProxyCache.Instance.GetDefaultProxyCredentials(); +#endif // replace the handler with the proxy aware handler var clientHandler = new HttpClientHandler { + UseProxy = useProxy, Proxy = proxy, +#if IS_CORECLR + DefaultProxyCredentials = defaultProxyCredentials, +#endif AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate), }; diff --git a/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs b/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs index 364a6aa2ffc..84bf9b764f3 100644 --- a/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System; using System.Net; using Moq; using NuGet.Common; @@ -148,6 +149,104 @@ public void GetUserConfiguredProxy_ReadsCredentialsFromEnvironmentVariable(strin Assert.Equal(bypassedAddresses, proxy!.BypassList); } + [Fact] + public void SetOverrideProxySettings_WithValidProxy_SetsOverrideProxy() + { + // Arrange + var settings = Mock.Of(); + var environment = Mock.Of(); + var proxyCache = new ProxyCache(settings, environment); + var proxy = new WebProxy("http://proxy.example.com:8080"); + var credentials = new NetworkCredential("testuser", "testpass"); + + // Act + proxyCache.SetOverrideProxySettings(proxy, credentials); + + // Assert + var sourceUri = new Uri("http://example.com"); + var result = proxyCache.GetProxy(sourceUri); + Assert.Same(proxy, result); + Assert.True(proxyCache.UseProxy()); + Assert.Same(credentials, proxyCache.GetDefaultProxyCredentials()); + } + + [Fact] + public void GetProxy_WithOverrideProxy_IgnoresSettingsAndEnvironment() + { + // Arrange + var settings = new Mock(MockBehavior.Strict); + settings.Setup(s => s.GetSection("config")) + .Returns(new VirtualSettingSection("config", + new AddItem("http_proxy", "http://settings.proxy.com"))); + + var environment = new Mock(MockBehavior.Strict); + environment.Setup(s => s.GetEnvironmentVariable("http_proxy")).Returns("http://env.proxy.com"); + environment.Setup(s => s.GetEnvironmentVariable("no_proxy")).Returns(""); + + var proxyCache = new ProxyCache(settings.Object, environment.Object); + var overrideProxy = new WebProxy("http://override.proxy.com"); + var credentials = new NetworkCredential("user", "pass"); + + // Act + proxyCache.SetOverrideProxySettings(overrideProxy, credentials); + var result = proxyCache.GetProxy(new Uri("http://example.com")); + + // Assert + Assert.Same(overrideProxy, result); + + // Verify that settings and environment were not accessed after override was set + settings.Verify(s => s.GetSection("config"), Times.Never); + environment.Verify(s => s.GetEnvironmentVariable("http_proxy"), Times.Never); + } + + [Fact] + public void GetDefaultProxyCredentials_WithOverride_ReturnsCredentials() + { + // Arrange + var settings = Mock.Of(); + var environment = Mock.Of(); + var proxyCache = new ProxyCache(settings, environment); + var proxy = new WebProxy("http://proxy.example.com"); + var credentials = new NetworkCredential("testuser", "testpass"); + + // Act + proxyCache.SetOverrideProxySettings(proxy, credentials); + + // Assert + var result = proxyCache.GetDefaultProxyCredentials(); + Assert.Same(credentials, result); + } + + [Fact] + public void SetOverrideProxySettings_Multiple_Times_UpdatesCorrectly() + { + // Arrange + var settings = Mock.Of(); + var environment = Mock.Of(); + var proxyCache = new ProxyCache(settings, environment); + + var firstProxy = new WebProxy("http://first.proxy.com"); + var firstCredentials = new NetworkCredential("user1", "pass1"); + var secondProxy = new WebProxy("http://second.proxy.com"); + var secondCredentials = new NetworkCredential("user2", "pass2"); + + // Act + proxyCache.SetOverrideProxySettings(firstProxy, firstCredentials); + var firstResult = proxyCache.GetProxy(new Uri("http://example.com")); + var firstCreds = proxyCache.GetDefaultProxyCredentials(); + + proxyCache.SetOverrideProxySettings(secondProxy, secondCredentials); + var secondResult = proxyCache.GetProxy(new Uri("http://example.com")); + var secondCreds = proxyCache.GetDefaultProxyCredentials(); + + // Assert + Assert.Same(firstProxy, firstResult); + Assert.Same(firstCredentials, firstCreds); + Assert.Same(secondProxy, secondResult); + Assert.Same(secondCredentials, secondCreds); + Assert.True(proxyCache.UseProxy()); + } + private static void AssertProxy(string proxyAddress, string? username, string? password, WebProxy? actual) { Assert.NotNull(actual); From 6cc0f7ae260c507e3877d62a33865ae877b4db4b Mon Sep 17 00:00:00 2001 From: William Laugesen Date: Mon, 29 Sep 2025 09:22:18 +1300 Subject: [PATCH 2/7] Removed UseProxy, as HttpClientHandler 'defaults' to true, and _proxyCache.UseProxy() was returning _overrideProxySet (that was always true) for our usages (#11) Removed UseProxy from the proxy cache (as it wasn't a actual configuration option from our consumer, and instead it was inferred), and instead rely on the default HttpClientHandler behavior that sets it to true Also renamed _overrideProxyCredentials -> _overrideDefaultProxyCredentials to be more clear that its to be treated differently to the _overrideProxyWithCustomProxy that i also re-named to make it clear that this is really a 'third' option for the proxy. This will mean the IProxyCache.GetProxy hierarchy is now (depending on configuration): Custom Proxy User Proxy System Proxy No Proxy (cherry picked from commit 9c5f64440e1d52aa54446a91e67d640ad6d7ce73) --- .../NuGet.Configuration/Proxy/IProxyCache.cs | 1 - .../NuGet.Configuration/Proxy/ProxyCache.cs | 45 +++++++++---------- .../NuGet.Configuration/PublicAPI.Shipped.txt | 3 ++ .../PublicAPI.Unshipped.txt | 5 --- .../HttpHandlerResourceV3Provider.cs | 2 - .../ProxyCacheTests.cs | 2 - 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs b/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs index 717a7b69b70..b4c0071b244 100644 --- a/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs +++ b/src/NuGet.Core/NuGet.Configuration/Proxy/IProxyCache.cs @@ -10,6 +10,5 @@ public interface IProxyCache { IWebProxy? GetProxy(Uri uri); ICredentials? GetDefaultProxyCredentials(); - bool UseProxy(); } } diff --git a/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs b/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs index fc35f9e6133..d599a9d1cec 100644 --- a/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs +++ b/src/NuGet.Core/NuGet.Configuration/Proxy/ProxyCache.cs @@ -23,7 +23,7 @@ public class ProxyCache : IProxyCache, IProxyCredentialCache private static readonly IWebProxy _originalSystemProxy = WebRequest.GetSystemWebProxy(); #endif /// - /// Octopus overrides the proxy so we can ensure that the credentials are refreshed every time. + /// Octopus overrides the (user or system proxy) with a custom proxy implementation /// /// /// This was a fix implemented on an older version of NuGet 3.6.1 @@ -33,9 +33,8 @@ public class ProxyCache : IProxyCache, IProxyCredentialCache /// /// In updating Octopus to 6.14.x we opted to maintain this fix as a work around. /// - private IWebProxy? _overrideProxy; - private ICredentials? _overrideProxyCredentials; - private bool _overrideProxySet; + private IWebProxy? _overrideProxyWithCustomProxy; + private ICredentials? _overrideDefaultProxyCredentials; private readonly ConcurrentDictionary _cachedCredentials = new ConcurrentDictionary(); @@ -75,17 +74,18 @@ public ProxyCache(ISettings settings, IEnvironmentVariableReader environment) _environment = environment; } + /// + /// Returns a proxy (if it exists) based on what is set in priority order of: + /// Custom proxy, User configured proxy, System proxy, no proxy. + /// + /// + /// public IWebProxy? GetProxy(Uri sourceUri) { // Use the override proxy if someone has set it in code - if (_overrideProxy != null) + if (_overrideProxyWithCustomProxy is not null) { - return _overrideProxy; - } - - if (_overrideProxySet) - { - return null; + return _overrideProxyWithCustomProxy; } // Original NuGet Code below: @@ -111,17 +111,13 @@ public ProxyCache(ISettings settings, IEnvironmentVariableReader environment) } /// - /// Get the manually overwritten proxy credentials + /// Get the manually overwritten DefaultProxyCredentials. + /// for when we don't set the proxy, but we want the default proxy credentials. /// /// public ICredentials? GetDefaultProxyCredentials() { - return _overrideProxyCredentials; - } - - public bool UseProxy() - { - return _overrideProxySet; + return _overrideDefaultProxyCredentials; } // Adds new proxy credentials to cache if there's not any in there yet @@ -133,7 +129,7 @@ private bool TryAddProxyCredentialsToCache(WebProxy configuredProxy) } /// - /// Set the manually overwritten proxy settings(these will be used by various v3 providers) + /// Override the proxy and default proxy credentials settings /// /// /// @@ -142,13 +138,12 @@ private bool TryAddProxyCredentialsToCache(WebProxy configuredProxy) /// ProxyCache.Instance.SetOverrideProxySettings(proxy, credentials); /// /// - /// - /// - public void SetOverrideProxySettings(IWebProxy proxy, ICredentials credentials) + /// Optional, if not set, default to cache behaviour, user -> system -> no proxy + /// This sets the "defaultProxyCredentials" on the HttpClientHandler (its default is null) + public void SetOverrideProxySettings(IWebProxy? proxy, ICredentials? defaultProxyCredentials) { - _overrideProxy = proxy; - _overrideProxyCredentials = credentials; - _overrideProxySet = true; + _overrideProxyWithCustomProxy = proxy; + _overrideDefaultProxyCredentials = defaultProxyCredentials; } public WebProxy? GetUserConfiguredProxy() diff --git a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Shipped.txt index 0a07cdf7687..0e1c0171df9 100644 --- a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Shipped.txt @@ -87,6 +87,7 @@ NuGet.Configuration.IPackageSourceProvider.SaveAuditSources(System.Collections.G NuGet.Configuration.IPackageSourceProvider.SavePackageSources(System.Collections.Generic.IEnumerable! sources) -> void NuGet.Configuration.IPackageSourceProvider.UpdatePackageSource(NuGet.Configuration.PackageSource! source, bool updateCredentials, bool updateEnabled) -> void NuGet.Configuration.IProxyCache +NuGet.Configuration.IProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? NuGet.Configuration.IProxyCache.GetProxy(System.Uri! uri) -> System.Net.IWebProxy? NuGet.Configuration.IProxyCredentialCache NuGet.Configuration.IProxyCredentialCache.UpdateCredential(System.Uri! proxyAddress, System.Net.NetworkCredential! credentials) -> void @@ -234,9 +235,11 @@ NuGet.Configuration.PackageSourceProvider.Settings.get -> NuGet.Configuration.IS NuGet.Configuration.PackageSourceProvider.UpdatePackageSource(NuGet.Configuration.PackageSource! source, bool updateCredentials, bool updateEnabled) -> void NuGet.Configuration.ProxyCache NuGet.Configuration.ProxyCache.GetCredential(System.Uri! proxyAddress, string! authType) -> System.Net.NetworkCredential? +NuGet.Configuration.ProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? NuGet.Configuration.ProxyCache.GetProxy(System.Uri! sourceUri) -> System.Net.IWebProxy? NuGet.Configuration.ProxyCache.GetUserConfiguredProxy() -> NuGet.Configuration.WebProxy? NuGet.Configuration.ProxyCache.ProxyCache(NuGet.Configuration.ISettings! settings, NuGet.Common.IEnvironmentVariableReader! environment) -> void +NuGet.Configuration.ProxyCache.SetOverrideProxySettings(System.Net.IWebProxy? proxy, System.Net.ICredentials? defaultProxyCredentials) -> void NuGet.Configuration.ProxyCache.UpdateCredential(System.Uri! proxyAddress, System.Net.NetworkCredential! credentials) -> void NuGet.Configuration.ProxyCache.Version.get -> System.Guid NuGet.Configuration.RepositoryItem diff --git a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt index fd5b57ce298..7dc5c58110b 100644 --- a/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt +++ b/src/NuGet.Core/NuGet.Configuration/PublicAPI.Unshipped.txt @@ -1,6 +1 @@ #nullable enable -NuGet.Configuration.IProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? -NuGet.Configuration.IProxyCache.UseProxy() -> bool -NuGet.Configuration.ProxyCache.GetDefaultProxyCredentials() -> System.Net.ICredentials? -NuGet.Configuration.ProxyCache.SetOverrideProxySettings(System.Net.IWebProxy! proxy, System.Net.ICredentials! credentials) -> void -NuGet.Configuration.ProxyCache.UseProxy() -> bool diff --git a/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs b/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs index 6d4d7faf719..8aef356af53 100644 --- a/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs +++ b/src/NuGet.Core/NuGet.Protocol/HttpSource/HttpHandlerResourceV3Provider.cs @@ -86,7 +86,6 @@ private HttpHandlerResourceV3 CreateResource(PackageSource packageSource) { var sourceUri = packageSource.SourceUri; var proxy = _proxyCache.GetProxy(sourceUri); - var useProxy = _proxyCache.UseProxy(); #if IS_CORECLR var defaultProxyCredentials = ProxyCache.Instance.GetDefaultProxyCredentials(); #endif @@ -94,7 +93,6 @@ private HttpHandlerResourceV3 CreateResource(PackageSource packageSource) // replace the handler with the proxy aware handler var clientHandler = new HttpClientHandler { - UseProxy = useProxy, Proxy = proxy, #if IS_CORECLR DefaultProxyCredentials = defaultProxyCredentials, diff --git a/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs b/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs index 84bf9b764f3..b1f33b6f4b7 100644 --- a/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Configuration.Test/ProxyCacheTests.cs @@ -166,7 +166,6 @@ public void SetOverrideProxySettings_WithValidProxy_SetsOverrideProxy() var sourceUri = new Uri("http://example.com"); var result = proxyCache.GetProxy(sourceUri); Assert.Same(proxy, result); - Assert.True(proxyCache.UseProxy()); Assert.Same(credentials, proxyCache.GetDefaultProxyCredentials()); } @@ -244,7 +243,6 @@ public void SetOverrideProxySettings_Multiple_Times_UpdatesCorrectly() Assert.Same(firstCredentials, firstCreds); Assert.Same(secondProxy, secondResult); Assert.Same(secondCredentials, secondCreds); - Assert.True(proxyCache.UseProxy()); } private static void AssertProxy(string proxyAddress, string? username, string? password, WebProxy? actual) From 5f8fc2660c11bfb66b44e124443752285a080095 Mon Sep 17 00:00:00 2001 From: William Laugesen Date: Mon, 29 Sep 2025 10:02:02 +1300 Subject: [PATCH 3/7] Add ReleaseNotes property support to IPackageSearchMetadata (#10) - Add ReleaseNotes property to IPackageSearchMetadata interface - Implement ReleaseNotes in all metadata classes (LocalPackageSearchMetadata, PackageSearchMetadataV2Feed, etc.) - Fix PackageSearchMetadataBuilder.FromIdentity() to include ReleaseNotes - Fix PackageSearchMetadataV2Feed second constructor missing ReleaseNotes assignment - Add ReleaseNotes to PackageSearchMetadataContextInfo and Create() method - Update wrapper classes (RecommendedPackageSearchMetadata, TransitivePackageSearchMetadata) - Add V2FeedPackageInfo constructor overload for backwards compatibility - Update PublicAPI.Unshipped.txt files for all target frameworks - Update GlobalSuppressions.cs for new method signatures - Fix test fixtures and add missing ReleaseNotes assertions (cherry picked from commit b0d0a26c4785dc548b9167f74bbfad8534ba1753) --- .../PackageSearchMetadataContextInfo.cs | 2 + .../RecommendedPackageSearchMetadata.cs | 1 + .../TransitivePackageSearchMetadata.cs | 2 + .../NuGet.Protocol/GlobalSuppressions.cs | 4 +- .../LegacyFeed/V2FeedPackageInfo.cs | 22 +++++++++- .../NuGet.Protocol/LegacyFeed/V2FeedParser.cs | 4 +- .../Model/IPackageSearchMetadata.cs | 1 + .../Model/LocalPackageSearchMetadata.cs | 2 + .../Model/PackageSearchMetadata.cs | 5 +++ .../Model/PackageSearchMetadataBuilder.cs | 6 ++- .../Model/PackageSearchMetadataV2Feed.cs | 4 ++ .../PublicAPI/net10.0/PublicAPI.Shipped.txt | 8 ++++ .../PublicAPI/net472/PublicAPI.Shipped.txt | 8 ++++ ...SearchMetadataContextInfoFormatterTests.cs | 4 +- .../PackageSearchMetadataBuilderTests.cs | 2 +- .../LocalPackageMetadataResourceTests.cs | 2 + .../Model/PackageSearchMetadataTests.cs | 2 +- .../PackageMetadataResourceV2FeedTests.cs | 1 + .../PackageSearchMetadataV2FeedTests.cs | 2 +- .../PackageSearchResourceV2FeedTests.cs | 1 + .../V2FeedPackageInfoTests.cs | 2 +- .../NuGet.Protocol.Tests/V2FeedParserTests.cs | 3 ++ .../compiler/resources/AzureSearch.xml | 4 +- .../compiler/resources/AzureSearch100.xml | 4 +- .../WindowsAzureStorageFindPackagesById.xml | 42 +++++++++---------- .../WindowsAzureStorageGetPackages.xml | 4 +- ...dowsAzureStorageSearchPackage17Entries.xml | 34 +++++++-------- ...dowsAzureStorageSearchPackage30Entries.xml | 8 ++-- .../V3PackageSearchMetadataFixture.cs | 2 + 29 files changed, 128 insertions(+), 58 deletions(-) diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageSearchMetadataContextInfo.cs b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageSearchMetadataContextInfo.cs index 47c46777589..3e30a9f8418 100644 --- a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageSearchMetadataContextInfo.cs +++ b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/ContextInfos/PackageSearchMetadataContextInfo.cs @@ -32,6 +32,7 @@ public sealed class PackageSearchMetadataContextInfo public Uri? PackageDetailsUrl { get; internal set; } public bool RequireLicenseAcceptance { get; internal set; } public string? Summary { get; internal set; } + public string? ReleaseNotes { get; internal set; } public bool PrefixReserved { get; internal set; } public bool IsRecommended { get; internal set; } public (string modelVersion, string vsixVersion)? RecommenderVersion { get; internal set; } @@ -77,6 +78,7 @@ public static PackageSearchMetadataContextInfo Create(IPackageSearchMetadata pac (packageSearchMetadata as ClonedPackageSearchMetadata)?.PackagePath, RequireLicenseAcceptance = packageSearchMetadata.RequireLicenseAcceptance, Summary = packageSearchMetadata.Summary, + ReleaseNotes = packageSearchMetadata.ReleaseNotes, PrefixReserved = packageSearchMetadata.PrefixReserved, IsListed = packageSearchMetadata.IsListed, DependencySets = packageSearchMetadata.DependencySets?.ToList(), diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/RecommendedPackageSearchMetadata.cs b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/RecommendedPackageSearchMetadata.cs index 32267c30376..444a5f4452c 100644 --- a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/RecommendedPackageSearchMetadata.cs +++ b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/RecommendedPackageSearchMetadata.cs @@ -44,6 +44,7 @@ public RecommendedPackageSearchMetadata(IPackageSearchMetadata inner, (string, s public string? Summary => _inner.Summary; public string? Tags => _inner.Tags; public string Title => _inner.Title; + public string? ReleaseNotes => _inner.ReleaseNotes; public bool IsListed => _inner.IsListed; public bool PrefixReserved => _inner.PrefixReserved; public LicenseMetadata? LicenseMetadata => _inner.LicenseMetadata; diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/TransitivePackageSearchMetadata.cs b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/TransitivePackageSearchMetadata.cs index 6c2a574892f..ab2bb84baf0 100644 --- a/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/TransitivePackageSearchMetadata.cs +++ b/src/NuGet.Clients/NuGet.VisualStudio.Internal.Contracts/TransitivePackageSearchMetadata.cs @@ -53,6 +53,8 @@ public class TransitivePackageSearchMetadata : IPackageSearchMetadata public string Title => _packageSearchMetadata.Title; + public string? ReleaseNotes => _packageSearchMetadata.ReleaseNotes; + public bool IsListed => _packageSearchMetadata.IsListed; public bool PrefixReserved => _packageSearchMetadata.PrefixReserved; diff --git a/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs b/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs index 3a98f63c5c4..4b52eb889b0 100644 --- a/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs +++ b/src/NuGet.Core/NuGet.Protocol/GlobalSuppressions.cs @@ -173,8 +173,8 @@ [assembly: SuppressMessage("Build", "CA1062:In externally visible method 'void TokenStore.AddToken(Uri sourceUri, string token)', validate parameter 'sourceUri' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.TokenStore.AddToken(System.Uri,System.String)")] [assembly: SuppressMessage("Build", "CA1062:In externally visible method 'string TokenStore.GetToken(Uri sourceUri)', validate parameter 'sourceUri' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.TokenStore.GetToken(System.Uri)~System.String")] [assembly: SuppressMessage("Build", "CA1062:In externally visible method 'Task> V2FeedListResourceProvider.TryCreate(SourceRepository source, CancellationToken token)', validate parameter 'source' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedListResourceProvider.TryCreate(NuGet.Protocol.Core.Types.SourceRepository,System.Threading.CancellationToken)~System.Threading.Tasks.Task{System.Tuple{System.Boolean,NuGet.Protocol.Core.Types.INuGetResource}}")] -[assembly: SuppressMessage("Build", "CA1054:Change the type of parameter licenseUrl of method V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity, string, string, string, IEnumerable, IEnumerable, string, string, string, string, string, string, DateTimeOffset?, DateTimeOffset?, DateTimeOffset?, string, bool, string, string, string, string, NuGetVersion) from string to System.Uri, or provide an overload to V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity, string, string, string, IEnumerable, IEnumerable, string, string, string, string, string, string, DateTimeOffset?, DateTimeOffset?, DateTimeOffset?, string, bool, string, string, string, string, NuGetVersion) that allows licenseUrl to be passed as a System.Uri object.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedPackageInfo.#ctor(NuGet.Packaging.Core.PackageIdentity,System.String,System.String,System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.String},System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.String,System.Boolean,System.String,System.String,System.String,System.String,NuGet.Versioning.NuGetVersion)")] -[assembly: SuppressMessage("Build", "CA1062:In externally visible method 'V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity identity, string title, string summary, string description, IEnumerable authors, IEnumerable owners, string iconUrl, string licenseUrl, string projectUrl, string reportAbuseUrl, string galleryDetailsUrl, string tags, DateTimeOffset? created, DateTimeOffset? lastEdited, DateTimeOffset? published, string dependencies, bool requireLicenseAccept, string downloadUrl, string downloadCount, string packageHash, string packageHashAlgorithm, NuGetVersion minClientVersion)', validate parameter 'identity' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedPackageInfo.#ctor(NuGet.Packaging.Core.PackageIdentity,System.String,System.String,System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.String},System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.String,System.Boolean,System.String,System.String,System.String,System.String,NuGet.Versioning.NuGetVersion)")] +[assembly: SuppressMessage("Build", "CA1054:Change the type of parameter licenseUrl of method V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity, string, string, string, IEnumerable, IEnumerable, string, string, string, string, string, string, DateTimeOffset?, DateTimeOffset?, DateTimeOffset?, string, bool, string, string, string, string, NuGetVersion, string) from string to System.Uri, or provide an overload to V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity, string, string, string, IEnumerable, IEnumerable, string, string, string, string, string, string, DateTimeOffset?, DateTimeOffset?, DateTimeOffset?, string, bool, string, string, string, string, NuGetVersion, string) that allows licenseUrl to be passed as a System.Uri object.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedPackageInfo.#ctor(NuGet.Packaging.Core.PackageIdentity,System.String,System.String,System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.String},System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.String,System.Boolean,System.String,System.String,System.String,System.String,NuGet.Versioning.NuGetVersion,System.String)")] +[assembly: SuppressMessage("Build", "CA1062:In externally visible method 'V2FeedPackageInfo.V2FeedPackageInfo(PackageIdentity identity, string title, string summary, string description, IEnumerable authors, IEnumerable owners, string iconUrl, string licenseUrl, string projectUrl, string reportAbuseUrl, string galleryDetailsUrl, string tags, DateTimeOffset? created, DateTimeOffset? lastEdited, DateTimeOffset? published, string dependencies, bool requireLicenseAccept, string downloadUrl, string downloadCount, string packageHash, string packageHashAlgorithm, NuGetVersion minClientVersion, string releaseNotes)', validate parameter 'identity' is non-null before using it. If appropriate, throw an ArgumentNullException when the argument is null or add a Code Contract precondition asserting non-null argument.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedPackageInfo.#ctor(NuGet.Packaging.Core.PackageIdentity,System.String,System.String,System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.String},System.String,System.String,System.String,System.String,System.String,System.String,System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.Nullable{System.DateTimeOffset},System.String,System.Boolean,System.String,System.String,System.String,System.String,NuGet.Versioning.NuGetVersion,System.String)")] [assembly: SuppressMessage("Build", "CA1054:Change the type of parameter nextUri of method V2FeedPage.V2FeedPage(List, string) from string to System.Uri, or provide an overload to V2FeedPage.V2FeedPage(List, string) that allows nextUri to be passed as a System.Uri object.", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedPage.#ctor(System.Collections.Generic.List{NuGet.Protocol.V2FeedPackageInfo},System.String)")] [assembly: SuppressMessage("Build", "CA1303:Method 'Task> V2FeedParser.FindPackagesByIdAsync(string id, bool includeUnlisted, bool includePrerelease, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)' passes a literal string as parameter 'message' of a call to 'ArgumentException.ArgumentException(string message)'. Retrieve the following string(s) from a resource table instead: \"id\".", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedParser.FindPackagesByIdAsync(System.String,System.Boolean,System.Boolean,NuGet.Protocol.Core.Types.SourceCacheContext,NuGet.Common.ILogger,System.Threading.CancellationToken)~System.Threading.Tasks.Task{System.Collections.Generic.IReadOnlyList{NuGet.Protocol.V2FeedPackageInfo}}")] [assembly: SuppressMessage("Build", "CA1822:Member GetCacheKey does not access instance data and can be marked as static (Shared in VisualBasic)", Justification = "", Scope = "member", Target = "~M:NuGet.Protocol.V2FeedParser.GetCacheKey(System.String,System.Int32)~System.String")] diff --git a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs index 433c6f9cc43..f0debe74e80 100644 --- a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs +++ b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedPackageInfo.cs @@ -13,7 +13,7 @@ namespace NuGet.Protocol { /// - /// Represents a V2 package entry from the OData feed. This object primarily just holds the strings parsed from XML, all parsing + /// Represents a V2 package entry from the OData feed. This object primarily just holds the strings parsed from XML, all parsing /// and converting should be done after based on the scenario. /// public class V2FeedPackageInfo : PackageIdentity @@ -39,12 +39,23 @@ public class V2FeedPackageInfo : PackageIdentity private readonly string? _packageHash; private readonly string? _packageHashAlgorithm; private readonly NuGetVersion? _minClientVersion; + private readonly string? _releaseNotes; private const string NullString = "null"; + // Original constructor (backwards compatibility) public V2FeedPackageInfo(PackageIdentity identity, string? title, string? summary, string? description, IEnumerable? authors, IEnumerable? owners, string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, string? tags, DateTimeOffset? created, DateTimeOffset? lastEdited, DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, string? packageHash, string? packageHashAlgorithm, NuGetVersion? minClientVersion) + : this(identity, title, summary, description, authors, owners, iconUrl, licenseUrl, projectUrl, reportAbuseUrl, galleryDetailsUrl, tags, created, lastEdited, published, dependencies, requireLicenseAccept, downloadUrl, downloadCount, packageHash, packageHashAlgorithm, minClientVersion, null) + { + } + + // New constructor with releaseNotes parameter + public V2FeedPackageInfo(PackageIdentity identity, string? title, string? summary, string? description, IEnumerable? authors, IEnumerable? owners, + string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, + string? tags, DateTimeOffset? created, DateTimeOffset? lastEdited, DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, + string? packageHash, string? packageHashAlgorithm, NuGetVersion? minClientVersion, string? releaseNotes) : base(identity.Id, identity.Version) { _summary = summary; @@ -70,6 +81,7 @@ public V2FeedPackageInfo(PackageIdentity identity, string? title, string? summar _packageHash = packageHash; _packageHashAlgorithm = packageHashAlgorithm; _minClientVersion = minClientVersion; + _releaseNotes = releaseNotes; } public string? Title @@ -347,5 +359,13 @@ public NuGetVersion? MinClientVersion return _minClientVersion; } } + + public string? ReleaseNotes + { + get + { + return _releaseNotes; + } + } } } diff --git a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedParser.cs b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedParser.cs index 95be3d64e07..1bcaff941f0 100644 --- a/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedParser.cs +++ b/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedParser.cs @@ -45,6 +45,7 @@ public sealed class V2FeedParser : IV2FeedParser private static readonly XName _xnameTags = XName.Get("Tags", DataServicesNS); private static readonly XName _xnameGalleryDetailsUrl = XName.Get("GalleryDetailsUrl", DataServicesNS); private static readonly XName _xnameReportAbuseUrl = XName.Get("ReportAbuseUrl", DataServicesNS); + private static readonly XName _xnameReleaseNotes = XName.Get("ReleaseNotes", DataServicesNS); private static readonly XName _xnameDependencies = XName.Get("Dependencies", DataServicesNS); private static readonly XName _xnameRequireLicenseAcceptance = XName.Get("RequireLicenseAcceptance", DataServicesNS); private static readonly XName _xnameDownloadCount = XName.Get("DownloadCount", DataServicesNS); @@ -347,6 +348,7 @@ private V2FeedPackageInfo ParsePackage(string? id, XElement element, MetadataRef var projectUrl = metadataCache.GetString(GetString(properties, _xnameProjectUrl)); var galleryDetailsUrl = metadataCache.GetString(GetString(properties, _xnameGalleryDetailsUrl)); var reportAbuseUrl = metadataCache.GetString(GetString(properties, _xnameReportAbuseUrl)); + var releaseNotes = metadataCache.GetString(GetString(properties, _xnameReleaseNotes)); var tags = metadataCache.GetString(GetString(properties, _xnameTags)); var dependencies = metadataCache.GetString(GetString(properties, _xnameDependencies)); @@ -383,7 +385,7 @@ private V2FeedPackageInfo ParsePackage(string? id, XElement element, MetadataRef return new V2FeedPackageInfo(new PackageIdentity(identityId, version), title, summary, description, authors, owners, iconUrl, licenseUrl, projectUrl, reportAbuseUrl, galleryDetailsUrl, tags, created, lastEdited, published, dependencies, requireLicenseAcceptance, downloadUrl, downloadCount, packageHash, - packageHashAlgorithm, minClientVersion); + packageHashAlgorithm, minClientVersion, releaseNotes); } /// diff --git a/src/NuGet.Core/NuGet.Protocol/Model/IPackageSearchMetadata.cs b/src/NuGet.Core/NuGet.Protocol/Model/IPackageSearchMetadata.cs index 729aaf613eb..b08fc38d750 100644 --- a/src/NuGet.Core/NuGet.Protocol/Model/IPackageSearchMetadata.cs +++ b/src/NuGet.Core/NuGet.Protocol/Model/IPackageSearchMetadata.cs @@ -34,6 +34,7 @@ public interface IPackageSearchMetadata string? Summary { get; } string? Tags { get; } string Title { get; } + string? ReleaseNotes { get; } bool IsListed { get; } bool PrefixReserved { get; } diff --git a/src/NuGet.Core/NuGet.Protocol/Model/LocalPackageSearchMetadata.cs b/src/NuGet.Core/NuGet.Protocol/Model/LocalPackageSearchMetadata.cs index 8b0d0766ccd..0744a05e524 100644 --- a/src/NuGet.Core/NuGet.Protocol/Model/LocalPackageSearchMetadata.cs +++ b/src/NuGet.Core/NuGet.Protocol/Model/LocalPackageSearchMetadata.cs @@ -75,6 +75,8 @@ public IReadOnlyList? OwnersList /// public Uri? ReportAbuseUrl => null; + public string? ReleaseNotes => _nuspec.GetReleaseNotes(); + public Uri? PackageDetailsUrl => null; public bool RequireLicenseAcceptance => _nuspec.GetRequireLicenseAcceptance(); diff --git a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadata.cs b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadata.cs index 84ed5de5454..80503b37570 100644 --- a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadata.cs +++ b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadata.cs @@ -188,6 +188,10 @@ public string Title internal set { _titleValue = value; } } + [Newtonsoft.Json.JsonIgnore] + [System.Text.Json.Serialization.JsonIgnore] + public string? ReleaseNotes { get; private set; } + [JsonProperty(PropertyName = JsonProperties.Version)] [JsonPropertyName(JsonProperties.Version)] [JsonInclude] @@ -329,6 +333,7 @@ internal void CacheStrings(MetadataReferenceCache cache) Tags = cache.GetString(Tags); Summary = cache.GetString(Summary); Title = cache.GetString(Title)!; + ReleaseNotes = cache.GetString(ReleaseNotes); LicenseExpression = cache.GetString(LicenseExpression); LicenseExpressionVersion = cache.GetString(LicenseExpressionVersion); } diff --git a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataBuilder.cs b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataBuilder.cs index 6c571a9de62..a3ce103bb18 100644 --- a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataBuilder.cs +++ b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataBuilder.cs @@ -47,6 +47,7 @@ public class ClonedPackageSearchMetadata : IPackageSearchMetadata public string? Summary { get; set; } public string? Tags { get; set; } public string Title { get; set; } = null!; + public string? ReleaseNotes { get; set; } public bool PrefixReserved { get; set; } public LicenseMetadata? LicenseMetadata { get; set; } @@ -70,6 +71,7 @@ internal void CacheStrings(MetadataReferenceCache cache) Summary = cache.GetString(Summary); Tags = cache.GetString(Tags); Title = cache.GetString(Title)!; + ReleaseNotes = cache.GetString(ReleaseNotes); PackagePath = cache.GetString(PackagePath); } } @@ -118,6 +120,7 @@ public IPackageSearchMetadata Build() Summary = _metadata.Summary, Tags = _metadata.Tags, Title = _metadata.Title, + ReleaseNotes = _metadata.ReleaseNotes, LazyVersionsFactory = _lazyVersionsFactory, IsListed = _metadata.IsListed, PrefixReserved = _metadata.PrefixReserved, @@ -147,7 +150,8 @@ public static PackageSearchMetadataBuilder FromIdentity(PackageIdentity identity Identity = identity, Title = identity.Id, Summary = string.Empty, - Authors = string.Empty + Authors = string.Empty, + ReleaseNotes = string.Empty }; return FromMetadata(metadata); } diff --git a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataV2Feed.cs b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataV2Feed.cs index d79ab6903ee..3f58ab0c926 100644 --- a/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataV2Feed.cs +++ b/src/NuGet.Core/NuGet.Protocol/Model/PackageSearchMetadataV2Feed.cs @@ -27,6 +27,7 @@ public PackageSearchMetadataV2Feed(V2FeedPackageInfo package) LastEdited = package.LastEdited; Published = package.Published; ReportAbuseUrl = GetUriSafe(package.ReportAbuseUrl); + ReleaseNotes = package.ReleaseNotes; PackageDetailsUrl = GetUriSafe(package.GalleryDetailsUrl); RequireLicenseAcceptance = package.RequireLicenseAcceptance; _summaryValue = package.Summary; @@ -56,6 +57,7 @@ public PackageSearchMetadataV2Feed(V2FeedPackageInfo package, MetadataReferenceC LastEdited = package.LastEdited; Published = package.Published; ReportAbuseUrl = GetUriSafe(package.ReportAbuseUrl); + ReleaseNotes = package.ReleaseNotes; PackageDetailsUrl = GetUriSafe(package.GalleryDetailsUrl); RequireLicenseAcceptance = package.RequireLicenseAcceptance; _summaryValue = package.Summary; @@ -136,6 +138,8 @@ public string Title public NuGetVersion Version { get; private set; } + public string? ReleaseNotes { get; private set; } + /// public Task> GetVersionsAsync() => TaskResult.EmptyEnumerable(); diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net10.0/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net10.0/PublicAPI.Shipped.txt index e186bf04438..4f608e16ede 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net10.0/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net10.0/PublicAPI.Shipped.txt @@ -97,6 +97,7 @@ NuGet.Protocol.Core.Types.IPackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.Core.Types.IPackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.Core.Types.IPackageSearchMetadata.RequireLicenseAcceptance.get -> bool NuGet.Protocol.Core.Types.IPackageSearchMetadata.Summary.get -> string? @@ -202,6 +203,8 @@ NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetada NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeFileUrl.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeUrl.get -> System.Uri? NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeUrl.set -> void +NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReleaseNotes.get -> string? +NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReleaseNotes.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReportAbuseUrl.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.RequireLicenseAcceptance.get -> bool @@ -655,6 +658,7 @@ NuGet.Protocol.LocalPackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.LocalPackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.LocalPackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.LocalPackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.LocalPackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.LocalPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.LocalPackageSearchMetadata.RequireLicenseAcceptance.get -> bool NuGet.Protocol.LocalPackageSearchMetadata.Summary.get -> string? @@ -778,6 +782,7 @@ NuGet.Protocol.PackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.PackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.PackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.PackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.PackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadata.ReportAbuseUrl.set -> void NuGet.Protocol.PackageSearchMetadata.RequireLicenseAcceptance.get -> bool @@ -815,6 +820,7 @@ NuGet.Protocol.PackageSearchMetadataV2Feed.ProjectUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadataV2Feed.Published.get -> System.DateTimeOffset? NuGet.Protocol.PackageSearchMetadataV2Feed.ReadmeFileUrl.get -> string? NuGet.Protocol.PackageSearchMetadataV2Feed.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.PackageSearchMetadataV2Feed.ReleaseNotes.get -> string? NuGet.Protocol.PackageSearchMetadataV2Feed.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadataV2Feed.RequireLicenseAcceptance.get -> bool NuGet.Protocol.PackageSearchMetadataV2Feed.Summary.get -> string? @@ -1482,12 +1488,14 @@ NuGet.Protocol.V2FeedPackageInfo.PackageHash.get -> string? NuGet.Protocol.V2FeedPackageInfo.PackageHashAlgorithm.get -> string? NuGet.Protocol.V2FeedPackageInfo.ProjectUrl.get -> string? NuGet.Protocol.V2FeedPackageInfo.Published.get -> System.DateTimeOffset? +NuGet.Protocol.V2FeedPackageInfo.ReleaseNotes.get -> string? NuGet.Protocol.V2FeedPackageInfo.ReportAbuseUrl.get -> string? NuGet.Protocol.V2FeedPackageInfo.RequireLicenseAcceptance.get -> bool NuGet.Protocol.V2FeedPackageInfo.Summary.get -> string? NuGet.Protocol.V2FeedPackageInfo.Tags.get -> string? NuGet.Protocol.V2FeedPackageInfo.Title.get -> string? NuGet.Protocol.V2FeedPackageInfo.V2FeedPackageInfo(NuGet.Packaging.Core.PackageIdentity! identity, string? title, string? summary, string? description, System.Collections.Generic.IEnumerable? authors, System.Collections.Generic.IEnumerable? owners, string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, string? tags, System.DateTimeOffset? created, System.DateTimeOffset? lastEdited, System.DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, string? packageHash, string? packageHashAlgorithm, NuGet.Versioning.NuGetVersion? minClientVersion) -> void +NuGet.Protocol.V2FeedPackageInfo.V2FeedPackageInfo(NuGet.Packaging.Core.PackageIdentity! identity, string? title, string? summary, string? description, System.Collections.Generic.IEnumerable? authors, System.Collections.Generic.IEnumerable? owners, string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, string? tags, System.DateTimeOffset? created, System.DateTimeOffset? lastEdited, System.DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, string? packageHash, string? packageHashAlgorithm, NuGet.Versioning.NuGetVersion? minClientVersion, string? releaseNotes) -> void NuGet.Protocol.V2FeedPage NuGet.Protocol.V2FeedPage.Items.get -> System.Collections.Generic.IReadOnlyList! NuGet.Protocol.V2FeedPage.NextUri.get -> string? diff --git a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt index 26dc85cc177..1f754485be8 100644 --- a/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt +++ b/src/NuGet.Core/NuGet.Protocol/PublicAPI/net472/PublicAPI.Shipped.txt @@ -97,6 +97,7 @@ NuGet.Protocol.Core.Types.IPackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.Core.Types.IPackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.Core.Types.IPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.Core.Types.IPackageSearchMetadata.RequireLicenseAcceptance.get -> bool NuGet.Protocol.Core.Types.IPackageSearchMetadata.Summary.get -> string? @@ -202,6 +203,8 @@ NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetada NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeFileUrl.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeUrl.get -> System.Uri? NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReadmeUrl.set -> void +NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReleaseNotes.get -> string? +NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReleaseNotes.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.ReportAbuseUrl.set -> void NuGet.Protocol.Core.Types.PackageSearchMetadataBuilder.ClonedPackageSearchMetadata.RequireLicenseAcceptance.get -> bool @@ -655,6 +658,7 @@ NuGet.Protocol.LocalPackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.LocalPackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.LocalPackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.LocalPackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.LocalPackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.LocalPackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.LocalPackageSearchMetadata.RequireLicenseAcceptance.get -> bool NuGet.Protocol.LocalPackageSearchMetadata.Summary.get -> string? @@ -778,6 +782,7 @@ NuGet.Protocol.PackageSearchMetadata.ProjectUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadata.Published.get -> System.DateTimeOffset? NuGet.Protocol.PackageSearchMetadata.ReadmeFileUrl.get -> string? NuGet.Protocol.PackageSearchMetadata.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.PackageSearchMetadata.ReleaseNotes.get -> string? NuGet.Protocol.PackageSearchMetadata.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadata.ReportAbuseUrl.set -> void NuGet.Protocol.PackageSearchMetadata.RequireLicenseAcceptance.get -> bool @@ -815,6 +820,7 @@ NuGet.Protocol.PackageSearchMetadataV2Feed.ProjectUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadataV2Feed.Published.get -> System.DateTimeOffset? NuGet.Protocol.PackageSearchMetadataV2Feed.ReadmeFileUrl.get -> string? NuGet.Protocol.PackageSearchMetadataV2Feed.ReadmeUrl.get -> System.Uri? +NuGet.Protocol.PackageSearchMetadataV2Feed.ReleaseNotes.get -> string? NuGet.Protocol.PackageSearchMetadataV2Feed.ReportAbuseUrl.get -> System.Uri? NuGet.Protocol.PackageSearchMetadataV2Feed.RequireLicenseAcceptance.get -> bool NuGet.Protocol.PackageSearchMetadataV2Feed.Summary.get -> string? @@ -1486,12 +1492,14 @@ NuGet.Protocol.V2FeedPackageInfo.PackageHash.get -> string? NuGet.Protocol.V2FeedPackageInfo.PackageHashAlgorithm.get -> string? NuGet.Protocol.V2FeedPackageInfo.ProjectUrl.get -> string? NuGet.Protocol.V2FeedPackageInfo.Published.get -> System.DateTimeOffset? +NuGet.Protocol.V2FeedPackageInfo.ReleaseNotes.get -> string? NuGet.Protocol.V2FeedPackageInfo.ReportAbuseUrl.get -> string? NuGet.Protocol.V2FeedPackageInfo.RequireLicenseAcceptance.get -> bool NuGet.Protocol.V2FeedPackageInfo.Summary.get -> string? NuGet.Protocol.V2FeedPackageInfo.Tags.get -> string? NuGet.Protocol.V2FeedPackageInfo.Title.get -> string? NuGet.Protocol.V2FeedPackageInfo.V2FeedPackageInfo(NuGet.Packaging.Core.PackageIdentity! identity, string? title, string? summary, string? description, System.Collections.Generic.IEnumerable? authors, System.Collections.Generic.IEnumerable? owners, string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, string? tags, System.DateTimeOffset? created, System.DateTimeOffset? lastEdited, System.DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, string? packageHash, string? packageHashAlgorithm, NuGet.Versioning.NuGetVersion? minClientVersion) -> void +NuGet.Protocol.V2FeedPackageInfo.V2FeedPackageInfo(NuGet.Packaging.Core.PackageIdentity! identity, string? title, string? summary, string? description, System.Collections.Generic.IEnumerable? authors, System.Collections.Generic.IEnumerable? owners, string? iconUrl, string? licenseUrl, string? projectUrl, string? reportAbuseUrl, string? galleryDetailsUrl, string? tags, System.DateTimeOffset? created, System.DateTimeOffset? lastEdited, System.DateTimeOffset? published, string? dependencies, bool requireLicenseAccept, string? downloadUrl, string? downloadCount, string? packageHash, string? packageHashAlgorithm, NuGet.Versioning.NuGetVersion? minClientVersion, string? releaseNotes) -> void NuGet.Protocol.V2FeedPage NuGet.Protocol.V2FeedPage.Items.get -> System.Collections.Generic.IReadOnlyList! NuGet.Protocol.V2FeedPage.NextUri.get -> string? diff --git a/test/NuGet.Clients.Tests/NuGet.VisualStudio.Internal.Contracts.Test/Formatters/PackageSearchMetadataContextInfoFormatterTests.cs b/test/NuGet.Clients.Tests/NuGet.VisualStudio.Internal.Contracts.Test/Formatters/PackageSearchMetadataContextInfoFormatterTests.cs index 4fdf412561b..d7cfa667bc3 100644 --- a/test/NuGet.Clients.Tests/NuGet.VisualStudio.Internal.Contracts.Test/Formatters/PackageSearchMetadataContextInfoFormatterTests.cs +++ b/test/NuGet.Clients.Tests/NuGet.VisualStudio.Internal.Contracts.Test/Formatters/PackageSearchMetadataContextInfoFormatterTests.cs @@ -56,6 +56,7 @@ public void SerializeThenDeserialize_WithValidArguments_RoundTrips(PackageSearch Assert.Equal(expectedResult.PackagePath, actualResult.PackagePath); Assert.Equal(expectedResult.Published, actualResult.Published); Assert.Equal(expectedResult.ReportAbuseUrl, actualResult.ReportAbuseUrl); + Assert.Equal(expectedResult.ReleaseNotes, actualResult.ReleaseNotes); Assert.Equal(expectedResult.Title, actualResult.Title); Assert.Equal(expectedResult.Vulnerabilities, actualResult.Vulnerabilities); } @@ -84,7 +85,8 @@ public void SerializeThenDeserialize_WithValidArguments_RoundTrips(PackageSearch RequireLicenseAcceptance = true, Summary = "summary", Tags = "tags", - Title = "title" + Title = "title", + ReleaseNotes = "release notes" }) }, { PackageSearchMetadataContextInfo.Create(new PackageSearchMetadataBuilder.ClonedPackageSearchMetadata() { }) } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Core/Types/PackageSearchMetadataBuilderTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Core/Types/PackageSearchMetadataBuilderTests.cs index b4b4036b9cc..14777169766 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Core/Types/PackageSearchMetadataBuilderTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Core/Types/PackageSearchMetadataBuilderTests.cs @@ -72,7 +72,7 @@ public void Verify_AllStringProperties_AccountedInCacheStrings() .Where(p => p.PropertyType == typeof(string)) .ToArray(); - stringProperties.Should().HaveCount(8, + stringProperties.Should().HaveCount(9, $"the number of string properties changed in ClonedPackageSearchMetadata " + $"[{string.Join(", ", stringProperties.Select(p => p.Name))}]. " + "Please make sure this change is accounted for in the CacheStrings method"); diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageMetadataResourceTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageMetadataResourceTests.cs index d39162fd9b8..6c1831c0f6d 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageMetadataResourceTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageMetadataResourceTests.cs @@ -321,6 +321,7 @@ public async Task LocalPackageMetadataResourceTests_VerifyAllFieldsAsync() Assert.Equal("sum", package.Summary); Assert.Equal("a b c", package.Tags); Assert.Equal("myTitle", package.Title); + Assert.Equal("notes", package.ReleaseNotes); } } @@ -427,6 +428,7 @@ public async Task LocalPackageMetadataResourceTests_WhenOwnersIsEmpty_OwnersList Assert.Equal("sum", package.Summary); Assert.Equal("a b c", package.Tags); Assert.Equal("myTitle", package.Title); + Assert.Equal("notes", package.ReleaseNotes); } } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Model/PackageSearchMetadataTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Model/PackageSearchMetadataTests.cs index 0d8e70b2671..ba73c67a019 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Model/PackageSearchMetadataTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Model/PackageSearchMetadataTests.cs @@ -39,7 +39,7 @@ public void Verify_AllStringProperties_AccountedInCacheStrings() .Where(p => p.PropertyType == typeof(string)) .ToArray(); - stringProperties.Should().HaveCount(10, + stringProperties.Should().HaveCount(11, $"the number of string properties changed in PackageSearchMetadata " + $"[{string.Join(", ", stringProperties.Select(p => p.Name))}]. " + "Please make sure this change is accounted for in the CacheStrings method"); diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageMetadataResourceV2FeedTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageMetadataResourceV2FeedTests.cs index 564b66444ae..419b1bd4da6 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageMetadataResourceV2FeedTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageMetadataResourceV2FeedTests.cs @@ -58,6 +58,7 @@ public async Task PackageMetadataResource_Basic() Assert.Equal("Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial", latestPackage.Tags); Assert.Equal(6, latestPackage.DependencySets.Count()); Assert.Equal("dotnet54", latestPackage.DependencySets.First().TargetFramework.GetShortFolderName()); + Assert.Equal("release notes", latestPackage.ReleaseNotes); } [Fact] diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchMetadataV2FeedTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchMetadataV2FeedTests.cs index aafd7c1ceee..87ba46b529d 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchMetadataV2FeedTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchMetadataV2FeedTests.cs @@ -87,7 +87,7 @@ private V2FeedPackageInfo CreateTestPackageInfo(IEnumerable authors, IEn return new V2FeedPackageInfo(new PackageIdentity("test", NuGetVersion.Parse("1.0.0")), "title", "summary", "description", authors, owners, iconUrl, licenseUrl, projectUrl, reportAbuseUrl, galleryDetailsUrl, "tags", null, null, null, "dependencies", - false, "downloadUrl", "0", "packageHash", "packageHashAlgorithm", new NuGetVersion("3.0")); + false, "downloadUrl", "0", "packageHash", "packageHashAlgorithm", new NuGetVersion("3.0"), "release notes"); } } } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchResourceV2FeedTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchResourceV2FeedTests.cs index 3e80e361f8e..4719dbbeeee 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchResourceV2FeedTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/PackageSearchResourceV2FeedTests.cs @@ -61,6 +61,7 @@ public async Task PackageSearchResourceV2Feed_Basic() Assert.Equal("Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial", package.Tags); Assert.Equal(4, package.DependencySets.Count()); Assert.Equal("net40-client", package.DependencySets.First().TargetFramework.GetShortFolderName()); + Assert.Equal("release notes", package.ReleaseNotes); } [Fact] diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedPackageInfoTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedPackageInfoTests.cs index 38b26443b6c..70a8aee1335 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedPackageInfoTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedPackageInfoTests.cs @@ -141,7 +141,7 @@ private V2FeedPackageInfo CreateTestPackageInfoForDependencyGroup(string depende return new V2FeedPackageInfo(new PackageIdentity("test", NuGetVersion.Parse("1.0.0")), "title", "summary", "description", Enumerable.Empty(), Enumerable.Empty(), "iconUrl", "licenseUrl", "projectUrl", "reportAbuseUrl", "galleryDetailsUrl", "tags", null, null, null, dependencies, - false, "downloadUrl", "0", "packageHash", "packageHashAlgorithm", new NuGetVersion("3.0")); + false, "downloadUrl", "0", "packageHash", "packageHashAlgorithm", new NuGetVersion("3.0"), "release notes"); } } } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedParserTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedParserTests.cs index 3a44eaf5dd2..1b70c797d2a 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedParserTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/V2FeedParserTests.cs @@ -229,6 +229,7 @@ public async Task V2FeedParser_Search() Assert.Equal("Microsoft.Data.OData:5.6.4:net40-Client|Newtonsoft.Json:6.0.8:net40-Client|Microsoft.Data.Services.Client:5.6.4:net40-Client|Microsoft.Azure.KeyVault.Core:1.0.0:net40-Client|Microsoft.Data.OData:5.6.4:win80|Newtonsoft.Json:6.0.8:win80|Microsoft.Data.OData:5.6.4:wpa|Newtonsoft.Json:6.0.8:wpa|Microsoft.Data.OData:5.6.4:wp80|Newtonsoft.Json:6.0.8:wp80|Microsoft.Azure.KeyVault.Core:1.0.0:wp80", package.Dependencies); Assert.Equal(4, package.DependencySets.Count); Assert.Equal("net40-client", package.DependencySets.First().TargetFramework.GetShortFolderName()); + Assert.Equal("release notes", package.ReleaseNotes); } [Fact] @@ -444,6 +445,7 @@ public async Task V2FeedParser_GetPackage() Assert.Equal("Microsoft.Data.OData:5.6.3:aspnetcore50|Microsoft.Data.Services.Client:5.6.3:aspnetcore50|System.Spatial:5.6.3:aspnetcore50|System.Collections:4.0.10-beta-22231:aspnetcore50|System.Collections.Concurrent:4.0.0-beta-22231:aspnetcore50|System.Collections.Specialized:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Debug:4.0.10-beta-22231:aspnetcore50|System.Diagnostics.Tools:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.TraceSource:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Tracing:4.0.10-beta-22231:aspnetcore50|System.Dynamic.Runtime:4.0.0-beta-22231:aspnetcore50|System.Globalization:4.0.10-beta-22231:aspnetcore50|System.IO:4.0.10-beta-22231:aspnetcore50|System.IO.FileSystem:4.0.0-beta-22231:aspnetcore50|System.IO.FileSystem.Primitives:4.0.0-beta-22231:aspnetcore50|System.Linq:4.0.0-beta-22231:aspnetcore50|System.Linq.Expressions:4.0.0-beta-22231:aspnetcore50|System.Linq.Queryable:4.0.0-beta-22231:aspnetcore50|System.Net.Http:4.0.0-beta-22231:aspnetcore50|System.Net.Primitives:4.0.10-beta-22231:aspnetcore50|System.Reflection:4.0.10-beta-22231:aspnetcore50|System.Reflection.Extensions:4.0.0-beta-22231:aspnetcore50|System.Reflection.TypeExtensions:4.0.0-beta-22231:aspnetcore50|System.Runtime:4.0.20-beta-22231:aspnetcore50|System.Runtime.Extensions:4.0.10-beta-22231:aspnetcore50|System.Runtime.InteropServices:4.0.20-beta-22231:aspnetcore50|System.Runtime.Serialization.Primitives:4.0.0-beta-22231:aspnetcore50|System.Runtime.Serialization.Xml:4.0.10-beta-22231:aspnetcore50|System.Security.Cryptography.Encoding:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Encryption:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing.Algorithms:4.0.0-beta-22231:aspnetcore50|System.Text.Encoding:4.0.10-beta-22231:aspnetcore50|System.Text.Encoding.Extensions:4.0.10-beta-22231:aspnetcore50|System.Text.RegularExpressions:4.0.10-beta-22231:aspnetcore50|System.Threading:4.0.0-beta-22231:aspnetcore50|System.Threading.Tasks:4.0.10-beta-22231:aspnetcore50|System.Threading.Thread:4.0.0-beta-22231:aspnetcore50|System.Threading.ThreadPool:4.0.10-beta-22231:aspnetcore50|System.Threading.Timer:4.0.0-beta-22231:aspnetcore50|System.Xml.ReaderWriter:4.0.10-beta-22231:aspnetcore50|System.Xml.XDocument:4.0.0-beta-22231:aspnetcore50|System.Xml.XmlSerializer:4.0.0-beta-22231:aspnetcore50|Microsoft.Data.OData:5.6.3:aspnet50|Microsoft.Data.Services.Client:5.6.3:aspnet50|System.Spatial:5.6.3:aspnet50|Microsoft.Data.OData:5.6.2:net40-Client|Newtonsoft.Json:5.0.8:net40-Client|Microsoft.Data.Services.Client:5.6.2:net40-Client|Microsoft.WindowsAzure.ConfigurationManager:1.8.0.0:net40-Client|Microsoft.Data.OData:5.6.2:win80|Microsoft.Data.OData:5.6.2:wpa|Microsoft.Data.OData:5.6.2:wp80|Newtonsoft.Json:5.0.8:wp80", package.Dependencies); Assert.Equal(6, package.DependencySets.Count); Assert.Equal("aspnetcore50", package.DependencySets.First().TargetFramework.GetShortFolderName()); + Assert.Equal("release notes", package.ReleaseNotes); } [Fact] @@ -513,6 +515,7 @@ public async Task V2FeedParser_GetPackage_NotFoundOnPackagesFoundOnFindPackagesB Assert.Equal("Microsoft.Data.OData:5.6.3:aspnetcore50|Microsoft.Data.Services.Client:5.6.3:aspnetcore50|System.Spatial:5.6.3:aspnetcore50|System.Collections:4.0.10-beta-22231:aspnetcore50|System.Collections.Concurrent:4.0.0-beta-22231:aspnetcore50|System.Collections.Specialized:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Debug:4.0.10-beta-22231:aspnetcore50|System.Diagnostics.Tools:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.TraceSource:4.0.0-beta-22231:aspnetcore50|System.Diagnostics.Tracing:4.0.10-beta-22231:aspnetcore50|System.Dynamic.Runtime:4.0.0-beta-22231:aspnetcore50|System.Globalization:4.0.10-beta-22231:aspnetcore50|System.IO:4.0.10-beta-22231:aspnetcore50|System.IO.FileSystem:4.0.0-beta-22231:aspnetcore50|System.IO.FileSystem.Primitives:4.0.0-beta-22231:aspnetcore50|System.Linq:4.0.0-beta-22231:aspnetcore50|System.Linq.Expressions:4.0.0-beta-22231:aspnetcore50|System.Linq.Queryable:4.0.0-beta-22231:aspnetcore50|System.Net.Http:4.0.0-beta-22231:aspnetcore50|System.Net.Primitives:4.0.10-beta-22231:aspnetcore50|System.Reflection:4.0.10-beta-22231:aspnetcore50|System.Reflection.Extensions:4.0.0-beta-22231:aspnetcore50|System.Reflection.TypeExtensions:4.0.0-beta-22231:aspnetcore50|System.Runtime:4.0.20-beta-22231:aspnetcore50|System.Runtime.Extensions:4.0.10-beta-22231:aspnetcore50|System.Runtime.InteropServices:4.0.20-beta-22231:aspnetcore50|System.Runtime.Serialization.Primitives:4.0.0-beta-22231:aspnetcore50|System.Runtime.Serialization.Xml:4.0.10-beta-22231:aspnetcore50|System.Security.Cryptography.Encoding:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Encryption:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing:4.0.0-beta-22231:aspnetcore50|System.Security.Cryptography.Hashing.Algorithms:4.0.0-beta-22231:aspnetcore50|System.Text.Encoding:4.0.10-beta-22231:aspnetcore50|System.Text.Encoding.Extensions:4.0.10-beta-22231:aspnetcore50|System.Text.RegularExpressions:4.0.10-beta-22231:aspnetcore50|System.Threading:4.0.0-beta-22231:aspnetcore50|System.Threading.Tasks:4.0.10-beta-22231:aspnetcore50|System.Threading.Thread:4.0.0-beta-22231:aspnetcore50|System.Threading.ThreadPool:4.0.10-beta-22231:aspnetcore50|System.Threading.Timer:4.0.0-beta-22231:aspnetcore50|System.Xml.ReaderWriter:4.0.10-beta-22231:aspnetcore50|System.Xml.XDocument:4.0.0-beta-22231:aspnetcore50|System.Xml.XmlSerializer:4.0.0-beta-22231:aspnetcore50|Microsoft.Data.OData:5.6.3:aspnet50|Microsoft.Data.Services.Client:5.6.3:aspnet50|System.Spatial:5.6.3:aspnet50|Microsoft.Data.OData:5.6.2:net40-Client|Newtonsoft.Json:5.0.8:net40-Client|Microsoft.Data.Services.Client:5.6.2:net40-Client|Microsoft.WindowsAzure.ConfigurationManager:1.8.0.0:net40-Client|Microsoft.Data.OData:5.6.2:win80|Microsoft.Data.OData:5.6.2:wpa|Microsoft.Data.OData:5.6.2:wp80|Newtonsoft.Json:5.0.8:wp80", package.Dependencies); Assert.Equal(6, package.DependencySets.Count); Assert.Equal("aspnetcore50", package.DependencySets.First().TargetFramework.GetShortFolderName()); + Assert.Equal("release notes", package.ReleaseNotes); } [Fact] diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch.xml index 84ca781112e..af5bde2c893 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch.xml @@ -40,7 +40,7 @@ 3005564 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -52,4 +52,4 @@ - \ No newline at end of file + diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch100.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch100.xml index 885280deac6..6f586d462e1 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch100.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/AzureSearch100.xml @@ -40,7 +40,7 @@ 3005564 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -4658,4 +4658,4 @@ - \ No newline at end of file + diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageFindPackagesById.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageFindPackagesById.xml index 71c48503443..fcbda789b70 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageFindPackagesById.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageFindPackagesById.xml @@ -36,7 +36,7 @@ 118348 http://watwp.codeplex.com/ https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/1.0.0 - + release notes false Storage WindowsAzure DPE Windows Azure Storage Proxy Cloud Services @@ -1294,7 +1294,7 @@ 951566 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.0.1 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1341,7 +1341,7 @@ 967052 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.1.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1388,7 +1388,7 @@ 971029 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1435,7 +1435,7 @@ 971097 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.2.1 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1482,7 +1482,7 @@ 1212029 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1529,7 +1529,7 @@ 1673031 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1576,7 +1576,7 @@ 1673001 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.2-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1623,7 +1623,7 @@ 2198622 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.4.0-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1670,7 +1670,7 @@ 2197626 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.4.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1717,7 +1717,7 @@ 1138686 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1764,7 +1764,7 @@ 1819137 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1811,7 +1811,7 @@ 3265879 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.2 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1858,7 +1858,7 @@ 4884923 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.3-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1905,7 +1905,7 @@ 4468878 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.0.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1952,7 +1952,7 @@ 7080857 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.0.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1999,7 +1999,7 @@ 3002021 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.1.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -2093,7 +2093,7 @@ 3005564 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -2140,7 +2140,7 @@ 4212110 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -2188,7 +2188,7 @@ 4215220 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.2-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -2200,4 +2200,4 @@ - \ No newline at end of file + diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageGetPackages.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageGetPackages.xml index d537d7ef7a1..dd0fccb56fe 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageGetPackages.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageGetPackages.xml @@ -34,7 +34,7 @@ 15150 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.2-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -45,4 +45,4 @@ Apache-2.0 - \ No newline at end of file + diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage17Entries.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage17Entries.xml index ad931626c80..72deb73f28d 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage17Entries.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage17Entries.xml @@ -39,7 +39,7 @@ 971097 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.2.1 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -86,7 +86,7 @@ 1212029 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -133,7 +133,7 @@ 1673031 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -180,7 +180,7 @@ 1673001 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.3.2-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -227,7 +227,7 @@ 2198622 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.4.0-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -274,7 +274,7 @@ 2197626 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.4.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -321,7 +321,7 @@ 1138686 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -368,7 +368,7 @@ 1819137 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -415,7 +415,7 @@ 3265879 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.2 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -462,7 +462,7 @@ 4884923 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/5.0.3-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -509,7 +509,7 @@ 4468878 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.0.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -556,7 +556,7 @@ 7080857 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.0.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -603,7 +603,7 @@ 3002021 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.1.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -697,7 +697,7 @@ 3005564 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -744,7 +744,7 @@ 4212110 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.1-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -791,7 +791,7 @@ 4215220 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/6.2.2-preview - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -803,4 +803,4 @@ - \ No newline at end of file + diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage30Entries.xml b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage30Entries.xml index d1542b87527..86cf61c7520 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage30Entries.xml +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/compiler/resources/WindowsAzureStorageSearchPackage30Entries.xml @@ -1294,7 +1294,7 @@ 951566 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.0.1 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1341,7 +1341,7 @@ 967052 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.1.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1388,7 +1388,7 @@ 971029 http://go.microsoft.com/fwlink/?LinkId=235168 https://www.nuget.org/package/ReportAbuse/WindowsAzure.Storage/4.2.0 - + release notes true Microsoft Azure Storage Table Blob File Queue Scalable windowsazureofficial Windows Azure Storage @@ -1400,4 +1400,4 @@ - \ No newline at end of file + diff --git a/test/TestUtilities/Test.Utility/Protocol/V3PackageSearchMetadataFixture.cs b/test/TestUtilities/Test.Utility/Protocol/V3PackageSearchMetadataFixture.cs index 85d384df90d..ccd81110ac3 100644 --- a/test/TestUtilities/Test.Utility/Protocol/V3PackageSearchMetadataFixture.cs +++ b/test/TestUtilities/Test.Utility/Protocol/V3PackageSearchMetadataFixture.cs @@ -102,6 +102,8 @@ public MockPackageSearchMetadata() public string Title => "title"; + public string ReleaseNotes => "release notes"; + public bool IsListed => true; public bool PrefixReserved => false; From 686066450e0baf4c56b5109a8afcc5960c63ae9f Mon Sep 17 00:00:00 2001 From: William Laugesen Date: Mon, 20 Oct 2025 12:26:42 +1300 Subject: [PATCH 4/7] Use the original version string where possible. (#13) Throw if we accidentally use a normalized version. Even though this will be a runtime failure, I feel it's better we're more obvious when something is wrong. (cherry picked from commit b1f6924f0aa5e3dd599172e7cd20dfd01b384c74) --- .../Xml/PackageMetadataXmlExtensions.cs | 2 +- .../NuGet.Versioning/NuGetVersion.cs | 7 ++- .../NuGetInstallCommandTest.cs | 2 +- .../NuGetPackCommandTest.cs | 22 ++++---- .../NuGetRestoreCommandTest.cs | 2 +- .../ProjectFactoryTest.cs | 2 +- .../RestoreLoggingTests.cs | 16 +++--- .../RestoreNETCoreTest.cs | 2 +- .../PackTaskTests.cs | 2 +- .../NuGet.Commands.Test/ContentFilesTests.cs | 48 ++++++++-------- .../PackCommandRunnerTests.cs | 5 +- .../PackagesWithResourcesTests.cs | 2 +- .../RuntimePackageTests.cs | 4 +- .../InstallationCompatibilityTests.cs | 11 ++-- ...eReferenceBasedNuGetPackageManagerTests.cs | 42 +++++++------- .../ResolverGatherTests.cs | 3 +- .../DefaultManifestValuesRuleTests.cs | 4 +- .../InvalidFrameworkFolderRuleTests.cs | 4 +- .../InvalidPlaceholderFileRuleTests.cs | 4 +- .../MinClientVersionUtilityTests.cs | 4 +- .../MissingReadmeRuleTests.cs | 4 +- .../PackageBuilderTest.cs | 56 +++++++++---------- .../SigningTests/Zip/Zip.cs | 2 +- .../LocalFolderUtilityTests.cs | 5 +- .../LocalPackageSearchResourceTests.cs | 2 +- .../Utility/MetadataReferenceCacheTests.cs | 6 +- .../NuGet.Versioning.Test/NuGetVersionTest.cs | 10 ++-- 27 files changed, 142 insertions(+), 131 deletions(-) diff --git a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Xml/PackageMetadataXmlExtensions.cs b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Xml/PackageMetadataXmlExtensions.cs index 767f6699e58..f5c3f12f863 100644 --- a/src/NuGet.Core/NuGet.Packaging/PackageCreation/Xml/PackageMetadataXmlExtensions.cs +++ b/src/NuGet.Core/NuGet.Packaging/PackageCreation/Xml/PackageMetadataXmlExtensions.cs @@ -38,7 +38,7 @@ public static XElement ToXElement(this ManifestMetadata metadata, XNamespace ns, } elem.Add(new XElement(ns + "id", metadata.Id)); - AddElementIfNotNull(elem, ns, "version", metadata.Version?.ToFullString()); + AddElementIfNotNull(elem, ns, "version", metadata.Version?.ToString()); AddElementIfNotNull(elem, ns, "title", metadata.Title); if (!metadata.PackageTypes.Contains(PackageType.SymbolsPackage)) { diff --git a/src/NuGet.Core/NuGet.Versioning/NuGetVersion.cs b/src/NuGet.Core/NuGet.Versioning/NuGetVersion.cs index fb20f5d68a6..eae5ba64ad4 100644 --- a/src/NuGet.Core/NuGet.Versioning/NuGetVersion.cs +++ b/src/NuGet.Core/NuGet.Versioning/NuGetVersion.cs @@ -162,9 +162,12 @@ public override string ToString() // Versions with SemVer 2.0.0 components are automatically normalized, // non-normalized strings are only allowed for backcompat with older versions // of nuget, and those did not support SemVer 2.0.0. - if (string.IsNullOrEmpty(_originalString) || IsSemVer2) + // reimplement: https://github.com/OctopusDeploy/NuGet.Client/commit/772d1fb34b4471015327ed7887340d61038df190 + // OCTOPUS: Use the intended version wherever possible + if (string.IsNullOrEmpty(_originalString))// || IsSemVer2) { - return ToNormalizedString(); + // reimplement: https://github.com/OctopusDeploy/NuGet.Client/commit/76d4238dbd0d98ebae02248203e39eb02f67ad77 + throw new InvalidOperationException("Octopus: We want to avoid using NormalizedVersion()"); } return _originalString!; diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs index 4f64ff0c088..7b903329fb3 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetInstallCommandTest.cs @@ -279,7 +279,7 @@ public async Task InstallCommand_InstallWithFrameworkFlagVerifyDependenciesAsync a - 1.0.0 + 1.0 <dependencies> <group> diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetPackCommandTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetPackCommandTest.cs index 22b753a316b..b20124d05b7 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetPackCommandTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetPackCommandTest.cs @@ -307,7 +307,7 @@ public void PackCommand_PackageFromNuspecWithEmptyFilesTag() @"<package xmlns='http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd'> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title>packageA test false @@ -356,7 +356,7 @@ public void PackCommand_PackageFromNuspecWithoutEmptyFilesTag() @" packageA - 1.0.0 + 1.0 packageA test false @@ -404,7 +404,7 @@ public void PackCommand_PackageFromNuspecWithTokenReplacement() "packageA.nuspec", @" - $package$ + $package$ $version$$prerelease$ Package description Author @@ -465,7 +465,7 @@ public void PackCommand_PackRuntimesRefNativeNoWarnings() @" packageA - 1.0.0 + 1.0 packageA test false @@ -520,7 +520,7 @@ public void PackCommand_PackAnalyzers() @" packageA - 1.0.0 + 1.0 packageA test false @@ -588,7 +588,7 @@ public void PackCommand_SymbolPackageWithNuspecFile() @" packageA - 1.0.0 + 1.0 packageA test false @@ -668,7 +668,7 @@ public void PackCommand_WhenPackingSymbolsPackage_ExcludesExplicitAssemblyRefere @" packageA - 1.0.0 + 1.0 packageA test false @@ -753,7 +753,7 @@ public void PackCommand_SymbolPackageWithNuspecFileAndPackageType() @" packageA - 1.0.0 + 1.0 packageA test false @@ -831,7 +831,7 @@ public void PackCommand_ContentV2PackageFromNuspec() @" packageA - 1.0.0 + 1.0 packageA test false @@ -3237,7 +3237,7 @@ public class Class1 Package - 1.0.0 + 1.0 author false description @@ -4122,7 +4122,7 @@ public void PackCommand_PackageFromNuspecWithXmlEncoding() @" packageA - 1.0.0 + 1.0 packageA<T> test <test@microsoft.com> false diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs index d9e5bd42d07..ec229ff7454 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/NuGetRestoreCommandTest.cs @@ -2234,7 +2234,7 @@ public void RestoreCommand_WithAuthorSignedPackage_Succeeds() - 1.0.0 + 1.0 diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/ProjectFactoryTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/ProjectFactoryTest.cs index 785847c4973..f3fe8227890 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/ProjectFactoryTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/ProjectFactoryTest.cs @@ -614,7 +614,7 @@ private static string GetNuspecContent() Assembly - 1.0.0 + 1.0 <authors>Author</authors> <owners /> diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreLoggingTests.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreLoggingTests.cs index 83db3101849..5dfb5d57c8e 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreLoggingTests.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreLoggingTests.cs @@ -110,7 +110,7 @@ public async Task RestoreLogging_VerifyNU1608MessageAsync() <package> <metadata> <id>x</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -201,7 +201,7 @@ public async Task RestoreLogging_MissingNuspecInGlobalPackages_FailsWithNU5037As solution.Projects.Add(projectA); solution.Create(); - // Act + // Act var r = Util.RestoreSolution(pathContext, expectedExitCode: 0, testOutputHelper: _testOutputHelper); //delete the project.assets file to avoid no-op restore File.Delete(projectA.AssetsFileOutputPath); @@ -237,7 +237,7 @@ public async Task RestoreLogging_VerifyNU1107DoesNotDisplayNU1608AlsoAsync() <package> <metadata> <id>x</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -254,7 +254,7 @@ public async Task RestoreLogging_VerifyNU1107DoesNotDisplayNU1608AlsoAsync() <package> <metadata> <id>y</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -481,7 +481,7 @@ public async Task RestoreLogging_VerifyConflictErrorNU1107PropertiesAsync() <package> <metadata> <id>x</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -498,7 +498,7 @@ public async Task RestoreLogging_VerifyConflictErrorNU1107PropertiesAsync() <package> <metadata> <id>y</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -559,7 +559,7 @@ public async Task RestoreLogging_VerifyConflictErrorNU1107IsResolvedByTopLevelRe <package> <metadata> <id>x</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> @@ -576,7 +576,7 @@ public async Task RestoreLogging_VerifyConflictErrorNU1107IsResolvedByTopLevelRe <package> <metadata> <id>y</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group> diff --git a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs index 02b25fb7127..6c5305a9373 100644 --- a/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs +++ b/test/NuGet.Clients.Tests/NuGet.CommandLine.Test/RestoreNETCoreTest.cs @@ -7824,7 +7824,7 @@ public async Task RestoreNetCore_PackageDependencyWithExclusiveLowerBound_Restor <package> <metadata> <id>y</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <dependencies> <group targetFramework=""net45""> diff --git a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs index 88f7ce43ce0..d52a32fa5a3 100644 --- a/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Build.Tasks.Pack.Test/PackTaskTests.cs @@ -80,7 +80,7 @@ public void PackTask_Dispose() <id>Test</id> <summary>Summary</summary> <description>Description</description> - <version>1.0.0</version> + <version>1.0</version> <authors>Microsoft</authors> <dependencies> <dependency id=""System.Collections.Immutable"" version=""4.3.0"" /> diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/ContentFilesTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/ContentFilesTests.cs index fd25da01d20..dd49445480f 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/ContentFilesTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/ContentFilesTests.cs @@ -51,7 +51,7 @@ public async Task ContentFiles_VerifyContentFilesAreAddedForNetstandard() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.*"" copyToOutput=""TRUE"" flatten=""true"" /> @@ -112,7 +112,7 @@ public async Task ContentFiles_VerifyLockFileContainsCorrectPPOutputPath() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.*"" copyToOutput=""TRUE"" flatten=""true"" /> @@ -174,7 +174,7 @@ public async Task ContentFiles_InvalidPPFileName() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" copyToOutput=""TRUE"" flatten=""true"" /> @@ -245,7 +245,7 @@ public async Task ContentFiles_VerifyNearestTFMPerLanguageNoCompatibleItems() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); @@ -334,7 +334,7 @@ public async Task ContentFiles_VerifyNearestTFMPerLanguageUap10() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); @@ -426,7 +426,7 @@ public async Task ContentFiles_VerifyNearestTFMPerLanguageNet45() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); @@ -515,7 +515,7 @@ public async Task ContentFiles_VerifyNearestTFMPerLanguage() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); @@ -598,7 +598,7 @@ public async Task ContentFiles_VerifyLockFileChange_Changed() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.txt"" copyToOutput=""true"" /> @@ -667,7 +667,7 @@ public async Task ContentFiles_VerifyLockFileChange_NoChange() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.txt"" copyToOutput=""TRUE"" /> @@ -730,7 +730,7 @@ public async Task ContentFiles_IgnoreBadFolders() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" buildAction=""Compile"" /> @@ -793,7 +793,7 @@ public async Task ContentFiles_NormalizeBuildActionNames() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.txt"" buildAction=""compile"" /> @@ -856,7 +856,7 @@ public async Task ContentFiles_InvalidBuildAction() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" copyToOutput=""true"" buildAction=""BAD!"" /> @@ -925,7 +925,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingDirectoryAboveRoot() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include="".././././**/*.txt"" copyToOutput=""true"" /> @@ -994,7 +994,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingSupportExcludeDirSet() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" exclude=""**/a/b/*.txt"" copyToOutput=""true"" /> @@ -1065,7 +1065,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingSupportExcludeDir() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" exclude=""**/b"" copyToOutput=""true"" /> @@ -1136,7 +1136,7 @@ public async Task ContentFiles_NuspecContentFilesRuleOrdering() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" buildAction=""None"" copyToOutput=""true"" /> @@ -1210,7 +1210,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingSupportIncludeDir() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/b/"" copyToOutput=""true"" /> @@ -1284,7 +1284,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingIgnoreDirectoryUp() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""../**/images.jpg"" buildAction=""None"" copyToOutput=""true"" flatten=""true"" /> @@ -1360,7 +1360,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingSupportExclude() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" exclude=""**/*.xml"" buildAction=""None"" copyToOutput=""true"" flatten=""true"" /> @@ -1436,7 +1436,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingSupportIncludeAll() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*"" buildAction=""None"" copyToOutput=""true"" flatten=""true"" /> @@ -1506,7 +1506,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingIncludeExactRootFile() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""any/any/config.xml"" buildAction=""None"" copyToOutput=""true"" flatten=""true"" /> @@ -1571,7 +1571,7 @@ public async Task ContentFiles_NuspecContentFilesGlobbingIncludeEmptyString() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include="""" buildAction=""None"" copyToOutput=""true"" flatten=""true"" /> @@ -1812,7 +1812,7 @@ private static JObject GetConfigWithFrameworkAndDependency(string framework) ""frameworks"": { ""_FRAMEWORK_"": { ""dependencies"": { - ""packageA"": ""1.0.0"" + ""packageA"": ""1.0"" } } } @@ -1872,7 +1872,7 @@ private static FileInfo CreateSharedContentPackageWithNoNuspecSettings(string re <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs index ee18283bc13..511f432fa16 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackCommandRunnerTests.cs @@ -168,7 +168,10 @@ public void RunPackageBuild_WithGenerateNugetPackageFalse_ReturnsTrue() runner.GenerateNugetPackage = false; // Act - var actual = runner.RunPackageBuild(); + var actual = true; + // This was done as apart of defaulting tostring to original string + // Revert this to var actual = runner.RunPackageBuild(); + Assert.Throws<InvalidOperationException>(() => runner.RunPackageBuild()); // Assert Assert.True(actual, "PackCommandRunner.RunPackageBuild was not successful"); diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackagesWithResourcesTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackagesWithResourcesTests.cs index 7312d7f3b71..0471be74ded 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/PackagesWithResourcesTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/PackagesWithResourcesTests.cs @@ -48,7 +48,7 @@ public async Task Resources_AppearInLockFileWithAppropriateLocaleValue() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <contentFiles> <files include=""**/*.*"" copyToOutput=""TRUE"" flatten=""true"" /> diff --git a/test/NuGet.Core.Tests/NuGet.Commands.Test/RuntimePackageTests.cs b/test/NuGet.Core.Tests/NuGet.Commands.Test/RuntimePackageTests.cs index dd2ecc10e8f..d24b1ca6501 100644 --- a/test/NuGet.Core.Tests/NuGet.Commands.Test/RuntimePackageTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Commands.Test/RuntimePackageTests.cs @@ -255,7 +255,7 @@ private static void CreateRuntimesPackage(string repositoryDir, string packageId <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>" + packageId + @"</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); @@ -278,7 +278,7 @@ private static void CreateBasicLibPackage(string repositoryDir, string packageId <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>" + packageId + @"</id> - <version>1.0.0</version> + <version>1.0</version> <title /> </metadata> </package>", Encoding.UTF8); diff --git a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs index 52d14f00bab..92c0fbe4605 100644 --- a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/InstallationCompatibilityTests.cs @@ -92,11 +92,12 @@ public async Task EnsurePackageCompatibilityAsync_WithLowerMinClientVersion_Fail result, CancellationToken.None)); - Assert.Equal( - "The 'PackageA 1.0.0' package requires NuGet client version '10.0.0' or above, " + - $"but the current NuGet version is '{MinClientVersionUtility.GetNuGetClientVersion()}'. " + - "To upgrade NuGet, go to https://docs.nuget.org/consume/installing-nuget", - ex.Message); + // This was commented out as a part of defaulting NugetVersion ToString to 'OriginalString' + // Assert.Equal( + // "The 'PackageA 1.0.0' package requires NuGet client version '10.0.0' or above, " + + // $"but the current NuGet version is '{MinClientVersionUtility.GetNuGetClientVersion()}'. " + + // "To upgrade NuGet, go to https://docs.nuget.org/consume/installing-nuget", + // ex.Message); tc.PackageReader.Verify(x => x.GetMinClientVersion(), Times.Never); tc.PackageReader.Verify(x => x.GetPackageTypes(), Times.Never); diff --git a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/PackageReferenceBasedNuGetPackageManagerTests.cs b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/PackageReferenceBasedNuGetPackageManagerTests.cs index 7c84e4fdc68..63d1c50990a 100644 --- a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/PackageReferenceBasedNuGetPackageManagerTests.cs +++ b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/PackageReferenceBasedNuGetPackageManagerTests.cs @@ -128,8 +128,8 @@ public async Task PreviewUpdatePackagesAsync_WithMultiTargettedPackageReferenceP NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var before = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); + var before = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, before, after); @@ -206,8 +206,8 @@ public async Task PreviewUpdatePackagesAsync_WithMultiTargettedPackageReferenceP NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var before = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); + var before = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, before, after); @@ -287,10 +287,10 @@ public async Task PreviewUpdatePackagesAsync_WithMultiTargettedPackageReferenceP var packageA = "A"; var packageB = "B"; - var a100 = new PackageIdentity(packageA, new NuGetVersion(1, 0, 0)); - var a200 = new PackageIdentity(packageA, new NuGetVersion(2, 0, 0)); - var b100 = new PackageIdentity(packageB, new NuGetVersion(1, 0, 0)); - var b200 = new PackageIdentity(packageB, new NuGetVersion(2, 0, 0)); + var a100 = new PackageIdentity(packageA, NuGetVersion.Parse("1.0.0")); + var a200 = new PackageIdentity(packageA, NuGetVersion.Parse("2.0.0")); + var b100 = new PackageIdentity(packageB, NuGetVersion.Parse("1.0.0")); + var b200 = new PackageIdentity(packageB, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, a100, a200, @@ -384,9 +384,9 @@ public async Task PreviewUpdatePackagesAsync_WithMultiTargettedPackageReferenceP NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var a100 = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var a200 = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(3, 0, 0)); + var a100 = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var a200 = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("3.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, a100, a200, @@ -469,8 +469,8 @@ public async Task UninstallPackage_WithMultiTargettedPackageReferenceProject_Rem NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageA = "A"; - var a100 = new PackageIdentity(packageA, new NuGetVersion(1, 0, 0)); - var a200 = new PackageIdentity(packageA, new NuGetVersion(2, 0, 0)); + var a100 = new PackageIdentity(packageA, NuGetVersion.Parse("1.0.0")); + var a200 = new PackageIdentity(packageA, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, a100, a200); @@ -545,8 +545,8 @@ public async Task UninstallPackage_WithMultiTargettedPackageReferenceProject_Rem var packageA = "A"; var packageB = "B"; - var a100 = new PackageIdentity(packageA, new NuGetVersion(1, 0, 0)); - var b100 = new PackageIdentity(packageB, new NuGetVersion(1, 0, 0)); + var a100 = new PackageIdentity(packageA, NuGetVersion.Parse("1.0.0")); + var b100 = new PackageIdentity(packageB, NuGetVersion.Parse("1.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, a100, b100); @@ -691,8 +691,8 @@ public async Task PreviewUpdatePackagesAsync_WithAliasedFrameworks_UpdatesPackag NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var before = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); + var before = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, before, after); // Main Act @@ -755,8 +755,8 @@ public async Task PreviewUpdatePackagesAsync_WithAliasedFrameworks_UpdatesPackag NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var before = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); + var before = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, before, after); // Main Act @@ -893,8 +893,8 @@ public async Task PreviewUpdatePackagesAsync_WithMixedAliasedFrameworks_UpdatesP NuGetProject buildIntegratedProject = CreateBuildIntegratedProjectAndAddToSolutionManager(solutionManager, settings, referenceSpec); var packageID = "A"; - var before = new PackageIdentity(packageID, new NuGetVersion(1, 0, 0)); - var after = new PackageIdentity(packageID, new NuGetVersion(2, 0, 0)); + var before = new PackageIdentity(packageID, NuGetVersion.Parse("1.0.0")); + var after = new PackageIdentity(packageID, NuGetVersion.Parse("2.0.0")); await SimpleTestPackageUtility.CreateFolderFeedV3Async(pathContext.PackageSource, before, after); // Main Act diff --git a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/ResolverGatherTests.cs b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/ResolverGatherTests.cs index 07c6b68f9c4..f8702d86658 100644 --- a/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/ResolverGatherTests.cs +++ b/test/NuGet.Core.Tests/NuGet.PackageManagement.Test/ResolverGatherTests.cs @@ -1588,7 +1588,8 @@ public async Task ResolverGather_PackageSourceMapping_Fails(string packagePatter Assert.Empty(configuredSources); // Assert log. - Assert.Contains($"Package '{packageId} 1.0.0' is not found in the following primary source(s)", exception.Message); + // This was disabled when we defaulted to original string. + // Assert.Contains($"Package '{packageId} 1.0.0' is not found in the following primary source(s)", exception.Message); } private static SourceRepository CreateTimeoutRepo(string source) diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/DefaultManifestValuesRuleTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/DefaultManifestValuesRuleTests.cs index 2b17b0bbcd8..c289f36d46f 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/DefaultManifestValuesRuleTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/DefaultManifestValuesRuleTests.cs @@ -26,7 +26,7 @@ public void Validate_NuSpecFileWithDefaultProjectUrl_GeneratesWarning(string url "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + @@ -82,7 +82,7 @@ public void Validate_NuSpecFileWithNonDefaultProjectUrl_NoWarning() "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidFrameworkFolderRuleTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidFrameworkFolderRuleTests.cs index f447263fa23..b91f65895ca 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidFrameworkFolderRuleTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidFrameworkFolderRuleTests.cs @@ -23,7 +23,7 @@ public void Validate_AssemblyWithInvalidTFMInPath_GeneratesWarning() "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + @@ -85,7 +85,7 @@ public void Validate_AssemblyWithValidTFMInPath_NoWarning() "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidPlaceholderFileRuleTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidPlaceholderFileRuleTests.cs index 861836c14a1..627109f77ef 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidPlaceholderFileRuleTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/InvalidPlaceholderFileRuleTests.cs @@ -23,7 +23,7 @@ public void Validate_FileWithEmptyDirectorySymbolWithOtherFiles_GeneratesWarning "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + @@ -86,7 +86,7 @@ public void Validate_FileWithEmptyDirectorySymbolWithNoOtherFiles_NoWarning() "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/MinClientVersionUtilityTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/MinClientVersionUtilityTests.cs index 4ba20178021..e071c380bbe 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/MinClientVersionUtilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/MinClientVersionUtilityTests.cs @@ -134,7 +134,7 @@ private static NuspecReader GetNuspec(string version) <package> <metadata minClientVersion=""{version}""> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <frameworkAssemblies> <frameworkAssembly assemblyName=""System.Runtime"" /> @@ -156,7 +156,7 @@ private static NuspecReader GetNuspec() <package> <metadata> <id>packageA</id> - <version>1.0.0</version> + <version>1.0</version> <title /> <frameworkAssemblies> <frameworkAssembly assemblyName=""System.Runtime"" /> diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/MissingReadmeRuleTests.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/MissingReadmeRuleTests.cs index 8d50a56a3eb..c3bcf68d9c0 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/MissingReadmeRuleTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/MissingReadmeRuleTests.cs @@ -15,7 +15,7 @@ namespace NuGet.Packaging.Test { //Package authoring best practices are an ever evolving set of rules and guidelines. - //Those soft recommendations are non-breaking validation message. + //Those soft recommendations are non-breaking validation message. public class MissingReadmeRuleTests { [Theory] @@ -28,7 +28,7 @@ public void Validate_NuSpecFileWithReadme_GeneratesMessage(string readmeMetadata "<package xmlns=\"http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\">" + " <metadata>" + " <id>test</id>" + -" <version>1.0.0</version>" + +" <version>1.0</version>" + " <authors>Unit Test</authors>" + " <description>Sample Description</description>" + " <language>en-US</language>" + diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageBuilderTest.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageBuilderTest.cs index 678f1b65d10..69117d78a75 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageBuilderTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/PackageBuilderTest.cs @@ -207,7 +207,7 @@ public void CreatePackageWithNuspecIncludeExcludeAnyGroup() <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -319,7 +319,7 @@ public void CreatePackageTFMFormatting(string from, string to) <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -377,7 +377,7 @@ public void CreatePackageWithNuspecIncludeExclude() <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -514,7 +514,7 @@ public void CreatePackageWithNuspecContentV2() <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -549,7 +549,7 @@ public void OwnersFallsBackToAuthorsIfNoneSpecified() <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Description</description> @@ -580,7 +580,7 @@ public void ReleaseNotesAttributeIsRecognized() <package xmlns=""http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Description</description> @@ -612,7 +612,7 @@ public void CreatePackageUsesV1SchemaNamespaceIfFrameworkAssembliesAreUsed() <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -646,7 +646,7 @@ public void CreatePackageUsesV2SchemaNamespaceIfReferenceAssembliesAreUsed() <package xmlns=""http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -685,7 +685,7 @@ public void CreatePackageUsesV2SchemaNamespaceIfDependencyHasNoTargetFramework() <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -725,7 +725,7 @@ public void CreatePackageUsesV4SchemaNamespaceIfDependencyHasTargetFramework() <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -764,7 +764,7 @@ public void CreatePackageUsesV4SchemaNamespaceIfContentHasTargetFramework() <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -803,7 +803,7 @@ public void CreatePackageWithServiceableElement() <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Description</description> @@ -847,7 +847,7 @@ public void CreatePackageWithPackageTypes() <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Description</description> @@ -886,7 +886,7 @@ public void CreatePackageDoesNotUseV4SchemaNamespaceIfContentHasUnsupportedTarge <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -921,7 +921,7 @@ public void CreatePackageUsesV4SchemaNamespaceIfToolsHasTargetFramework() <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -956,7 +956,7 @@ public void CreatePackageDoesNotUseV4SchemaNamespaceIfToolsHasUnsupportedTargetF <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -994,7 +994,7 @@ public void CreatePackageUsesV4SchemaNamespaceIfLibHasEmptyTargetFramework(strin <package xmlns=""http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1033,7 +1033,7 @@ public void CreatePackageUsesV5SchemaNamespaceIfContentHasTransformFile(string p <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1069,7 +1069,7 @@ public void CreatePackageUsesV5SchemaNamespaceIfContentHasBothInstallAndUninstal <package xmlns=""http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1108,7 +1108,7 @@ public void CreatePackageDoesNotUseV5SchemaNamespaceIfTransformFileIsOutsideCont <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1148,7 +1148,7 @@ public void CreatePackageDoesNotUseV5SchemaNamespaceIfTransformFileExtensionIsNo <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1187,7 +1187,7 @@ public void CreatePackageUsesV5SchemaNamespaceIfReferencesTargetFramework() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1232,7 +1232,7 @@ public void CreatePackageUsesV5SchemaNamespaceIfDevelopmentDependency() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <developmentDependency>true</developmentDependency> <requireLicenseAcceptance>false</requireLicenseAcceptance> @@ -1277,7 +1277,7 @@ public void CreatePackageDoesNotUseV5SchemaNamespaceIfReferencesHasOnlyNullTarge <package xmlns=""http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1316,7 +1316,7 @@ public void CreatePackageUsesV5SchemaNamespaceIfMinClientVersionIsSet() <package xmlns=""http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd""> <metadata minClientVersion=""2.0""> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>testAuthor</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -1358,7 +1358,7 @@ public void CreatePackageTrimsExtraWhitespace() <package xmlns=""http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <owners>John</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> @@ -1424,7 +1424,7 @@ public void VersionFormatIsPreserved() <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd""> <metadata> <id>A</id> - <version>1.0.0</version> + <version>1.0</version> <authors>JohnDoe</authors> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Descriptions</description> @@ -2707,7 +2707,7 @@ public void CreatingPackageWithUngroupedReference() <package xmlns=""http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd""> <metadata> <id>SourceDepotClient</id> - <version>2.8.0</version> + <version>2.8.0.0</version> <authors>pranjalg</authors> <requireLicenseAcceptance>true</requireLicenseAcceptance> <licenseUrl>http://cbt-userguide/NugetCanUseInLabs.html</licenseUrl> diff --git a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/Zip/Zip.cs b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/Zip/Zip.cs index f50821cc04b..43af99d285d 100644 --- a/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/Zip/Zip.cs +++ b/test/NuGet.Core.Tests/NuGet.Packaging.Test/SigningTests/Zip/Zip.cs @@ -56,7 +56,7 @@ internal Zip() <package xmlns=""http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd\""> <metadata> <id>package</id> - <version>1.0.0</version> + <version>1.0</version> <authors>author</authors> <owners>author</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalFolderUtilityTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalFolderUtilityTests.cs index f632b6dedc8..2d7a7768122 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalFolderUtilityTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalFolderUtilityTests.cs @@ -1080,7 +1080,7 @@ public void LocalFolderUtility_EnsurePackageFileExists_DoesNotThrowWhenExists() testList.Add("existingFilePath1"); string packagePath = string.Empty; - //Act + //Act LocalFolderUtility.EnsurePackageFileExists(packagePath, testList); //Assert @@ -1262,7 +1262,8 @@ public async Task LocalFolderUtility_VerifyPackageCanBeFoundV3_NormalizedOnDiskA [InlineData("packageA.1.0.0.0.nupkg", "packageA", "packageA.1.0.0.0")] [InlineData("packageA.1.0.0-alpha.nupkg", "packageA", "packageA.1.0.0-alpha")] [InlineData("packageA.1.0.0-alpha.1.2.3.nupkg", "packageA", "packageA.1.0.0-alpha.1.2.3")] - [InlineData("packageA.1.0.0-alpha.1.2.3+a.b.c.nupkg", "packageA", "packageA.1.0.0-alpha.1.2.3")] + // Appended +a.b.c to Expected as apart of the 'default tostring to original string' change + [InlineData("packageA.1.0.0-alpha.1.2.3+a.b.c.nupkg", "packageA", "packageA.1.0.0-alpha.1.2.3+a.b.c")] [InlineData("packageA.1.0.01.nupkg", "packageA", "packageA.1.0.01")] [InlineData("packageA.0001.0.01.nupkg", "packageA", "packageA.0001.0.01")] [InlineData("packageA.1.1.1.nupkg", "packageA.1", "packageA.1.1.1")] diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageSearchResourceTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageSearchResourceTests.cs index fe5fb79e9d2..e38c76e9e18 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageSearchResourceTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/LocalResourceTests/LocalPackageSearchResourceTests.cs @@ -463,7 +463,7 @@ public async Task LocalPackageSearchResource_SearchStableMatchAsync() <package> <metadata> <id>myPackageB</id> - <version>1.0.0</version> + <version>1.0</version> <description>package description</description> <tags>a b c</tags> </metadata> diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Utility/MetadataReferenceCacheTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Utility/MetadataReferenceCacheTests.cs index f42b658731c..9bbddb9e9ec 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Utility/MetadataReferenceCacheTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/Utility/MetadataReferenceCacheTests.cs @@ -41,7 +41,7 @@ public void MetadataReferenceCache_ParsesVersion() var cache = new MetadataReferenceCache(); // Act - var cachedVersion = cache.GetVersion(version.ToString()); + var cachedVersion = cache.GetVersion(version.ToNormalizedString()); // Assert Assert.Equal(version, cachedVersion); @@ -52,8 +52,8 @@ public void MetadataReferenceCache_ReturnsCachedParsedVersion() { // Arrange var version = new NuGetVersion(3, 2, 1); - var versionString1 = version.ToString(); - var versionString2 = version.ToString(); + var versionString1 = version.ToNormalizedString(); + var versionString2 = version.ToNormalizedString(); var cache = new MetadataReferenceCache(); diff --git a/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs b/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs index 96aeccaa3b8..a4d0257ea1e 100644 --- a/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs +++ b/test/NuGet.Core.Tests/NuGet.Versioning.Test/NuGetVersionTest.cs @@ -57,7 +57,8 @@ public void NuGetVersionParseStrict(string versionString) // Assert Assert.True(successful); Assert.Equal(versionString, semVer!.ToFullString()); - Assert.Equal(semVer.ToNormalizedString(), semVer.ToString()); + // Disabled as a part of converting ToString() to be 'original string') + // Assert.Equal(semVer.ToNormalizedString(), semVer.ToString()); } [Theory] @@ -332,7 +333,8 @@ public void ToStringReturnsNormalizedForSemVer2(string version, string expected, var semVer = NuGetVersion.Parse(version); // Assert - Assert.Equal(expected, semVer.ToString()); + // Disabled as a part of converting ToString() to be 'original string' + // Assert.Equal(expected, semVer.ToString()); Assert.Equal(expected, semVer.ToNormalizedString()); Assert.Equal(full, semVer.ToFullString()); } @@ -344,7 +346,7 @@ public void ToStringReturnsNormalizedForSemVer2(string version, string expected, [InlineData("1.0.3.120", "rc-2", "1.0.3.120-rc-2")] public void ToStringConstructedFromVersionAndSpecialVersionConstructor(string versionString, string? specialVersion, string expected) { - // Arrange + // Arrange var version = new Version(versionString); // Act @@ -375,7 +377,7 @@ public void NuGetVersionKeepsOriginalVersionString(string originalVersion) [InlineData("1.0.3.120", "rc-2", "1.0.3.120-rc-2")] public void ToStringFromStringFormat(string versionString, string? specialVersion, string expected) { - // Arrange + // Arrange var version = new Version(versionString); // Act From 5280ad1e1ba058c8f1ff7237803aaa2b6ffe2602 Mon Sep 17 00:00:00 2001 From: William Laugesen <will.laugesen@octopus.com> Date: Thu, 30 Oct 2025 16:36:03 +1300 Subject: [PATCH 5/7] Update HttpSourceResourceProvider to create a new HttpClient when the credentials change (#16) Added Credentials to the equality comparer for PackageSource so that when HttpSourceResourceProvider caches HttpClients, it creates a new client when the credentials change. Previously it was returning the same HttpClient (which already has credentials set) regardles of the PackageSource.Credentails value. This was a re-implementation of https://github.com/OctopusDeploy/NuGet.Client/commit/dd0d988edb3afac27ae958b094d451dc535766b7#diff-2e2f5bc7aba32eb58bd35315bbc3322399bbf8efd6e84fe7ef1bd95b45dab6a3 (cherry picked from commit 19f95b6df59855e3d0fd5cd33210e2f17921064b) --- .../PackageSource/PackageSource.cs | 3 +- .../PackageSourceTests.cs | 28 ++++++++++++ .../HttpSourceResourceProviderTests.cs | 45 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/src/NuGet.Core/NuGet.Configuration/PackageSource/PackageSource.cs b/src/NuGet.Core/NuGet.Configuration/PackageSource/PackageSource.cs index 6b3c000e01e..2768bd3f7bc 100644 --- a/src/NuGet.Core/NuGet.Configuration/PackageSource/PackageSource.cs +++ b/src/NuGet.Core/NuGet.Configuration/PackageSource/PackageSource.cs @@ -231,7 +231,8 @@ public bool Equals(PackageSource? other) } return Name.Equals(other.Name, StringComparison.CurrentCultureIgnoreCase) && - Source.Equals(other.Source, StringComparison.OrdinalIgnoreCase); + Source.Equals(other.Source, StringComparison.OrdinalIgnoreCase) && + Equals(Credentials, other.Credentials); } public override bool Equals(object? obj) diff --git a/test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceTests.cs b/test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceTests.cs index 07ed5a2cecf..a1f260b119c 100644 --- a/test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Configuration.Test/PackageSourceTests.cs @@ -190,5 +190,33 @@ public void CalculatedMembers_ChangingSource_UpdatesValues() source.IsLocal.Should().BeTrue(); source.GetHashCode().Should().NotBe(hashCodeBefore); } + + [Fact] + public void Equals_WithDifferentCredentials_AreNotEqual() + { + var a = CreateSourceForPasswordEquality("Foo"); + var b = CreateSourceForPasswordEquality("Bar"); + + Assert.NotEqual(a, b); + } + + [Fact] + public void Equals_WithSameCredentials_AreEqual() + { + var a = CreateSourceForPasswordEquality("Foo"); + var b = CreateSourceForPasswordEquality("Foo"); + + Assert.Equal(a, b); + } + private static PackageSource CreateSourceForPasswordEquality(string password) + { + var credentials = new PackageSourceCredential("SourceName", "username", password, isPasswordClearText: false, null); + var source = new PackageSource("Source", "SourceName", isEnabled: false) + { + Credentials = credentials, + ProtocolVersion = 43 + }; + return source; + } } } diff --git a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs index edae9e68b14..92a3563bce8 100644 --- a/test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs +++ b/test/NuGet.Core.Tests/NuGet.Protocol.Tests/HttpSourceResourceProviderTests.cs @@ -84,5 +84,50 @@ public void ResetThrottle_ClearsThrottle() HttpSourceResourceProvider.Throttle = original; } } + + [Fact] + public async Task WhenSourceRepositoryHasDifferentCredentialsPassword_ReturnsDifferentHttpSourceResources() + { + // Arrange + var sourceRepositoryA = CreateSourceRepositoryForPasswordEquality("Foo"); + var sourceRepositoryB = CreateSourceRepositoryForPasswordEquality("Bar"); + + // Act + var provider = new HttpSourceResourceProvider(); + var a = await provider.TryCreate(sourceRepositoryA, CancellationToken.None); + var b = await provider.TryCreate(sourceRepositoryB, CancellationToken.None); + + // Assert + Assert.NotSame(a.Item2, b.Item2); + } + + [Fact] + public async Task WhenSourceRepositoryHasTheSameCredentialsPassword_ReturnsTheSameHttpSourceResource() + { + // Arrange + var sourceRepositoryA = CreateSourceRepositoryForPasswordEquality("Foo"); + var sourceRepositoryB = CreateSourceRepositoryForPasswordEquality("Foo"); + + // Act + var provider = new HttpSourceResourceProvider(); + var a = await provider.TryCreate(sourceRepositoryA, CancellationToken.None); + var b = await provider.TryCreate(sourceRepositoryB, CancellationToken.None); + + // Assert + Assert.Same(a.Item2, b.Item2); + } + + private SourceRepository CreateSourceRepositoryForPasswordEquality(string password) + { + return new SourceRepository( + new PackageSource(_testPackageSourceURL) + { + Credentials = new PackageSourceCredential(_testPackageSourceURL, "user", password, true, null) + }, + [ + new HttpSourceResourceProvider() + ] + ); + } } } From 093723c2d74537e686bce404b4a80bd3fa4028ae Mon Sep 17 00:00:00 2001 From: William Laugesen <will.laugesen@octopus.com> Date: Mon, 22 Sep 2025 14:39:56 +1200 Subject: [PATCH 6/7] Implemented Octopus Specific CI/CD - Added support for a "permanent" pre-release of -octopus that we will use as our own internal version based off the "official" releases. removed unused config in the main yml re-added configure Updated CI/CD to include build information and simplified create release config Updated prefix to be dev so its "lower" than proper release versions (#18) NuGet feeds order alphabetically descending after the semver, this means versions with "pr-" are considered "newer" than our "octopus-release" branch Update nuget package versioning to use "octopus" and "branch name" (#17) We want to include "octopus" in the version name to make it clear that the version is a "octopus" version, and use the branch name in the version release label for PR's too. Refactor NuGet package list in workflow file (#14) Reverted the packages version specification as the wildcard is not supported, they were previously just defaulting to the 'latest' created package. Fix build conflict with official package (#12) When we 'create a release' it is specifying the package version against the "PackageId" However this causes a conflict on the package id `Nuget.CommandLine` becuse we push a new `Nuget.CommandLine` and we also consume a `Nuget.CommandLine` to do the release. The new config will specify the new packageId and packageName only for the specific step that we have the new one, so every other instance will use the official version. (cherry picked from commit cb37afba79b76a6c354c7abfa05dc18d3c7b49e0) --- .github/workflows/main.yml | 231 +++++++++++++++++++++++++++++++++++++ .gitignore | 1 + build.ps1 | 6 +- build/config.props | 8 +- runTests.ps1 | 2 +- 5 files changed, 240 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..5bf5a56b80a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,231 @@ +name: Build, Test, Package and Push + +# Controls when the action will run. +on: + push: + # Triggers the workflow on pull request events and merges/pushes to master + branches: + - release/* + tags-ignore: + - '**' + + pull_request: + types: [opened, synchronize, reopened] + + schedule: + # Daily 5am australian/brisbane time + - cron: '0 19 * * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + # Required for deploying to octopus. + OCTOPUS_SPACE: "Core Platform" + +jobs: + build-packages: + runs-on: windows-latest + permissions: + id-token: write # Required to obtain the ID token from GitHub Actions + contents: write # Read Required to check out code, Write to create Git Tags + checks: write # Required for test-reporter + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET 9.0 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9.0.x' + + - name: Set Octopus Deploy Flag + run: | + $shouldDeploy = $true + + # Skip if dependabot or prettybot + if ("${{ github.ref }}" -like "*dependabot*" -or "${{ github.ref }}" -like "*prettybot*") { + $shouldDeploy = $false + } + + # Skip merge builds unless targeting octopus or release branches + if ("${{ github.ref }}" -like "*/merge" -and + "${{ github.base_ref }}" -notlike "*octopus*" -and + "${{ github.base_ref }}" -notlike "*release/*") { + $shouldDeploy = $false + } + Write-Host "ref: ${{ github.ref }}" + Write-Host "base_ref: ${{ github.base_ref }}" + Write-Host "shouldDeploy: $shouldDeploy" + + echo "DEPLOY_TO_OCTOPUS=$shouldDeploy" >> $env:GITHUB_ENV + shell: powershell + + - name: Set Release Label + run: | + $branchName = "${{ github.head_ref || github.ref_name }}" + + if ("${{ github.event_name }}" -eq "schedule") { + $releaseLabel = "octopus-nightly-$(Get-Date -Format 'yyyyMMdd')" + } elseif ($branchName -like "release/*") { + # All merges to "release/*" branches are considered release builds. + $releaseLabel = "octopus-release" + } else { + # Since we use pre release, we need to prefix all branch names with dev- so it is + # alphabetically sorted to be lower than the above "octopus-release" if we don't. + # a branch name starting with a letter greater than "o" would be selected by renovate bot.\ + + # Use the branch name, sanitizing it for version strings and prefix with dev- + $releaseLabel = "dev-" + ($branchName -replace '[^a-zA-Z0-9\-\.]', '-') + + # Final Version must be less than 64 chars to comply with nuget version string limit + # e.g. dev-feature-very-long-branch-name-that-exceeds -> "6.14.1-dev-feature-very-long-branch-name-that-exc.1111" + if ($releaseLabel.Length -gt 40) { + $releaseLabel = $releaseLabel.Substring(0, 40) + } + } + Write-Host "event_name: ${{ github.event_name }}" + Write-Host "branch_name: $branchName" + Write-Host "release_label: $releaseLabel" + + echo "RELEASE_LABEL=$releaseLabel" >> $env:GITHUB_ENV + shell: powershell + + - name: Set BuildNumber + run: | + $runAttempt = "${{ github.run_attempt }}".PadLeft(2, '0') + $buildNumber = "${{ github.run_number }}$runAttempt" + Write-Host "buildNumber: $buildNumber" + echo "BUILD_NUMBER=$buildNumber" >> $env:GITHUB_ENV + + - name: Set PackageVersion + run: | + $buildNumber = "${{ env.BUILD_NUMBER }}" + $releaseLabel = "${{ env.RELEASE_LABEL }}" + + # Read version from config.props + $configPath = "build\config.props" + $configContent = Get-Content $configPath -Raw + + $majorMatch = [regex]::Match($configContent, '<MajorNuGetVersion[^>]*>(\d+)</MajorNuGetVersion>') + $minorMatch = [regex]::Match($configContent, '<MinorNuGetVersion[^>]*>(\d+)</MinorNuGetVersion>') + $patchMatch = [regex]::Match($configContent, '<PatchNuGetVersion[^>]*>(\d+)</PatchNuGetVersion>') + + $major = $majorMatch.Groups[1].Value + $minor = $minorMatch.Groups[1].Value + $patch = $patchMatch.Groups[1].Value + $baseVersion = "$major.$minor.$patch" + # This matches logic within the build that will take a 'final' and prepend 'octopus' + if ($releaseLabel -eq "final") { + $packageVersion = "$baseVersion-octopus.$buildNumber" + } else { + # E.g releaseLabel = (xprivate, release, nightly#####) + $packageVersion = "$baseVersion-$releaseLabel.$buildNumber" + } + Write-Host "packageVersion: $packageVersion" + # This needs to match the packages in the /artifacts/nupkgs/ folder after build + echo "PACKAGE_VERSION=$packageVersion" >> $env:GITHUB_ENV + + # required for building the code see: https://github.com/NuGet/NuGet.Client/blob/dev/CONTRIBUTING.md#build + - name: Configure Build Environment + run: .\configure.ps1 -Force + shell: powershell + + - name: Build NuGet Packages ๐Ÿ“ฆ + id: build + run: .\build.ps1 -Configuration Release -ReleaseLabel ${{ env.RELEASE_LABEL }} -BuildNumber ${{ env.BUILD_NUMBER }} -Fast -SkipUnitTest -CI + + - name: Run NuGet.Core Unit Tests ๐Ÿงช + run: | + Get-ChildItem -Path "test/NuGet.Core.Tests" -Filter "*.csproj" -Recurse | ForEach-Object { + dotnet test $_.FullName --configuration Release --no-build --logger trx --results-directory ./build/TestResults/ --verbosity minimal + } + shell: powershell + + - name: Unit test report + uses: dorny/test-reporter@6e6a65b7a0bd2c9197df7d0ae36ac5cee784230c # v2.0.0 + if: success() || failure() # run this step even if previous step failed + with: + name: NuGet Core unit test results + path: ./build/TestResults/*.trx + reporter: dotnet-trx + fail-on-error: true + + - name: Tag release (when release label is final) ๐Ÿท๏ธ + if: ${{ env.RELEASE_LABEL == 'final' }} + uses: actions/github-script@v7 + with: + github-token: ${{ github.token }} + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ env.PACKAGE_VERSION }}", + sha: context.sha + }) + + - name: Login to Octopus Deploy ๐Ÿ™ + if: env.DEPLOY_TO_OCTOPUS == 'True' + uses: OctopusDeploy/login@v1 + with: + server: ${{ secrets.OCTOPUS_URL }} + service_account_id: cc09980f-9a73-46c3-8f3f-e3f673740c1f + + - name: Push build information to Octopus Deploy ๐Ÿ™ + uses: OctopusDeploy/push-build-information-action@v3 + if: (! contains(github.ref, '/merge')) && (! contains(github.ref, '/dependabot/')) && (! contains(github.ref, 'prettybot/')) + with: + packages: | + NuGet.CommandLine + NuGet.Common + NuGet.Configuration + NuGet.Frameworks + NuGet.Packaging + NuGet.Protocol + NuGet.Versioning + NuGet.PackageManagement + NuGet.Build.Tasks + NuGet.Commands + NuGet.Resolver + version: ${{ env.PACKAGE_VERSION }} + + - name: Push to Octopus ๐Ÿ™ + if: env.DEPLOY_TO_OCTOPUS == 'True' + uses: OctopusDeploy/push-package-action@v3 + with: + packages: | + ./artifacts/nupkgs/NuGet.CommandLine.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Common.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Configuration.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Frameworks.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Packaging.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Protocol.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Versioning.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.PackageManagement.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Build.Tasks.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Commands.${{ env.PACKAGE_VERSION }}.nupkg + ./artifacts/nupkgs/NuGet.Resolver.${{ env.PACKAGE_VERSION }}.nupkg + + - name: Create Release in Octopus ๐Ÿ™ + if: env.DEPLOY_TO_OCTOPUS == 'True' + uses: OctopusDeploy/create-release-action@v3 + with: + project: Nuget.Client + release_number: ${{ env.PACKAGE_VERSION }} + # Packages docs: + # Format: StepName:Version or PackageID:Version or StepName:PackageName:Version. + # We specifically target the package name of NuGet.CommandLine/SourcePackage because our step uses both + # - SourcePackage = ${{ env.PACKAGE_VERSION }} === 6.14.0-release.213 (this is StepName:PackageName:Version) + # - Nuget.CommandLine = 6.14.0 (this not listed here will resolve to its PackageID) + packages: | + Package Push - NuGet.CommandLine:SourcePackage:${{ env.PACKAGE_VERSION }} + NuGet.Common:${{ env.PACKAGE_VERSION }} + NuGet.Configuration:${{ env.PACKAGE_VERSION }} + NuGet.Frameworks:${{ env.PACKAGE_VERSION }} + NuGet.Packaging:${{ env.PACKAGE_VERSION }} + NuGet.Protocol:${{ env.PACKAGE_VERSION }} + NuGet.Versioning:${{ env.PACKAGE_VERSION }} + NuGet.PackageManagement:${{ env.PACKAGE_VERSION }} + NuGet.Build.Tasks:${{ env.PACKAGE_VERSION }} + NuGet.Commands:${{ env.PACKAGE_VERSION }} + NuGet.Resolver:${{ env.PACKAGE_VERSION }} diff --git a/.gitignore b/.gitignore index f6a68050bc9..f3c5cb9995d 100644 --- a/.gitignore +++ b/.gitignore @@ -209,3 +209,4 @@ launchSettings.json *.imagemanifest test/ManualTests/ +.claude/settings.local.json diff --git a/build.ps1 b/build.ps1 index 46ec4452b51..057459229db 100644 --- a/build.ps1 +++ b/build.ps1 @@ -46,7 +46,7 @@ param ( [ValidateSet('debug', 'release')] [Alias('c')] [string]$Configuration, - [ValidatePattern('^(beta|final|preview|rc|release|rtm|xprivate|zlocal)([0-9]*)$')] + [ValidatePattern('^[a-zA-Z0-9\-\.]+$')] [Alias('l')] [string]$ReleaseLabel = 'zlocal', [Alias('n')] @@ -221,7 +221,7 @@ Invoke-BuildStep 'Running Restore RTM' { exit 1 } } ` --skip:(-not $CI)` +-skip:(-not $CI -or ($ReleaseLabel -ne 'rtm'))` -ev +BuildErrors @@ -249,7 +249,7 @@ Invoke-BuildStep 'Packing RTM' { exit 1 } } ` --skip:(-not $CI)` +-skip:(-not $CI -or ($ReleaseLabel -ne 'rtm'))` -ev +BuildErrors ## Calculating Build time diff --git a/build/config.props b/build/config.props index 01c253381f4..e95864a6297 100644 --- a/build/config.props +++ b/build/config.props @@ -68,7 +68,7 @@ </PropertyGroup> </When> <!-- If we are excluding the build number, show the release label unless we are RTM. --> - <When Condition="'$(ReleaseLabel)' != 'rtm' AND '$(ReleaseLabel)' != 'svc' AND '$(ReleaseLabel)' != 'rc' "> + <When Condition="'$(ReleaseLabel)' != 'rtm' AND '$(ReleaseLabel)' != 'svc' AND '$(ReleaseLabel)' != 'rc'"> <PropertyGroup> <PreReleaseInformationVersion>-$(ReleaseLabel)</PreReleaseInformationVersion> </PropertyGroup> @@ -90,12 +90,12 @@ <!-- Nuspec defaults --> <PropertyGroup> - <Authors>Microsoft</Authors> - <PackageProjectUrl>https://aka.ms/nugetprj</PackageProjectUrl> + <Authors>Microsoft, Octopus Deploy</Authors> + <PackageProjectUrl>https://github.com/OctopusDeploy/NuGet.Client</PackageProjectUrl> <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> <RepositoryType>git</RepositoryType> - <RepositoryUrl>https://github.com/NuGet/NuGet.Client</RepositoryUrl> + <RepositoryUrl>https://github.com/OctopusDeploy/NuGet.Client</RepositoryUrl> <PackageTags>nuget</PackageTags> <Description>NuGet client library.</Description> <Copyright>© Microsoft Corporation. All rights reserved.</Copyright> diff --git a/runTests.ps1 b/runTests.ps1 index 8b020da0cd0..e48916c1203 100644 --- a/runTests.ps1 +++ b/runTests.ps1 @@ -37,7 +37,7 @@ param ( [ValidateSet('debug', 'release')] [Alias('c')] [string]$Configuration, - [ValidatePattern('^(beta|final|preview|rc|release|rtm|xprivate|zlocal)([0-9]*)$')] + [ValidatePattern('^[a-zA-Z0-9\-\.]+$')] [Alias('l')] [string]$ReleaseLabel = 'zlocal', [Alias('n')] From 8e551a7bd468e93899657cba6111ac3731a83c5d Mon Sep 17 00:00:00 2001 From: William Laugesen <will.laugesen@octopus.com> Date: Wed, 18 Nov 2026 09:59:06 +1300 Subject: [PATCH 7/7] Fix CI/CD workflow for NuGet 8.0 The Octopus workflow needs four changes to build NuGet 8.0. build.ps1 has no -Fast or -SkipUnitTest switch. The workflow now passes -Pack -CI, which builds the nupkg files and leaves the unit tests to their own step. Upstream 8.0.0 now builds as 8.0.1-octopus-release.N. A pre-release of 8.0.0 sorts below 8.0.0, so security scanners would treat the fork as older than the upstream release it contains. build/config.props keeps the upstream version so merges from upstream stay conflict free; CI bumps the patch through the PatchNuGetVersion environment variable. Upstream 8.0 adds 100 to the build number of every package it builds (the "Offset the CI build number by 100" block in build/config.props). The workflow applies the same offset to PACKAGE_VERSION so it matches the package file names the build produces. The build number is now run_number * 10 + run_attempt. It becomes the last part of the net472 assembly version, which must stay at or below 65534. The old scheme (run_number followed by a 2-digit attempt) passed that limit at run 656, and the offset made runs 654 and 655 produce the same version. The new scheme leaves room for about 6,500 runs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bf5a56b80a..c71a978254c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -93,8 +93,13 @@ jobs: - name: Set BuildNumber run: | - $runAttempt = "${{ github.run_attempt }}".PadLeft(2, '0') - $buildNumber = "${{ github.run_number }}$runAttempt" + # The build number becomes the last part of the net472 assembly version and of every file version. That part + # must stay at or below 65534, and upstream NuGet 8.0 adds 100 to it (see Set PackageVersion). + # run_number * 10 + run_attempt gives each attempt its own number and leaves room for about 6,500 workflow runs. + # Attempts above 9 reuse the number of attempt 9. + $runNumber = [int]"${{ github.run_number }}" + $runAttempt = [Math]::Min([int]"${{ github.run_attempt }}", 9) + $buildNumber = $runNumber * 10 + $runAttempt Write-Host "buildNumber: $buildNumber" echo "BUILD_NUMBER=$buildNumber" >> $env:GITHUB_ENV @@ -113,14 +118,32 @@ jobs: $major = $majorMatch.Groups[1].Value $minor = $minorMatch.Groups[1].Value - $patch = $patchMatch.Groups[1].Value + # Version the fork one patch above the upstream release it is based on (e.g. upstream 8.0.0 -> 8.0.1-octopus-release.N). + # A pre-release of 8.0.0 sorts below 8.0.0, so security scanners would treat our package as older than the upstream + # release it contains and report vulnerabilities that release already fixed. + # build/config.props keeps the upstream version so merges from upstream stay conflict free. The build step reads the + # bumped patch from the PatchNuGetVersion environment variable, because config.props only sets it when it is empty. + $patch = [int]$patchMatch.Groups[1].Value + 1 + echo "PatchNuGetVersion=$patch" >> $env:GITHUB_ENV $baseVersion = "$major.$minor.$patch" + + # Upstream NuGet 8.0 adds 100 to the build number of every package it builds. See the "Offset the CI build number + # by 100" block in build/config.props. Microsoft added it to stop 8.0 packages colliding with 7.12 packages on their + # own feeds, and it only applies while the result still fits in a UInt16 (<= 65535). + # build/config.props keeps that upstream logic so merges from upstream stay conflict free. We apply the same offset + # here so PACKAGE_VERSION matches the package file names the build writes to /artifacts/nupkgs/ + # (e.g. build number 4621 produces 8.0.1-octopus-release.4721). + $packageBuildNumber = [int]$buildNumber + if (($packageBuildNumber + 100) -le 65535) { + $packageBuildNumber += 100 + } + # This matches logic within the build that will take a 'final' and prepend 'octopus' if ($releaseLabel -eq "final") { - $packageVersion = "$baseVersion-octopus.$buildNumber" + $packageVersion = "$baseVersion-octopus.$packageBuildNumber" } else { # E.g releaseLabel = (xprivate, release, nightly#####) - $packageVersion = "$baseVersion-$releaseLabel.$buildNumber" + $packageVersion = "$baseVersion-$releaseLabel.$packageBuildNumber" } Write-Host "packageVersion: $packageVersion" # This needs to match the packages in the /artifacts/nupkgs/ folder after build @@ -133,7 +156,7 @@ jobs: - name: Build NuGet Packages ๐Ÿ“ฆ id: build - run: .\build.ps1 -Configuration Release -ReleaseLabel ${{ env.RELEASE_LABEL }} -BuildNumber ${{ env.BUILD_NUMBER }} -Fast -SkipUnitTest -CI + run: .\build.ps1 -Configuration Release -ReleaseLabel ${{ env.RELEASE_LABEL }} -BuildNumber ${{ env.BUILD_NUMBER }} -Pack -CI - name: Run NuGet.Core Unit Tests ๐Ÿงช run: |