Skip to content
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
1 change: 1 addition & 0 deletions dotnet/generate-target-platforms.csharp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
writer.WriteLine ("\t</ItemGroup>");
writer.WriteLine ("\t<PropertyGroup>");
writer.WriteLine ($"\t\t<{platform}MinSupportedOSPlatformVersion>{minSdkVersionString}</{platform}MinSupportedOSPlatformVersion>");
writer.WriteLine ($"\t\t<MinSupportedOSPlatformVersion>$({platform}MinSupportedOSPlatformVersion)</MinSupportedOSPlatformVersion>");
writer.WriteLine ("\t</PropertyGroup>");
writer.WriteLine ("</Project>");
}
Expand Down
13 changes: 13 additions & 0 deletions msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,19 @@
<comment>RuntimeIdentifier: don't translate (it's the name of a MSBuild property)</comment>
</data>

<data name="E7125" xml:space="preserve">
<value>Unable to parse the value '{0}' for the property '{1}.</value>
<comment>
{0}: user-provided value
{1}: name of an MSBuild property
</comment>
</data>

<data name="E7126" xml:space="preserve">
<value>The SupportedOSPlatformVersion value '{0}' in the project file is lower than the minimum value '{1}'.</value>
<comment>SupportedOSPlatformVersion: don't translate (it's the name of an MSBuild property)</comment>
</data>

<data name="XcodeBuild_CreateNativeRef" xml:space="preserve">
<value>Adding reference to Xcode project output: '{0}'. The '%(CreateNativeReference)' metadata can be set to 'false' to opt out of this behavior.</value>
<comment>
Expand Down
15 changes: 15 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class CompileAppManifest : XamarinTask, ITaskCallback, ICancelableTask {

public bool IsWatchExtension { get; set; }

[Required]
public string MinSupportedOSPlatformVersion { get; set; } = string.Empty;

public ITaskItem [] PartialAppManifests { get; set; } = Array.Empty<ITaskItem> ();

[Required]
Expand Down Expand Up @@ -302,6 +305,18 @@ bool SetMinimumOSVersion (PDictionary plist)
minimumOSVersion = minimumOSVersionInManifest!;
}

// Verify that the value is not lower than the minimum
if (!Version.TryParse (MinSupportedOSPlatformVersion, out var minSupportedVersion)) {
Log.LogError (MSBStrings.E7125 /* Unable to parse the value '{0}' for the property '{1}. */, MinSupportedOSPlatformVersion, "MinSupportedOSPlatformVersion");
return false;
} else if (!Version.TryParse (SupportedOSPlatformVersion, out var supportedVersion)) {
Log.LogError (MSBStrings.E7125 /* Unable to parse the value '{0}' for the property '{1}. */, SupportedOSPlatformVersion, "SupportedOSPlatformVersion");
return false;
} else if (minSupportedVersion > supportedVersion) {
Log.LogError (MSBStrings.E7126 /* The SupportedOSPlatformVersion value '{0}' in the project file is lower than the minimum value '{1}'." */, SupportedOSPlatformVersion, MinSupportedOSPlatformVersion);
return false;
}

// Write out our value
plist [minimumVersionKey] = minimumOSVersion;

Expand Down
1 change: 1 addition & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
IsWatchApp="$(IsWatchApp)"
IsWatchExtension="$(IsWatchExtension)"
IsXPCService="$(IsXPCService)"
MinSupportedOSPlatformVersion="$(MinSupportedOSPlatformVersion)"
PartialAppManifests="@(PartialAppManifest)"
ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(_ResourcePrefix)"
Expand Down
14 changes: 8 additions & 6 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ test.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Version.De
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_NUGET_REF_NAME=$($(platform)_NUGET_REF_NAME)\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(rid)_NUGET_RUNTIME_NAME=$($(rid)_NUGET_RUNTIME_NAME)\\n))" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),SUPPORTED_API_VERSIONS_$(platform)='$(SUPPORTED_API_VERSIONS_$(platform))'\\n)" | sed 's/^ //' >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)" >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)\n" >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),DOTNET_MIN_$(platform)_SDK_VERSION=$(DOTNET_MIN_$(platform)_SDK_VERSION)\\n)" | sed 's/^ //' >> $@

test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Version.Details.xml
@rm -f $@
Expand Down Expand Up @@ -119,9 +120,10 @@ test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Ver
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_NUGET_REF_NAME=$($(platform)_NUGET_REF_NAME)\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(rid)_NUGET_RUNTIME_NAME=$($(rid)_NUGET_RUNTIME_NAME)\\n))" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),SUPPORTED_API_VERSIONS_$(platform)='$(SUPPORTED_API_VERSIONS_$(platform))'\\n)" | sed 's/^ //' >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)" >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
@printf "XCODE_VERSION=$(XCODE_VERSION)\n" >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),DOTNET_MIN_$(platform)_SDK_VERSION=$(DOTNET_MIN_$(platform)_SDK_VERSION)\\n)" | sed 's/^ //' >> $@

clean-local::
$(Q) $(SYSTEM_XBUILD) /t:Clean /p:Platform=iPhoneSimulator /p:Configuration=$(CONFIG) $(XBUILD_VERBOSITY) tests.sln
Expand Down
28 changes: 27 additions & 1 deletion tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ public void UnsupportedTargetPlatformVersion (ApplePlatform platform)
// Pick a target platform version that we don't really support,
// but don't show an error in .NET 8 because of backwards compat.
// The earliest target OS version should do.
var minSupportedOSVersion = GetSupportedTargetPlatformVersions (platform).First ();
var minSupportedOSVersion = GetMinSupportedOSPlatformVersion (platform);
var targetFrameworks = Configuration.DotNetTfm + "-" + platform.AsString ().ToLowerInvariant () + minSupportedOSVersion;
var supportedApiVersions = GetSupportedApiVersions (platform, isCompat: false);

Expand Down Expand Up @@ -1914,6 +1914,11 @@ string [] GetSupportedTargetPlatformVersions (ApplePlatform platform)
.ToArray ();
}

string GetMinSupportedOSPlatformVersion (ApplePlatform platform)
{
return Configuration.GetVariable ($"DOTNET_MIN_{platform.AsString ().ToUpperInvariant ()}_SDK_VERSION", "unknown MinSupportedOSPlatformVersion");
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "MtouchArch", "x86_64")]
[TestCase (ApplePlatform.iOS, "MtouchArch", "ARMv7s")]
Expand Down Expand Up @@ -2837,5 +2842,26 @@ static HashSet<string> GetLinkedWithFrameworks (string path)
}
return rv;
}

[Test]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "13.1")]
[TestCase (ApplePlatform.iOS, "ios-arm64", "10.0")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64", "10.0")]
[TestCase (ApplePlatform.MacOSX, "osx-arm64", "10.0")]
public void InvalidSupportedOSPlatformVersion (ApplePlatform platform, string runtimeIdentifiers, string version)
{
var project = "MySimpleApp";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var minVersion = GetMinSupportedOSPlatformVersion (platform);
var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath);
Clean (project_path);
var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["SupportedOSPlatformVersion"] = version;
var rv = DotNet.AssertBuildFailure (project_path, properties);
var errors = BinLog.GetBuildLogErrors (rv.BinLogPath).ToArray ();
AssertErrorMessages (errors, $"The SupportedOSPlatformVersion value '{version}' in the project file is lower than the minimum value '{minVersion}'.");
}
}
}
2 changes: 1 addition & 1 deletion tests/generator/BGenTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public static void AddPreviewNoWarn (IList<string> argumentList)
public static string? GetPreviewNoWarn (string? existingNowarn)
{
if (Configuration.XcodeIsStable)
return null;
return existingNowarn;

var previewNoWarn = $"XCODE_{Configuration.XcodeVersion.Major}_{Configuration.XcodeVersion.Minor}_PREVIEW";
if (string.IsNullOrEmpty (existingNowarn)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,15 @@ CompileAppManifest CreateTask (string? tmpdir = null, ApplePlatform platform = A
task.AssemblyName = "AssemblyName";
task.AppBundleName = "AppBundleName";
task.CompiledAppManifest = new TaskItem (Path.Combine (tmpdir, "TemporaryAppManifest.plist"));
task.DefaultSdkVersion = Sdks.GetAppleSdk (platform).GetInstalledSdkVersions (false).First ().ToString ();
task.SdkVersion = task.DefaultSdkVersion;
task.DefaultSdkVersion = Sdks.GetAppleSdk (platform).GetInstalledSdkVersions (false).First ().ToString ()!;
task.MinSupportedOSPlatformVersion = "10.0";
task.SupportedOSPlatformVersion = "15.0";
task.SdkVersion = task.DefaultSdkVersion ?? string.Empty;
task.TargetFrameworkMoniker = TargetFramework.GetTargetFramework (platform, true).ToString ();

return task;
}

[Test]
public void DefaultMinimumOSVersion ()
{
var dir = Cache.CreateTemporaryDirectory ();
var task = CreateTask (dir);

ExecuteTask (task);

var plist = PDictionary.FromFile (task.CompiledAppManifest!.ItemSpec)!;
Assert.AreEqual (task.SdkVersion, plist.GetMinimumOSVersion (), "MinimumOSVersion");
}

[Test]
public void MainMinimumOSVersions ()
{
Expand All @@ -52,6 +42,7 @@ public void MainMinimumOSVersions ()
main.Save (mainPath);

task.AppManifest = new TaskItem (mainPath);
task.SupportedOSPlatformVersion = "14.0";

ExecuteTask (task);

Expand All @@ -78,6 +69,7 @@ public void MultipleMinimumOSVersions ()

task.AppManifest = new TaskItem (mainPath);
task.PartialAppManifests = new [] { new TaskItem (partialPath) };
task.SupportedOSPlatformVersion = "14.0";

ExecuteTask (task);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ protected virtual void ConfigureTask (bool isDotNet)
Task.CompiledAppManifest = new TaskItem (Path.Combine (Cache.CreateTemporaryDirectory (), "AppBundlePath", "Info.plist"));
Task.AssemblyName = assemblyName;
Task.AppManifest = new TaskItem (CreateTempFile ("foo.plist"));
Task.MinSupportedOSPlatformVersion = "10.0";
Task.SupportedOSPlatformVersion = "15.0";
Task.SdkVersion = "10.0";

Plist = new PDictionary ();
Expand All @@ -70,7 +72,7 @@ public override void Setup ()

ConfigureTask (IsDotNet);

Task.Execute ();
ExecuteTask (Task);
CompiledPlist = PDictionary.FromFile (Task.CompiledAppManifest.ItemSpec);
}

Expand Down