Skip to content

Commit

Permalink
Apply workaround for reusing WindowsAppSDK pkg types in maui 7.0-xxx …
Browse files Browse the repository at this point in the history
…project
  • Loading branch information
imcarolwang committed Feb 4, 2024
1 parent f438576 commit 6272864
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ internal async Task GenerateProjectAsync(bool keepBootstrapperDir, ILogger logge
if (isSupportedTFM && frameworkInfo.Name != FrameworkInfo.Netstandard && frameworkInfo.Version.CompareTo(new Version(6, 0)) >= 0)
{
this.MSBuildProj.TargetFramework = targetFramework;
if(targetFramework.ToLowerInvariant().Contains("net7.0-windows10"))
{
this.MSBuildProj.SetEnableMsixTooling();
}
}
// else
// The TFM is Netstandard or version lower than 6.0 or unknown: either, it was not provided or it is a version not yet known to the tool,
Expand Down
8 changes: 8 additions & 0 deletions src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,14 @@ public bool AddDependency(ProjectDependency dependency, bool copyInternalAssets
return addDependency;
}

public void SetEnableMsixTooling()
{
// workaround for https://github.com/microsoft/WindowsAppSDK/issues/3548: dotnet build fails when WindowsAppSDK is referenced in console application.
// affects MAUI project targeting net7.0-windows10.0xxx, not reproduce in net8.0-window10.0xxx
// ref: https://github.com/dotnet/maui/issues/5886
SetPropertyValue("EnableMsixTooling", "true");
}

// Sets the property value in a PropertyGroup. Returns true if the value was changed, and false if it was already set to that value.
private bool SetPropertyValue(string propertyName, string value)
{
Expand Down
3 changes: 1 addition & 2 deletions src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,7 @@ internal static void RemoveRedundantReferences(IList<ProjectDependency> dependen
for (int idx = dependencies.Count - 1; idx >= 0; idx--)
{
var dependency = dependencies[idx];
if (dependency.IsFramework || TargetFrameworkHelper.ServiceModelPackages.Any(s => s.Name == dependency.Name)
|| TargetFrameworkHelper.s_mauiAppWindowsPackages.Any(s => s.Name == dependency.Name))
if (dependency.IsFramework || TargetFrameworkHelper.ServiceModelPackages.Any(s => s.Name == dependency.Name))
{
dependencies.RemoveAt(idx);
}
Expand Down
8 changes: 0 additions & 8 deletions src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ internal class TargetFrameworkHelper
ProjectDependency.FromPackage("System.ServiceModel.NetFramingBase", "*")
};

//packages not supprted by "dotnet build" when handling type-reuse in bootstrapper project
internal static List<ProjectDependency> s_mauiAppWindowsPackages = new List<ProjectDependency>()
{
ProjectDependency.FromPackage("Microsoft.Graphics.Win2D", "*"),
ProjectDependency.FromPackage("Microsoft.WindowsAppSDK", "*" ),
ProjectDependency.FromPackage("Microsoft.Maui.Graphics.Win2D.WinUI.Desktop", "*"),
};

public static Version MinSupportedNetFxVersion { get; } = new Version("4.5");
public static Version MinSupportedNetStandardVersion { get; } = NetStandardToNetCoreVersionMap.Keys.First();
public static Version MinSupportedNetCoreAppVersion { get; } = NetStandardToNetCoreVersionMap.Values.First();
Expand Down

0 comments on commit 6272864

Please sign in to comment.