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/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj b/src/Tests/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj index 923677f18b69..2de4810afdaa 100644 --- a/src/Tests/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj +++ b/src/Tests/Msbuild.Tests.Utilities/Msbuild.Tests.Utilities.csproj @@ -12,6 +12,7 @@ + @@ -23,13 +24,4 @@ - - - - - - - - - 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"); }); } }