[dotnet] Make sure to not run the linker when we're on a disconnected 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.
This commit is contained in:
Rolf Bjarne Kvinge 2022-05-23 16:33:09 +02:00 коммит произвёл GitHub
Родитель 0c08e725f3
Коммит da7dd02dfd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -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)' != ''">
@ -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" />

Просмотреть файл

@ -418,7 +418,8 @@ namespace Xamarin.Tests {
[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 ();
@ -429,6 +430,12 @@ namespace Xamarin.Tests {
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));