winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 464e177f3b355ffef3d9f96fdebed9004407d181
parent c5fbdd9fb9d53336bad182b82f255b2e3f691b10
Author: Ryan <69221034+ryfu-msft@users.noreply.github.com>
Date:   Fri,  1 Mar 2024 11:40:54 -0800

Update Repair-WinGetPackageManager with UiXaml 2.8 (#4218)


Diffstat:
Msrc/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs | 58++++++++++++++++++++++++++++++++++++++++++----------------
Msrc/PowerShell/Microsoft.WinGet.Client.Engine/Microsoft.WinGet.Client.Engine.csproj | 3++-
Msrc/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.Designer.cs | 18------------------
Msrc/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.resx | 7-------
4 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs @@ -17,6 +17,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers using Microsoft.WinGet.Client.Engine.Extensions; using Microsoft.WinGet.Common.Command; using Octokit; + using Semver; using static Microsoft.WinGet.Client.Engine.Common.Constants; /// <summary> @@ -73,12 +74,12 @@ namespace Microsoft.WinGet.Client.Engine.Helpers private const string VCLibsUWPDesktopArm64 = "https://aka.ms/Microsoft.VCLibs.arm64.14.00.Desktop.appx"; // Xaml + private const string XamlPackage28 = "Microsoft.UI.Xaml.2.8"; + private const string XamlReleaseTag286 = "v2.8.6"; + private const string MinimumWinGetReleaseTagForXaml28 = "v1.7.10514"; + private const string XamlPackage27 = "Microsoft.UI.Xaml.2.7"; private const string XamlReleaseTag273 = "v2.7.3"; - private const string XamlAssetX64 = "Microsoft.UI.Xaml.2.7.x64.appx"; - private const string XamlAssetX86 = "Microsoft.UI.Xaml.2.7.x86.appx"; - private const string XamlAssetArm = "Microsoft.UI.Xaml.2.7.arm.appx"; - private const string XamlAssetArm64 = "Microsoft.UI.Xaml.2.7.arm64.appx"; private readonly PowerShellCmdlet pwshCmdlet; private readonly HttpClientHelper httpClientHelper; @@ -163,7 +164,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task InstallFromGitHubReleaseAsync(string releaseTag, bool allUsers, bool isDowngrade, bool force) { - await this.InstallDependenciesAsync(); + await this.InstallDependenciesAsync(releaseTag); if (isDowngrade) { @@ -188,6 +189,25 @@ namespace Microsoft.WinGet.Client.Engine.Helpers } } + /// <summary> + /// Gets the Xaml dependency package name and release tag based on the provided WinGet release tag. + /// </summary> + /// <param name="releaseTag">WinGet release tag.</param> + /// <returns>A tuple in the format of (XamlPackageName, XamlReleaseTag).</returns> + private static Tuple<string, string> GetXamlDependencyVersionInfo(string releaseTag) + { + var targetVersion = SemVersion.Parse(releaseTag, SemVersionStyles.AllowLowerV); + + if (targetVersion.CompareSortOrderTo(SemVersion.Parse(MinimumWinGetReleaseTagForXaml28, SemVersionStyles.AllowLowerV)) >= 0) + { + return Tuple.Create(XamlPackage28, XamlReleaseTag286); + } + else + { + return Tuple.Create(XamlPackage27, XamlReleaseTag273); + } + } + private async Task AddProvisionPackageAsync(string releaseTag) { var githubClient = new GitHubClient(RepositoryOwner.Microsoft, RepositoryName.WinGetCli); @@ -269,7 +289,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers .FirstOrDefault(); } - private async Task InstallDependenciesAsync() + private async Task InstallDependenciesAsync(string releaseTag) { // A better implementation would use Add-AppxPackage with -DependencyPath, but // the Appx module needs to be remoted into Windows PowerShell. When the string[] parameter @@ -278,7 +298,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers // if we are in Core, then start powershell.exe and run the same command. Right now, we just // do Add-AppxPackage for each one. await this.InstallVCLibsDependenciesAsync(); - await this.InstallUiXamlAsync(); + await this.InstallUiXamlAsync(releaseTag); } private async Task InstallVCLibsDependenciesAsync() @@ -356,32 +376,38 @@ namespace Microsoft.WinGet.Client.Engine.Helpers } } - private async Task InstallUiXamlAsync() + private async Task InstallUiXamlAsync(string releaseTag) { - var uiXamlObjs = this.GetAppxObject(XamlPackage27); + (string xamlPackageName, string xamlReleaseTag) = GetXamlDependencyVersionInfo(releaseTag); + string xamlAssetX64 = string.Format($"{0}.x64.appx", xamlPackageName); + string xamlAssetX86 = string.Format($"{0}.x86.appx", xamlPackageName); + string xamlAssetArm = string.Format($"{0}.arm.appx", xamlPackageName); + string xamlAssetArm64 = string.Format($"{0}.arm64.appx", xamlPackageName); + + var uiXamlObjs = this.GetAppxObject(xamlPackageName); if (uiXamlObjs is null) { var githubRelease = new GitHubClient(RepositoryOwner.Microsoft, RepositoryName.UiXaml); - var xamlRelease = await githubRelease.GetReleaseAsync(XamlReleaseTag273); + var xamlRelease = await githubRelease.GetReleaseAsync(xamlReleaseTag); var packagesToInstall = new List<ReleaseAsset>(); var arch = RuntimeInformation.OSArchitecture; if (arch == Architecture.X64) { - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetX64)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetX64)); } else if (arch == Architecture.X86) { - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetX86)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetX86)); } else if (arch == Architecture.Arm64) { // Deployment please figure out for me. - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetX64)); - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetX86)); - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetArm)); - packagesToInstall.Add(xamlRelease.GetAsset(XamlAssetArm64)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetX64)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetX86)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetArm)); + packagesToInstall.Add(xamlRelease.GetAsset(xamlAssetArm64)); } else { diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Microsoft.WinGet.Client.Engine.csproj b/src/PowerShell/Microsoft.WinGet.Client.Engine/Microsoft.WinGet.Client.Engine.csproj @@ -41,6 +41,7 @@ <ItemGroup> <PackageReference Include="Octokit" Version="4.0.3" /> <PackageReference Include="PowerShellStandard.Library" Version="5.1.1" PrivateAssets="all" /> + <PackageReference Include="Semver" Version="2.3.0" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> @@ -50,7 +51,7 @@ <PackageReference Include="Microsoft.CSharp" Version="4.7.0" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" /> <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.4" Condition="'$(TargetFramework)' == '$(CoreFramework)'" /> <PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22000.196" PrivateAssets="all" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" /> - <PackageReference Include="System.Net.Http" Version="4.3.4" Condition="'$(TargetFramework)' == '$(DesktopFramework)'"/> + <PackageReference Include="System.Net.Http" Version="4.3.4" Condition="'$(TargetFramework)' == '$(DesktopFramework)'" /> </ItemGroup> <ItemGroup> diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.Designer.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.Designer.cs @@ -214,15 +214,6 @@ namespace Microsoft.WinGet.Resources { } /// <summary> - /// Looks up a localized string similar to Microsoft.UI.Xaml.2.7 package is not installed. - /// </summary> - internal static string MicrosoftUIXaml27Message { - get { - return ResourceManager.GetString("MicrosoftUIXaml27Message", resourceCulture); - } - } - - /// <summary> /// Looks up a localized string similar to No packages matched the given input criteria.. /// </summary> internal static string NoPackageFoundExceptionMessage { @@ -383,14 +374,5 @@ namespace Microsoft.WinGet.Resources { return ResourceManager.GetString("WinGetCLITimeoutExceptionMessage", resourceCulture); } } - - /// <summary> - /// Looks up a localized string similar to Windows Package Manager not supported.. - /// </summary> - internal static string WinGetNotSupportedMessage { - get { - return ResourceManager.GetString("WinGetNotSupportedMessage", resourceCulture); - } - } } } diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.resx b/src/PowerShell/Microsoft.WinGet.Client.Engine/Properties/Resources.resx @@ -189,13 +189,6 @@ <data name="RepairAppExecutionAliasMessage" xml:space="preserve"> <value>The App Execution Alias for the Windows Package Manager is disabled. You should enable the App Execution Alias for the Windows Package Manager. Go to App execution aliases option in Apps &amp; features Settings to enable it.</value> </data> - <data name="MicrosoftUIXaml27Message" xml:space="preserve"> - <value>Microsoft.UI.Xaml.2.7 package is not installed</value> - <comment>{Locked="Microsoft.UI.Xaml.2.7"}</comment> - </data> - <data name="WinGetNotSupportedMessage" xml:space="preserve"> - <value>Windows Package Manager not supported.</value> - </data> <data name="IntegrityUnexpectedVersionMessage" xml:space="preserve"> <value>The installed winget version doesn't match the expectation. Installer version '{0}' Expected version '{1}'</value> <comment>{Locked="{0}","{1}"} {0} - The winget current installed winget version. {1} - The expected winget version.</comment>