Skip to content

Commit

Permalink
App target frameworks fix (#1435)
Browse files Browse the repository at this point in the history
* Fixed memory corruption in VisualStudioFinder

VisualStudioFinder.GetLatestPath() uses COM to iterate over the
install locations for Visual Studio but somehow, once the method
returns to the caller (GetLatestVisualStudioPath), none of the
methods can be relied on to return sane values.

Therefore, the easiest solution is to track the values we care about
and just return them to our caller who can then avoid needing to re-make
the same COM invocations a second time.

* Removed LogError call used for debugging

* Improve support <TargetFrameworks> for migrations

* Nuget TFI addition

* Fix typo for recommended net7-ios on MauiiOS projects

* Add default platform versions

* Revert "Removed LogError call used for debugging" from tfm branch

This reverts commit 91dd355.

* Revert "Fixed memory corruption in VisualStudioFinder"

This reverts commit ab1f8ef.

* update mobile dev logic + remove defaults

* Update package mapper to include App Center packages + update Community Toolkit to latest

* Clean up code + update SkiaSharp

---------

Co-authored-by: Jeffrey Stedfast <jestedfa@microsoft.com>
Co-authored-by: Diana Soltani <dianasoltani@microsoft.com>
  • Loading branch information
3 people authored Mar 17, 2023
1 parent 5fd3400 commit 1cc53ee
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
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);
}
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",
_ => 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))
{
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

0 comments on commit 1cc53ee

Please sign in to comment.