From 62728643bd68f9e6593d8e74529cb7fe780ccbfe Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Sun, 4 Feb 2024 07:59:38 +0000 Subject: [PATCH] Apply workaround for reusing WindowsAppSDK pkg types in maui 7.0-xxx project --- .../lib/src/Bootstrapper/SvcutilBootstrapper.cs | 4 ++++ src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs | 8 ++++++++ src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs | 3 +-- .../lib/src/Shared/TargetFrameworkHelper.cs | 8 -------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/Bootstrapper/SvcutilBootstrapper.cs b/src/dotnet-svcutil/lib/src/Bootstrapper/SvcutilBootstrapper.cs index f349906e15b2..49add0d7ae0b 100644 --- a/src/dotnet-svcutil/lib/src/Bootstrapper/SvcutilBootstrapper.cs +++ b/src/dotnet-svcutil/lib/src/Bootstrapper/SvcutilBootstrapper.cs @@ -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, diff --git a/src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs b/src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs index 4a50db78e775..8e52580d6eb1 100644 --- a/src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs +++ b/src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs @@ -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) { diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index 7369cf8cbf95..3998fc5f7628 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -435,8 +435,7 @@ internal static void RemoveRedundantReferences(IList 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); } diff --git a/src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs b/src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs index 4bbff4c8b572..d3aeb1ba44a6 100644 --- a/src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs +++ b/src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs @@ -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 s_mauiAppWindowsPackages = new List() - { - 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();