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

[dotnet] Force 'AppendRuntimeIdentifierToOutputPath=true' for the inner build of universal apps. #20839

Merged
merged 1 commit into from
Jul 10, 2024
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
[dotnet] Force 'AppendRuntimeIdentifierToOutputPath=true' for the inn…
…er build of universal apps.

When building universal apps, each inner build must add the runtime identifier
to the output path, otherwise the inner builds may conflict with eachother,
overwriting eachother's files.

That's bad.

So we explicitly set `AppendRuntimeIdentifierToOutputPath` to `true` when
building inner builds.
  • Loading branch information
rolfbjarne committed Jul 9, 2024
commit 7cd729fef1cf64e18f3bdf5bfc5c4304f3cc617c
2 changes: 2 additions & 0 deletions dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,12 @@
</PropertyGroup>

<!-- Execute the inner builds -->
<!-- We force AppendRuntimeIdentifierToOutputPath=true because otherwise the inner builds might end up writing to the same directory -->
<MSBuild
Projects="$(MSBuildProjectFile)"
Targets="_BuildRidSpecificAppBundle"
Properties="
AppendRuntimeIdentifierToOutputPath=true;
RuntimeIdentifier=%(_RuntimeIdentifiersAsItems.Identity);
_CodesignItemsPath=%(_RuntimeIdentifiersAsItems.RidSpecificCodesignItemsPath);
_MtouchSymbolsList=%(_RuntimeIdentifiersAsItems.RidSpecificSymbolsListPath);
Expand Down
7 changes: 7 additions & 0 deletions tests/dotnet/MySimpleApp/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(SetAppendRuntimeIdentifierToOutputPathToFalse)' == 'true'">
<!-- Used by the AppendRuntimeIdentifierToOutputPath_* tests -->
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)../../../Directory.Build.props" />
</Project>
32 changes: 32 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1984,5 +1984,37 @@ public void PartialAOTTest (ApplePlatform platform, string runtimeIdentifiers, s
ExecuteWithMagicWordAndAssert (appExecutable);
}
}

[Test]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")]
public void AppendRuntimeIdentifierToOutputPath_DisableCommandLine (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["cmdline:AppendRuntimeIdentifierToOutputPath"] = "false";
DotNet.AssertBuild (project_path, properties);
}

[Test]
[TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64;maccatalyst-x64")]
public void AppendRuntimeIdentifierToOutputPath_DisableDirectoryBuildProps (ApplePlatform platform, string runtimeIdentifiers)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["SetAppendRuntimeIdentifierToOutputPathToFalse"] = "true";
DotNet.AssertBuild (project_path, properties);
}
}
}