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

[release/6.0.4xx] [dotnet] Make sure to not run the linker when we're on a disconnected Windows build. #15096

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
7 changes: 6 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@
<PublishTrimmed Condition="'$(PublishTrimmed)' == '' And '$(_MustTrim)' == 'true'">true</PublishTrimmed>
</PropertyGroup>
<Error Condition="'$(_MustTrim)' == 'true' And '$(PublishTrimmed)' != 'true'" Text="$(_PlatformName) projects must build with PublishTrimmed=true. Current value: $(PublishTrimmed)." />
<PropertyGroup Condition="'$(PublishTrimmed)' != '' And '$(IsMacEnabled)' != 'true'">
<_PreviousPublishTrimmedValue>$(PublishTrimmed)</_PreviousPublishTrimmedValue>
<PublishTrimmed />
</PropertyGroup>
<Warning Condition="'$(_PreviousPublishTrimmedValue)' != ''" Text="The linker has been disabled because there's no connection to a Mac." />
</Target>

<Target Name="_WarnRuntimeIdentifiersClash" Condition="'$(_RuntimeIdentifiersClashMessage)' != ''">
Expand Down Expand Up @@ -754,7 +759,7 @@
</Target>


<Target Name="_LoadLinkerOutput" DependsOnTargets="ComputeFilesToPublish">
<Target Name="_LoadLinkerOutput" DependsOnTargets="ComputeFilesToPublish" Condition="'$(IsMacEnabled)' == 'true'">
<!-- Load _MainFile -->
<ReadItemsFromFile SessionId="$(BuildSessionId)" File="$(_LinkerItemsDirectory)/_MainFile.items" Condition="Exists('$(_LinkerItemsDirectory)/_MainFile.items')">
<Output TaskParameter="Items" ItemName="_MainFile" />
Expand Down
9 changes: 8 additions & 1 deletion tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ public void InvalidRuntimeIdentifiers (ApplePlatform platform, string runtimeIde
[Test]
[TestCase ("iossimulator-x64", false)]
[TestCase ("ios-arm64", true)]
public void IsNotMacBuild (string runtimeIdentifier, bool isDeviceBuild)
[TestCase ("ios-arm64", true, "PublishTrimmed=true;UseInterpreter=true")]
public void IsNotMacBuild (string runtimeIdentifier, bool isDeviceBuild, string extraProperties = null)
{
if (isDeviceBuild)
Configuration.AssertDeviceAvailable ();
Expand All @@ -429,6 +430,12 @@ public void IsNotMacBuild (string runtimeIdentifier, bool isDeviceBuild)
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifier);
properties ["IsMacEnabled"] = "false";
if (extraProperties is not null) {
foreach (var assignment in extraProperties.Split (';')) {
var split = assignment.Split ('=');
properties [split [0]] = split [1];
}
}
var result = DotNet.AssertBuild (project_path, properties);
AssertThatLinkerDidNotExecute (result);
var appExecutable = Path.Combine (appPath, Path.GetFileName (project_path));
Expand Down