Skip to content

Commit

Permalink
[dotnet] Make sure to not run the linker when we're on a disconnected…
Browse files Browse the repository at this point in the history
… Windows build. (#15076)

This also means that we shouldn't load the linker's output. Note that we need
to check _LoadLinkerOutput even if we've already disabled the linker, because
there may be linker output from a previous (connected) build, and we don't
want to load that.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1542438.
  • Loading branch information
rolfbjarne authored May 23, 2022
1 parent 0c08e72 commit da7dd02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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 @@ -756,7 +761,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

5 comments on commit da7dd02

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: da7dd02dfd2166e08eba4946cc44bd7d3d559431

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 [CI Build] API Diff 📋

API diff (for current PR)

ℹ️ API Diff (from PR only) (please review changes)

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

API diff (vs stable)

✅ API Diff from stable

API diff: vsdrops gist

Xamarin
.NET
Xamarin vs .NET
iOS vs Mac Catalyst (.NET)

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMMINI-055.Monterey'
Hash: da7dd02dfd2166e08eba4946cc44bd7d3d559431

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • introspection

Pipeline on Agent
Hash: da7dd02dfd2166e08eba4946cc44bd7d3d559431

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-058.Monterey
Hash: da7dd02dfd2166e08eba4946cc44bd7d3d559431

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

1028 tests' device not found, 228 tests passed.

Pipeline on Agent XAMBOT-1108.Monterey'
[dotnet] Make sure to not run the linker when we're on a disconnected Windows build. (#15076)

Please sign in to comment.