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

[One .NET] fix 'dotnet publish' with no arguments #8137

Merged
merged 1 commit into from
Jun 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
<UseCurrentRuntimeIdentifier>false</UseCurrentRuntimeIdentifier>
<PublishTrimmed Condition=" '$(PublishTrimmed)' == '' and ('$(AndroidLinkMode)' == 'SdkOnly' or '$(AndroidLinkMode)' == 'Full') ">true</PublishTrimmed>
<PublishTrimmed Condition=" '$(PublishTrimmed)' == '' and '$(Configuration)' == 'Release' and '$(AndroidLinkMode)' != 'None' ">true</PublishTrimmed>
<!--
This prevents an early error message during 'dotnet publish'.
We handle $(SelfContained) in a custom way where it is forced to be true.
-->
<PublishSelfContained Condition=" '$(PublishSelfContained)' == '' ">false</PublishSelfContained>
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' and '$(PublishTrimmed)' == 'true' ">SdkOnly</AndroidLinkMode>
<AndroidLinkMode Condition=" '$(AndroidLinkMode)' == '' ">None</AndroidLinkMode>
<!-- For compat with user code not marked trimmable, only trim opt-in by default. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,18 @@ static bool IsPreviewFrameworkVersion (string targetFramework)
&& XABuildConfig.AndroidLatestUnstableApiLevel != XABuildConfig.AndroidLatestStableApiLevel);
}

[Test]
public void DotNetPublishDefaultValues([Values (false, true)] bool isRelease)
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease
};
var builder = CreateDllBuilder ();
builder.Save (proj);
var dotnet = new DotNetCLI (Path.Combine (Root, builder.ProjectDirectory, proj.ProjectFilePath));
Assert.IsTrue (dotnet.Publish (), "`dotnet publish` should succeed");
}

[Test]
public void DotNetPublish ([Values (false, true)] bool isRelease, [ValueSource(nameof(DotNetTargetFrameworks))] object[] data)
{
Expand Down