Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SelfContained set to false for -a #35286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -12,6 +12,7 @@
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.Cli.Sln.Internal\Microsoft.DotNet.Cli.Sln.Internal.csproj" />
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.Cli.Utils\Microsoft.DotNet.Cli.Utils.csproj" />
<ProjectReference Include="..\..\Cli\Microsoft.DotNet.InternalAbstractions\Microsoft.DotNet.InternalAbstractions.csproj" />
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -23,13 +24,4 @@
<PackageReference Include="System.Security.Cryptography.X509Certificates" />
</ItemGroup>

<!-- Global usings removal -->
<!-- See: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#using -->
<ItemGroup>
<Using Remove="Microsoft.NET.TestFramework" />
<Using Remove="Microsoft.NET.TestFramework.Assertions" />
<Using Remove="Microsoft.NET.TestFramework.Commands" />
<Using Remove="Microsoft.NET.TestFramework.ProjectConstruction" />
<Using Remove="Microsoft.NET.TestFramework.Utilities" />
</ItemGroup>
</Project>
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