From dd380277a95e2a2a833bc40a9f0b547ca36c34b2 Mon Sep 17 00:00:00 2001 From: Michael Yanni Date: Mon, 11 Sep 2023 14:34:36 -0700 Subject: [PATCH] Removes adding the SelfContained property (set to false) for -a. Fixed tests based on the removal of the property. --- src/Cli/dotnet/CommonOptions.cs | 23 ++++--------------- .../GivenDotnetOsArchOptions.cs | 8 +++---- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Cli/dotnet/CommonOptions.cs b/src/Cli/dotnet/CommonOptions.cs index a989805c68d9..3547fd59ed1c 100644 --- a/src/Cli/dotnet/CommonOptions.cs +++ b/src/Cli/dotnet/CommonOptions.cs @@ -201,8 +201,7 @@ internal static IEnumerable ResolveArchOptionToRuntimeIdentifier(string return Array.Empty(); } - var selfContainedSpecified = (parseResult.GetResult(SelfContainedOption) ?? parseResult.GetResult(NoSelfContainedOption)) is not null; - return ResolveRidShorthandOptions(null, arg, selfContainedSpecified); + return ResolveRidShorthandOptions(null, arg); } internal static IEnumerable ResolveOsOptionToRuntimeIdentifier(string arg, ParseResult parseResult) @@ -212,24 +211,12 @@ internal static IEnumerable ResolveOsOptionToRuntimeIdentifier(string ar throw new GracefulException(CommonLocalizableStrings.CannotSpecifyBothRuntimeAndOsOptions); } - var selfContainedSpecified = (parseResult.GetResult(SelfContainedOption) ?? parseResult.GetResult(NoSelfContainedOption)) is not null; - if (parseResult.BothArchAndOsOptionsSpecified()) - { - return ResolveRidShorthandOptions(arg, ArchOptionValue(parseResult), selfContainedSpecified); - } - - return ResolveRidShorthandOptions(arg, null, selfContainedSpecified); + var arch = parseResult.BothArchAndOsOptionsSpecified() ? ArchOptionValue(parseResult) : null; + return ResolveRidShorthandOptions(arg, arch); } - private static IEnumerable ResolveRidShorthandOptions(string os, string arch, bool userSpecifiedSelfContainedOption) - { - var properties = new string[] { $"-property:RuntimeIdentifier={ResolveRidShorthandOptionsToRuntimeIdentifier(os, arch)}" }; - if (!userSpecifiedSelfContainedOption) - { - properties = properties.Append("-property:SelfContained=false").ToArray(); - } - return properties; - } + private static IEnumerable ResolveRidShorthandOptions(string os, string arch) => + new string[] { $"-property:RuntimeIdentifier={ResolveRidShorthandOptionsToRuntimeIdentifier(os, arch)}" }; internal static string ResolveRidShorthandOptionsToRuntimeIdentifier(string os, string arch) { diff --git a/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs b/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs index a1e4980d7f0f..ed1ea7afefc3 100644 --- a/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs +++ b/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs @@ -28,7 +28,7 @@ public void OsOptionIsCorrectlyResolved() var expectedArch = RuntimeInformation.ProcessArchitecture.Equals(Architecture.Arm64) ? "arm64" : Environment.Is64BitOperatingSystem ? "x64" : "x86"; command.GetArgumentsToMSBuild() .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-{expectedArch} -property:SelfContained=false"); + .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-{expectedArch}"); }); } @@ -50,7 +50,7 @@ public void ArchOptionIsCorrectlyResolved() } command.GetArgumentsToMSBuild() .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier={expectedOs}-arch -property:SelfContained=false"); + .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier={expectedOs}-arch"); }); } @@ -63,7 +63,7 @@ public void OSAndArchOptionsCanBeCombined() var command = BuildCommand.FromArgs(new string[] { "--arch", "arch", "--os", "os" }, msbuildPath); command.GetArgumentsToMSBuild() .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-arch -property:SelfContained=false"); + .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-arch"); }); } @@ -145,7 +145,7 @@ public void ArchOptionsAMD64toX64() var command = BuildCommand.FromArgs(new string[] { "--arch", "amd64", "--os", "os" }, msbuildPath); command.GetArgumentsToMSBuild() .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-x64 -property:SelfContained=false"); + .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary -property:RuntimeIdentifier=os-x64"); }); } }