diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 32965625581c..2ebaf4ba5d2b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -87,14 +87,14 @@ 8d395fd2729ad43428252f37656eb5c97a180987 - + https://github.com/dotnet/fsharp - 5af96504f10836eca6ce804ab3cdd28c042fa35a + 63a09289745da5c256e7baf5f4194a750b1ec878 - + https://github.com/dotnet/fsharp - 5af96504f10836eca6ce804ab3cdd28c042fa35a + 63a09289745da5c256e7baf5f4194a750b1ec878 diff --git a/eng/Versions.props b/eng/Versions.props index d8d5b49ecab9..ec5d7fb8e774 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -205,7 +205,7 @@ - 13.9.200-beta.24617.1 + 13.9.200-beta.25056.5 diff --git a/src/Cli/dotnet/commands/dotnet-help/HelpCommand.cs b/src/Cli/dotnet/commands/dotnet-help/HelpCommand.cs index 8671bbd6eee2..0c9d420c6db3 100644 --- a/src/Cli/dotnet/commands/dotnet-help/HelpCommand.cs +++ b/src/Cli/dotnet/commands/dotnet-help/HelpCommand.cs @@ -7,6 +7,8 @@ using Microsoft.DotNet.Cli.Utils; using Microsoft.TemplateEngine.Cli.Commands; +using NuGetDocumentedCommand = NuGet.CommandLine.XPlat.Commands.DocumentedCommand; + namespace Microsoft.DotNet.Tools.Help { public class HelpCommand(string[] helpArgs) @@ -107,6 +109,11 @@ private bool TryGetDocsLink(string[] command, out string docsLink) docsLink = dc.DocsLink; return true; } + else if (parsedCommand?.CommandResult?.Command is NuGetDocumentedCommand ndc) + { + docsLink = ndc.HelpUrl; + return true; + } docsLink = null; return false; } diff --git a/src/Cli/dotnet/commands/dotnet-nuget/NuGetCommandParser.cs b/src/Cli/dotnet/commands/dotnet-nuget/NuGetCommandParser.cs index 3b098edc738e..1909c2fad5ba 100644 --- a/src/Cli/dotnet/commands/dotnet-nuget/NuGetCommandParser.cs +++ b/src/Cli/dotnet/commands/dotnet-nuget/NuGetCommandParser.cs @@ -36,7 +36,7 @@ private static CliCommand ConstructCommand() command.Subcommands.Add(GetVerifyCommand()); command.Subcommands.Add(GetTrustCommand()); command.Subcommands.Add(GetSignCommand()); - command.Subcommands.Add(GetWhyCommand()); + NuGet.CommandLine.XPlat.Commands.Why.WhyCommand.GetWhyCommand(command); command.SetAction(NuGetCommand.Run); @@ -218,19 +218,5 @@ private static CliCommand GetSignCommand() return signCommand; } - - private static CliCommand GetWhyCommand() - { - DocumentedCommand whyCommand = new("why", "https://learn.microsoft.com/dotnet/core/tools/dotnet-nuget-why"); - whyCommand.Arguments.Add(new CliArgument("PROJECT|SOLUTION") { Arity = ArgumentArity.ExactlyOne }); - whyCommand.Arguments.Add(new CliArgument("PACKAGE") { Arity = ArgumentArity.ExactlyOne }); - - whyCommand.Options.Add(new ForwardedOption>("--framework", "-f") { Arity = ArgumentArity.ZeroOrMore } - .ForwardAsManyArgumentsEachPrefixedByOption("--framework") - .AllowSingleArgPerToken()); - - whyCommand.SetAction(NuGetCommand.Run); - return whyCommand; - } } } diff --git a/src/Cli/dotnet/dotnet.csproj b/src/Cli/dotnet/dotnet.csproj index 7b258f8f8a0e..82db3621e7fc 100644 --- a/src/Cli/dotnet/dotnet.csproj +++ b/src/Cli/dotnet/dotnet.csproj @@ -102,6 +102,7 @@ + diff --git a/src/SourceBuild/patches/fsharp/0001-Upgrade-some-runtime-packages.patch b/src/SourceBuild/patches/fsharp/0001-Upgrade-some-runtime-packages.patch deleted file mode 100644 index c12d61eb6c7d..000000000000 --- a/src/SourceBuild/patches/fsharp/0001-Upgrade-some-runtime-packages.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 192a16dca94744c82ca456d6cfb7a2a30be1d84f Mon Sep 17 00:00:00 2001 -From: Matt Thalman -Date: Thu, 19 Dec 2024 11:00:01 -0600 -Subject: [PATCH] Upgrade some runtime packages - -Backport: https://github.com/dotnet/fsharp/pull/18166 ---- - eng/Versions.props | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/eng/Versions.props b/eng/Versions.props -index cd72f8599..1f711df8f 100644 ---- a/eng/Versions.props -+++ b/eng/Versions.props -@@ -76,15 +76,15 @@ - - 8.0.0 -- 4.5.1 -+ 4.6.0 - $(SystemPackageVersionVersion) - $(SystemPackageVersionVersion) - $(SystemPackageVersionVersion) - $(SystemPackageVersionVersion) -- 4.5.5 -+ 4.6.0 - 4.7.0 - $(SystemPackageVersionVersion) -- 6.0.0 -+ 6.1.0 - $(SystemPackageVersionVersion) - 4.5.0 - 1.6.0 diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs index 577bcdd34b5a..3fec1be83da0 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs @@ -828,6 +828,8 @@ private ToolPackSupport AddToolPack( runtimePackToDownload.SetMetadata(MetadataKeys.Version, packVersion); } + runtimePackItem.SetMetadata(MetadataKeys.RuntimeIdentifier, hostRuntimeIdentifier); + switch (toolPackType) { case ToolPackType.Crossgen2: diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs index 63c12a3a749c..4f2c34b8e54d 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveReadyToRunCompilers.cs @@ -52,21 +52,7 @@ protected override void ExecuteCore() _runtimePack = GetNETCoreAppRuntimePack(); _targetRuntimeIdentifier = _runtimePack?.GetMetadata(MetadataKeys.RuntimeIdentifier); - // Get the list of runtime identifiers that we support and can target - ITaskItem targetingPack = GetNETCoreAppTargetingPack(); - string supportedRuntimeIdentifiers = targetingPack?.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers); - - var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); - var supportedRIDsList = supportedRuntimeIdentifiers == null ? Array.Empty() : supportedRuntimeIdentifiers.Split(';'); - - // Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture - _hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid( - runtimeGraph, - NETCoreSdkRuntimeIdentifier, - supportedRIDsList, - out _); - - if (_hostRuntimeIdentifier == null || _targetRuntimeIdentifier == null) + if (_targetRuntimeIdentifier == null) { Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); return; @@ -96,6 +82,13 @@ protected override void ExecuteCore() private bool ValidateCrossgenSupport() { + _hostRuntimeIdentifier = GetHostRuntimeIdentifierForCrossgen(); + if (_hostRuntimeIdentifier == null) + { + Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); + return false; + } + _crossgenTool.PackagePath = _runtimePack?.GetMetadata(MetadataKeys.PackageDirectory); if (_crossgenTool.PackagePath == null) { @@ -121,12 +114,39 @@ private bool ValidateCrossgenSupport() } return true; + + string GetHostRuntimeIdentifierForCrossgen() + { + // Crossgen's host RID comes from the runtime pack that Crossgen will be loaded from. + + // Get the list of runtime identifiers that we support and can target + ITaskItem targetingPack = GetNETCoreAppTargetingPack(); + string supportedRuntimeIdentifiers = targetingPack?.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers); + + var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); + var supportedRIDsList = supportedRuntimeIdentifiers == null ? Array.Empty() : supportedRuntimeIdentifiers.Split(';'); + + // Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture + return NuGetUtils.GetBestMatchingRid( + runtimeGraph, + NETCoreSdkRuntimeIdentifier, + supportedRIDsList, + out _); + } } private bool ValidateCrossgen2Support() { ITaskItem crossgen2Pack = Crossgen2Packs?.FirstOrDefault(); - _crossgen2Tool.PackagePath = crossgen2Pack?.GetMetadata(MetadataKeys.PackageDirectory); + + _hostRuntimeIdentifier = crossgen2Pack?.GetMetadata(MetadataKeys.RuntimeIdentifier); + if (_hostRuntimeIdentifier == null) + { + Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); + return false; + } + + _crossgen2Tool.PackagePath = crossgen2Pack.GetMetadata(MetadataKeys.PackageDirectory); if (string.IsNullOrEmpty(_crossgen2Tool.PackagePath) || !NuGetVersion.TryParse(crossgen2Pack.GetMetadata(MetadataKeys.NuGetPackageVersion), out NuGetVersion crossgen2PackVersion)) @@ -181,42 +201,19 @@ private bool GetCrossgen2TargetOS(out string targetOS) // Determine targetOS based on target rid. // Use the runtime graph to support non-portable target rids. + // Use the full target rid instead of just the target OS as the runtime graph + // may only have the full target rid and not an OS-only rid for non-portable target rids + // added by our source-build partners. var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); string portablePlatform = NuGetUtils.GetBestMatchingRid( runtimeGraph, - _targetPlatform, - new[] { "linux", "linux-musl", "osx", "win", "freebsd", "illumos" }, + _targetRuntimeIdentifier, + new[] { "linux", "osx", "win", "freebsd", "illumos" }, out _); - // For source-build, allow the bootstrap SDK rid to be unknown to the runtime repo graph. - if (portablePlatform == null && _targetRuntimeIdentifier == _hostRuntimeIdentifier) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - portablePlatform = "win"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - portablePlatform = "linux"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) - { - portablePlatform = "freebsd"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("ILLUMOS"))) - { - portablePlatform = "illumos"; - } - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - { - portablePlatform = "osx"; - } - } - targetOS = portablePlatform switch { "linux" => "linux", - "linux-musl" => "linux", "osx" => "osx", "win" => "windows", "freebsd" => "freebsd", diff --git a/test/dotnet-nuget.UnitTests/GivenANuGetCommand.cs b/test/dotnet-nuget.UnitTests/GivenANuGetCommand.cs index e2e545145088..0191039ad85f 100644 --- a/test/dotnet-nuget.UnitTests/GivenANuGetCommand.cs +++ b/test/dotnet-nuget.UnitTests/GivenANuGetCommand.cs @@ -77,9 +77,6 @@ public GivenANuGetCommand(ITestOutputHelper log) : base(log) "--interactive", "--verbosity", "detailed", "--format", "json"}, 0)] - [InlineData(new[] { "why" }, 0)] - [InlineData(new[] { "why", "C:\\path", "Fake.Package" }, 0)] - [InlineData(new[] { "why", "C:\\path", "Fake.Package", "--framework", "net472", "-f", "netcoreapp5.0" }, 0)] public void ItPassesCommandIfSupported(string[] inputArgs, int result) { @@ -112,5 +109,29 @@ public void ItAcceptsPrefixedOption() .And .HaveStdErrContaining("Required argument missing for option: '-ss'."); } + + [Fact] + public void ItHasAWhySubcommand() + { + var testAssetName = "NewtonSoftDependentProject"; + var testAsset = _testAssetsManager + .CopyTestAsset(testAssetName) + .WithSource(); + var projectDirectory = testAsset.Path; + + new RestoreCommand(testAsset) + .Execute() + .Should() + .Pass() + .And.NotHaveStdErr(); + + new DotnetCommand(Log) + .WithWorkingDirectory(projectDirectory) + .Execute("nuget", "why", "newtonsoft.json") + .Should() + .Pass() + .And.NotHaveStdErr() + .And.HaveStdOutContaining("has the following dependency"); + } } }