diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.props b/msbuild/Xamarin.Shared/Xamarin.Shared.props
index b750392921..d3039e2dd1 100644
--- a/msbuild/Xamarin.Shared/Xamarin.Shared.props
+++ b/msbuild/Xamarin.Shared/Xamarin.Shared.props
@@ -120,12 +120,22 @@ Copyright (C) 2020 Microsoft. All rights reserved.
-
+
+ Entitlements.plist
+
diff --git a/tests/dotnet/AutoDetectEntitlements/AppDelegate.cs b/tests/dotnet/AutoDetectEntitlements/AppDelegate.cs
new file mode 100644
index 0000000000..24a52b91ba
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/AppDelegate.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Runtime.InteropServices;
+
+using Foundation;
+
+namespace MySimpleApp
+{
+ public class Program
+ {
+ static int Main (string[] args)
+ {
+ GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly
+
+ Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD"));
+
+ return args.Length;
+ }
+ }
+}
diff --git a/tests/dotnet/AutoDetectEntitlements/MacCatalyst/AutoDetectEntitlements.csproj b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/AutoDetectEntitlements.csproj
new file mode 100644
index 0000000000..6b0e2c7731
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/AutoDetectEntitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Entitlements.plist b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Entitlements.plist
new file mode 100644
index 0000000000..556f40a9a7
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Entitlements.plist
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Makefile b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/MacCatalyst/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/AutoDetectEntitlements/Makefile b/tests/dotnet/AutoDetectEntitlements/Makefile
new file mode 100644
index 0000000000..6affa45ff1
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/Makefile
@@ -0,0 +1,2 @@
+TOP=../../..
+include $(TOP)/tests/common/shared-dotnet-test.mk
diff --git a/tests/dotnet/AutoDetectEntitlements/iOS/AutoDetectEntitlements.csproj b/tests/dotnet/AutoDetectEntitlements/iOS/AutoDetectEntitlements.csproj
new file mode 100644
index 0000000000..86d408734a
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/iOS/AutoDetectEntitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-ios
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/iOS/Entitlements.plist b/tests/dotnet/AutoDetectEntitlements/iOS/Entitlements.plist
new file mode 100644
index 0000000000..556f40a9a7
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/iOS/Entitlements.plist
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/iOS/Makefile b/tests/dotnet/AutoDetectEntitlements/iOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/iOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/AutoDetectEntitlements/macOS/AutoDetectEntitlements.csproj b/tests/dotnet/AutoDetectEntitlements/macOS/AutoDetectEntitlements.csproj
new file mode 100644
index 0000000000..a77287b9ba
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/macOS/AutoDetectEntitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-macos
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/macOS/Entitlements.plist b/tests/dotnet/AutoDetectEntitlements/macOS/Entitlements.plist
new file mode 100644
index 0000000000..556f40a9a7
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/macOS/Entitlements.plist
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/macOS/Makefile b/tests/dotnet/AutoDetectEntitlements/macOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/macOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/AutoDetectEntitlements/shared.csproj b/tests/dotnet/AutoDetectEntitlements/shared.csproj
new file mode 100644
index 0000000000..957a01c12a
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/shared.csproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ AutoDetectEntitlements
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/shared.mk b/tests/dotnet/AutoDetectEntitlements/shared.mk
new file mode 100644
index 0000000000..ec2a0d435d
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/shared.mk
@@ -0,0 +1,3 @@
+TOP=../../../..
+TESTNAME=AutoDetectEntitlements
+include $(TOP)/tests/common/shared-dotnet.mk
diff --git a/tests/dotnet/AutoDetectEntitlements/tvOS/AutoDetectEntitlements.csproj b/tests/dotnet/AutoDetectEntitlements/tvOS/AutoDetectEntitlements.csproj
new file mode 100644
index 0000000000..bd487ddcd8
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/tvOS/AutoDetectEntitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-tvos
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/tvOS/Entitlements.plist b/tests/dotnet/AutoDetectEntitlements/tvOS/Entitlements.plist
new file mode 100644
index 0000000000..556f40a9a7
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/tvOS/Entitlements.plist
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/AutoDetectEntitlements/tvOS/Makefile b/tests/dotnet/AutoDetectEntitlements/tvOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/AutoDetectEntitlements/tvOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs
index 9f43a3d9a7..55758a7932 100644
--- a/tests/dotnet/UnitTests/ProjectTest.cs
+++ b/tests/dotnet/UnitTests/ProjectTest.cs
@@ -968,5 +968,28 @@ namespace Xamarin.Tests {
DotNet.AssertBuild (project_path, properties);
}
+
+ [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", false)]
+ [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", true)]
+ [TestCase (ApplePlatform.iOS, "ios-arm64", false)]
+ [TestCase (ApplePlatform.TVOS, "tvossimulator-arm64", true)]
+ public void AutoDetectEntitlements (ApplePlatform platform, string runtimeIdentifiers, bool exclude)
+ {
+ var project = "AutoDetectEntitlements";
+ Configuration.IgnoreIfIgnoredPlatform (platform);
+
+ var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
+ Clean (project_path);
+
+ var properties = GetDefaultProperties (runtimeIdentifiers);
+ if (exclude) {
+ properties ["EnableDefaultCodesignEntitlements"] = "false";
+ DotNet.AssertBuild (project_path, properties);
+ } else {
+ var rv = DotNet.AssertBuildFailure (project_path, properties);
+ var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToList ();
+ Assert.That (errors [0].Message, Does.Contain ("Error loading Entitlements.plist template 'Entitlements.plist'"), "Message");
+ }
+ }
}
}
diff --git a/tests/msbuild/Xamarin.MacDev.Tests/DotnetTest.cs b/tests/msbuild/Xamarin.MacDev.Tests/DotnetTest.cs
index 7b59be444e..30fcbda3d3 100644
--- a/tests/msbuild/Xamarin.MacDev.Tests/DotnetTest.cs
+++ b/tests/msbuild/Xamarin.MacDev.Tests/DotnetTest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using Xamarin.Tests;
@@ -52,6 +53,15 @@ namespace Xamarin.iOS.Tasks {
{
Configuration.AssertDotNetAvailable ();
+ Dictionary properties = null;
+
+ if (Platform == "iPhoneSimulator") {
+ properties = new Dictionary
+ {
+ { "EnableDefaultCodesignEntitlements", "false" },
+ };
+ }
+
tfi = "Xamarin.iOS";
switch (project) {
case "MyMetalGame":
@@ -67,7 +77,7 @@ namespace Xamarin.iOS.Tasks {
ClearTestDirectory ();
Mode = ExecutionMode.DotNet;
- BuildProject (project, clean: false, expectedErrorCount: expectedErrorCount);
+ BuildProject (project, clean: false, expectedErrorCount: expectedErrorCount, properties: properties);
var dotnet_bundle = AppBundlePath;
Mode = ExecutionMode.MSBuild;
@@ -80,7 +90,7 @@ namespace Xamarin.iOS.Tasks {
NugetRestore (Path.Combine (net461, "MyExtensionWithPackageReference", "MyExtensionWithPackageReference.csproj"));
break;
}
- BuildProject (project, nuget_restore: true, expectedErrorCount: expectedErrorCount);
+ BuildProject (project, nuget_restore: true, expectedErrorCount: expectedErrorCount, properties: properties);
var net461_bundle = AppBundlePath;
if (expectedErrorCount == 0)
diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs
index b25da5f84d..362beafc7a 100644
--- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs
+++ b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/ProjectTest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
@@ -18,7 +19,7 @@ namespace Xamarin.iOS.Tasks
{
}
- public ProjectPaths BuildProject (string appName, int expectedErrorCount = 0, bool clean = true, bool nuget_restore = false, bool is_library = false)
+ public ProjectPaths BuildProject (string appName, int expectedErrorCount = 0, bool clean = true, bool nuget_restore = false, bool is_library = false, Dictionary properties = null)
{
var mtouchPaths = SetupProjectPaths (appName);
var csproj = mtouchPaths.ProjectCSProjPath;
@@ -31,7 +32,7 @@ namespace Xamarin.iOS.Tasks
NugetRestore (csproj);
if (clean) {
- RunTarget (mtouchPaths, "Clean", Mode);
+ RunTarget (mtouchPaths, "Clean", Mode, properties: properties);
Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath);
Assert.IsFalse (Directory.Exists (AppBundlePath + ".dSYM"), "App bundle .dSYM exists after cleanup: {0} ", AppBundlePath + ".dSYM");
Assert.IsFalse (Directory.Exists (AppBundlePath + ".mSYM"), "App bundle .mSYM exists after cleanup: {0} ", AppBundlePath + ".mSYM");
@@ -53,7 +54,7 @@ namespace Xamarin.iOS.Tasks
}
}
- RunTarget (mtouchPaths, "Build", Mode, expectedErrorCount);
+ RunTarget (mtouchPaths, "Build", Mode, expectedErrorCount, properties: properties);
if (expectedErrorCount > 0 || is_library)
return mtouchPaths;