From 2fcf879cd50d9f598004d10f6abba5c340592dd7 Mon Sep 17 00:00:00 2001 From: Union Palenshus Date: Thu, 13 May 2021 15:49:02 -0700 Subject: [PATCH] Omitting resource type packages, and prompting for architecture in some cases (#14) --- pipelines/azure-pipelines.release.yml | 4 ++-- src/WingetCreateCLI/Commands/NewCommand.cs | 15 +++++++++++---- src/WingetCreateCLI/Commands/SubmitCommand.cs | 2 +- src/WingetCreateCLI/Commands/TokenCommand.cs | 2 +- src/WingetCreateCLI/Commands/UpdateCommand.cs | 2 +- src/WingetCreateCore/Common/PackageParser.cs | 5 +++-- src/WingetCreateCore/WingetCreateCore.csproj | 4 ++-- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/pipelines/azure-pipelines.release.yml b/pipelines/azure-pipelines.release.yml index 8420a963..40ea96c5 100644 --- a/pipelines/azure-pipelines.release.yml +++ b/pipelines/azure-pipelines.release.yml @@ -40,7 +40,7 @@ jobs: dependsOn: GetVersion variables: majorMinorBuildVersion: $[dependencies.GetVersion.outputs['GetVersionStep.majorMinorBuildVersion']] - revision: $[counter(format('{0}.{1}', '2', variables['majorMinorBuildVersion']), 1)] + revision: $[counter(format('{0}.{1}', '3', variables['majorMinorBuildVersion']), 1)] version: "$(majorMinorBuildVersion).$(revision)" appxBundleFile: "Microsoft.WindowsPackageManagerManifestCreator_$(version)_8wekyb3d8bbwe.msixbundle" @@ -211,5 +211,5 @@ jobs: # https://aka.ms/wingetcreate/preview points to latest preview version of wingetcreate.exe iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - wingetcreate.exe update -i Microsoft.WingetCreate -u $(packageUrl) -v $(manifestVersion) -t $(GITHUB_PAT) + wingetcreate.exe update -i Microsoft.WingetCreate -u $(packageUrl) -v $(manifestVersion) -t $(GITHUB_PAT) --submit displayName: Update package manifest in the OWC diff --git a/src/WingetCreateCLI/Commands/NewCommand.cs b/src/WingetCreateCLI/Commands/NewCommand.cs index 891e7400..1b1ea3d7 100644 --- a/src/WingetCreateCLI/Commands/NewCommand.cs +++ b/src/WingetCreateCLI/Commands/NewCommand.cs @@ -32,7 +32,12 @@ public class NewCommand : BaseCommand /// /// The url path to the manifest documentation site. /// - public const string ManifestDocumentationUrl = "https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md"; + private const string ManifestDocumentationUrl = "https://github.com/microsoft/winget-cli/blob/master/doc/ManifestSpecv1.0.md"; + + /// + /// Installer types for which we can trust that the detected architecture is correct, so don't need to prompt the user to confirm. + /// + private static readonly InstallerType[] ReliableArchitectureInstallerTypes = new[] { InstallerType.Msi, InstallerType.Msix, InstallerType.Appx }; /// /// Gets the usage examples for the New command. @@ -78,7 +83,7 @@ public override async Task Execute() { CommandExecutedEvent commandEvent = new CommandExecutedEvent { - Command = "new", + Command = nameof(NewCommand), InstallerUrl = this.InstallerUrl, HasGitHubToken = !string.IsNullOrEmpty(this.GitHubToken), }; @@ -219,10 +224,12 @@ private static void PromptInstallerProperties(T manifest, PropertyInfo proper { var currentValue = requiredProperty.GetValue(singleInstaller); - if (currentValue == null) + // Only prompt if the value isn't already set, or if it's the Architecture property and we don't trust the parser to have gotten it correct for this InstallerType. + if (currentValue == null || + (requiredProperty.Name == nameof(Installer.Architecture) && !ReliableArchitectureInstallerTypes.Contains(singleInstaller.InstallerType.Value))) { var result = PromptProperty(singleInstaller, currentValue, requiredProperty.Name); - requiredProperty.SetValue(requiredProperty, result); + requiredProperty.SetValue(singleInstaller, result); } // If we know the installertype is EXE, prompt the user for installer switches (silent and silentwithprogress) diff --git a/src/WingetCreateCLI/Commands/SubmitCommand.cs b/src/WingetCreateCLI/Commands/SubmitCommand.cs index 3968c351..56a71137 100644 --- a/src/WingetCreateCLI/Commands/SubmitCommand.cs +++ b/src/WingetCreateCLI/Commands/SubmitCommand.cs @@ -51,7 +51,7 @@ public override async Task Execute() { CommandExecutedEvent commandEvent = new CommandExecutedEvent { - Command = "Submit", + Command = nameof(SubmitCommand), HasGitHubToken = !string.IsNullOrEmpty(this.GitHubToken), }; diff --git a/src/WingetCreateCLI/Commands/TokenCommand.cs b/src/WingetCreateCLI/Commands/TokenCommand.cs index 5c50e9ef..572c7a6c 100644 --- a/src/WingetCreateCLI/Commands/TokenCommand.cs +++ b/src/WingetCreateCLI/Commands/TokenCommand.cs @@ -36,7 +36,7 @@ public override async Task Execute() { CommandExecutedEvent commandEvent = new CommandExecutedEvent { - Command = "Token", + Command = nameof(TokenCommand), HasGitHubToken = !string.IsNullOrEmpty(this.GitHubToken), }; diff --git a/src/WingetCreateCLI/Commands/UpdateCommand.cs b/src/WingetCreateCLI/Commands/UpdateCommand.cs index 7f70842f..d1443b1e 100644 --- a/src/WingetCreateCLI/Commands/UpdateCommand.cs +++ b/src/WingetCreateCLI/Commands/UpdateCommand.cs @@ -85,7 +85,7 @@ public override async Task Execute() { CommandExecutedEvent commandEvent = new CommandExecutedEvent { - Command = "update", + Command = nameof(UpdateCommand), InstallerUrl = this.InstallerUrl, Id = this.Id, Version = this.Version, diff --git a/src/WingetCreateCore/Common/PackageParser.cs b/src/WingetCreateCore/Common/PackageParser.cs index 4565383b..8226e0ac 100644 --- a/src/WingetCreateCore/Common/PackageParser.cs +++ b/src/WingetCreateCore/Common/PackageParser.cs @@ -399,9 +399,10 @@ private static AppxMetadata GetAppxMetadataAndSetInstallerProperties(string path IAppxFile signatureFile = bundle.AppxBundleReader.GetFootprintFile(APPX_BUNDLE_FOOTPRINT_FILE_TYPE.APPX_BUNDLE_FOOTPRINT_FILE_TYPE_SIGNATURE); signatureSha256 = HashAppxFile(signatureFile); - foreach (var appxName in bundle.InternalAppxPackagesRelativePaths) + // Only create installer nodes for non-resource packages + foreach (var childPackage in bundle.ChildAppxPackages.Where(p => p.PackageType == PackageType.Application)) { - var appxFile = bundle.AppxBundleReader.GetPayloadPackage(appxName); + var appxFile = bundle.AppxBundleReader.GetPayloadPackage(childPackage.RelativeFilePath); appxMetadatas.Add(new AppxMetadata(appxFile.GetStream())); } } diff --git a/src/WingetCreateCore/WingetCreateCore.csproj b/src/WingetCreateCore/WingetCreateCore.csproj index 44412ca7..4a89b3a2 100644 --- a/src/WingetCreateCore/WingetCreateCore.csproj +++ b/src/WingetCreateCore/WingetCreateCore.csproj @@ -17,12 +17,12 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive