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

App target frameworks fix #1435

Merged
merged 13 commits into from
Mar 17, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Process(ITargetFrameworkSelectorFilterState tfm)
}
else if (tfm.Components.HasFlag(ProjectComponents.MauiiOS))
{
_logger.LogInformation("Recommending TFM {TFM} for project {Name} because project is of type .NET MAUI Target:iOS", TargetFrameworkMoniker.Net70_Android, tfm.Project);
_logger.LogInformation("Recommending TFM {TFM} for project {Name} because project is of type .NET MAUI Target:iOS", TargetFrameworkMoniker.Net70_iOS, tfm.Project);
tfm.TryUpdate(TargetFrameworkMoniker.Net70_iOS);
DianaSoltani marked this conversation as resolved.
Show resolved Hide resolved
}
else if (tfm.Components.HasFlag(ProjectComponents.Maui))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,43 @@
"NetCorePackages": []
},
{
"PackageSetName": "Third Party Unsupported",
"PackageSetName": "Microsoft.AppCenter",
"NetFrameworkPackages": [
{
"Name": "Microsoft.AppCenter",
"Version": "*"
},
{
"Name": "Microsoft.AppCenter.Analytics",
"Version": "*"
},
{
"Name": "Microsoft.AppCenter.Crashes",
"Version": "*"
},
{
"Name": "Microsoft.AppCenter.Distribute",
"Version": "*"
}
],
"NetCorePackages": []
"NetCorePackages": [
{
"Name": "Microsoft.AppCenter",
"Version": "5.0.1"
},
{
"Name": "Microsoft.AppCenter.Analytics",
"Version": "5.0.1"
},
{
"Name": "Microsoft.AppCenter.Crashes",
"Version": "5.0.1"
},
{
"Name": "Microsoft.AppCenter.Distribute",
"Version": "5.0.1"
}
]
},
{
"PackageSetName": "Community Toolkit",
Expand All @@ -331,7 +356,7 @@

{
"Name": "CommunityToolkit.Maui",
"Version": "1.0.0-rc2"
"Version": "5.0.0"
}
]
},
Expand All @@ -354,15 +379,15 @@
"NetCorePackages": [
{
"Name": "SkiaSharp.Views.Maui.Controls",
"Version": "2.88.0-preview.256"
"Version": "2.88.3"
},
{
"Name": "SkiaSharp.Views.Maui.Core",
"Version": "2.88.0-preview.256"
"Version": "2.88.3"
},
{
"Name": "SkiaSharp.Views.Maui.Controls.Compatibility",
"Version": "2.88.0-preview.256"
"Version": "2.88.3"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ private static string[] GetNonSdkTargetFramework(IProjectFile file)
}

const string NonSdkTargetFramework = "TargetFrameworkVersion";
const string TargetFrameworkIdentifier = "TargetFrameworkIdentifier";

var tfi = file.GetPropertyValue(TargetFrameworkIdentifier);
if (tfi == FrameworkConstants.FrameworkIdentifiers.MonoAndroid)
{
return new string[] { "net7.0-android" };
}
else if (tfi == FrameworkConstants.FrameworkIdentifiers.XamarinIOs)
{
return new string[] { "net7.0-ios" };
}

var tfms = GetTfms(file, NonSdkTargetFramework);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ public static ProjectItemElement GetPackagesConfigItem(ProjectItemGroupElement p
/// Finds the property group with the TFM specified, which is normally the top-level property group.
/// </summary>
public static ProjectPropertyGroupElement GetOrCreateTopLevelPropertyGroupWithTFM(IProjectRootElement rootElement) =>
rootElement.PropertyGroups.Single(pg => pg.Properties.Any(p => p.ElementName.Equals(MSBuildFacts.TargetFrameworkNodeName, StringComparison.OrdinalIgnoreCase)))
rootElement.PropertyGroups.Single(pg => pg.Properties.Any(p => p.ElementName.Equals(MSBuildFacts.TargetFrameworkNodeName, StringComparison.OrdinalIgnoreCase)
|| p.ElementName.Equals(MSBuildFacts.TargetFrameworksNodeName, StringComparison.OrdinalIgnoreCase)))
?? rootElement.AddPropertyGroup();

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static string GetTargetFramework(this IProject project)
".NETCore" => "net", // UWP
".NETCoreApp" => "netcoreapp",
".NETPortable" => "netstandard",
"MonoAndroid" => "net",
"Xamarin.iOS" => "net",
"MonoAndroid" => "net7.0-android",
"Xamarin.iOS" => "net7.0-ios",
DianaSoltani marked this conversation as resolved.
Show resolved Hide resolved
_ => throw new InvalidOperationException($"Unknown {MSBuildFacts.LegacyTargetFrameworkPropertyNodeName}: {tfi}"),
};

Expand All @@ -68,8 +68,12 @@ public static string GetTargetFramework(this IProject project)
}
}
}

if (tfi.Equals(MSBuildFacts.NETPortableTFValuePrefix, StringComparison.OrdinalIgnoreCase))
else if (tfi.Equals(MSBuildFacts.MonoAndroid, StringComparison.OrdinalIgnoreCase) ||
tfi.Equals(MSBuildFacts.XamariniOS, StringComparison.OrdinalIgnoreCase))
{
DianaSoltani marked this conversation as resolved.
Show resolved Hide resolved
return tf;
}
else if (tfi.Equals(MSBuildFacts.NETPortableTFValuePrefix, StringComparison.OrdinalIgnoreCase))
{
var profile = project.GetPropertyValue(MSBuildFacts.LegacyTargetFrameworkProfileNodeName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ public static class MSBuildFacts
public const string DesignerSubType = "Designer";
public const string CodeSubTypeValue = "Code";
public const string TargetFrameworkNodeName = "TargetFramework";
public const string TargetFrameworksNodeName = "TargetFrameworks";
public const string OutputTypeNodeName = "OutputType";
public const string GenerateAssemblyInfoNodeName = "GenerateAssemblyInfo";
public const string RequiredTargetFrameworkNodeName = "RequiredTargetFramework";
Expand Down Expand Up @@ -301,6 +302,8 @@ public static class MSBuildFacts
public const string PackagesSubstring = @"\packages";
public const string NetStandard20 = "netstandard2.0";
public const string NetCoreApp31 = "netcoreapp3.1";
public const string XamariniOS = "Xamarin.iOS";
public const string MonoAndroid = "MonoAndroid";
public const string Net5 = "net5.0";
public const string WindowsSuffix = "-windows";
public const string Net5Windows = "net5.0-windows";
Expand Down