Skip to content

Commit

Permalink
Remove SelfContained set to false for -a (#35286)
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored Sep 12, 2023
2 parents ffbf03d + dd38027 commit f1ffab6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
23 changes: 5 additions & 18 deletions src/Cli/dotnet/CommonOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ internal static IEnumerable<string> ResolveArchOptionToRuntimeIdentifier(string
return Array.Empty<string>();
}

var selfContainedSpecified = (parseResult.GetResult(SelfContainedOption) ?? parseResult.GetResult(NoSelfContainedOption)) is not null;
return ResolveRidShorthandOptions(null, arg, selfContainedSpecified);
return ResolveRidShorthandOptions(null, arg);
}

internal static IEnumerable<string> ResolveOsOptionToRuntimeIdentifier(string arg, ParseResult parseResult)
Expand All @@ -212,24 +211,12 @@ internal static IEnumerable<string> 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<string> 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<string> ResolveRidShorthandOptions(string os, string arch) =>
new string[] { $"-property:RuntimeIdentifier={ResolveRidShorthandOptionsToRuntimeIdentifier(os, arch)}" };

internal static string ResolveRidShorthandOptionsToRuntimeIdentifier(string os, string arch)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
});
}

Expand All @@ -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");
});
}

Expand All @@ -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");
});
}

Expand Down Expand Up @@ -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");
});
}
}
Expand Down

0 comments on commit f1ffab6

Please sign in to comment.