Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 1.2 Schema #270

Merged
merged 3 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/NewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private static void PromptOptionalProperties<T>(T manifest)
if (type.IsEnumerable())
{
Type elementType = type.GetGenericArguments().SingleOrDefault();
if (elementType.IsNonStringClassType() && !Prompt.Confirm(Resources.EditAgreements_Message))
if (elementType.IsNonStringClassType() && !Prompt.Confirm(string.Format(Resources.EditObjectTypeField_Message, property.Name)))
{
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/WingetCreateCLI/Commands/UpdateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private List<InstallerMetadata> ParseInstallerUrlsForArchOverride(List<string> i

string installerUrl = installerUrlOverride[0];
string overrideArchString = installerUrlOverride[1];
InstallerArchitecture? overrideArch = overrideArchString.ToEnumOrDefault<InstallerArchitecture>();
Architecture? overrideArch = overrideArchString.ToEnumOrDefault<Architecture>();
if (overrideArch.HasValue)
{
installerMetadata.InstallerUrl = installerUrl;
Expand Down
84 changes: 78 additions & 6 deletions src/WingetCreateCLI/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions src/WingetCreateCLI/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -862,9 +862,9 @@
<data name="DisplayVersion_KeywordDescription" xml:space="preserve">
<value>The DisplayVersion registry value</value>
</data>
<data name="EditAgreements_Message" xml:space="preserve">
<value>Would you like to edit the Agreements field?</value>
<comment>`Agreements` refers to a specific field name that the user can edit.</comment>
<data name="EditObjectTypeField_Message" xml:space="preserve">
<value>Would you like to edit the {0} field?</value>
<comment>{0} - will be replaced with the name of the object type field</comment>
</data>
<data name="ExpectedReturnCodes_KeywordDescription" xml:space="preserve">
<value>Installer exit codes for common errors</value>
Expand Down Expand Up @@ -894,4 +894,29 @@
<value>Failed to update fork because the default branch is ahead by {0} commit(s). </value>
<comment>{0} - represents the number of commits the default branch is ahead by</comment>
</data>
<data name="DisplayInstallWarnings_KeywordDescription" xml:space="preserve">
<value>Indicates whether winget should display a warning message if the install or upgrade is known to interfere with running applications</value>
</data>
<data name="Documentations_KeywordDescription" xml:space="preserve">
<value>List of documentation</value>
</data>
<data name="DocumentLabel_KeywordDescription" xml:space="preserve">
<value>The label of the documentation for providing software guides such as manuals and troubleshooting URLs</value>
</data>
<data name="DocumentUrl_KeywordDescription" xml:space="preserve">
<value>The documentation URL</value>
</data>
<data name="InstallationNotes_KeywordDescription" xml:space="preserve">
<value>The notes displayed to the user upon completion of a package installation</value>
</data>
<data name="PurchaseUrl_KeywordDescription" xml:space="preserve">
<value>The purchase url for acquiring entitlement for the package</value>
</data>
<data name="ReturnResponseUrl_KeywordDescription" xml:space="preserve">
<value>The return response url to provide additional guidance for expected return codes</value>
</data>
<data name="UnsupportedArguments_KeywordDescription" xml:space="preserve">
<value>List of winget arguments the installer does not support</value>
<comment>"winget" is the proper name of the tool</comment>
</data>
</root>
25 changes: 12 additions & 13 deletions src/WingetCreateCore/Common/PackageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Microsoft.WingetCreateCore
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -298,7 +297,7 @@ public static bool ParsePackageAndUpdateInstallerNode(Installer installer, strin
else
{
// For a single installer, detect the architecture. If no architecture is detected, default to architecture from existing manifest.
newInstaller.Architecture = GetArchFromUrl(url) ?? GetMachineType(path)?.ToString().ToEnumOrDefault<InstallerArchitecture>() ?? installer.Architecture;
newInstaller.Architecture = GetArchFromUrl(url) ?? GetMachineType(path)?.ToString().ToEnumOrDefault<Architecture>() ?? installer.Architecture;
}

newInstaller.InstallerUrl = url;
Expand Down Expand Up @@ -465,7 +464,7 @@ private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata inst
var baseInstaller = new Installer();
baseInstaller.InstallerUrl = url;
baseInstaller.InstallerSha256 = GetFileHash(path);
baseInstaller.Architecture = GetMachineType(path)?.ToString().ToEnumOrDefault<InstallerArchitecture>() ?? InstallerArchitecture.Neutral;
baseInstaller.Architecture = GetMachineType(path)?.ToString().ToEnumOrDefault<Architecture>() ?? Architecture.Neutral;

bool parseMsixResult = false;

Expand Down Expand Up @@ -500,28 +499,28 @@ private static bool ParsePackageAndGenerateInstallerNodes(InstallerMetadata inst
/// </summary>
/// <param name="url">Installer url string.</param>
/// <returns>Installer architecture enum.</returns>
private static InstallerArchitecture? GetArchFromUrl(string url)
private static Architecture? GetArchFromUrl(string url)
{
List<InstallerArchitecture> archMatches = new List<InstallerArchitecture>();
List<Architecture> archMatches = new List<Architecture>();

// Arm must only be checked if arm64 check fails, otherwise it'll match for arm64 too
if (Regex.Match(url, "arm64|aarch64", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(InstallerArchitecture.Arm64);
archMatches.Add(Architecture.Arm64);
}
else if (Regex.Match(url, @"\barm\b", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(InstallerArchitecture.Arm);
archMatches.Add(Architecture.Arm);
}

if (Regex.Match(url, "x64|win64|_64|64-bit", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(InstallerArchitecture.X64);
archMatches.Add(Architecture.X64);
}

if (Regex.Match(url, "x86|win32|ia32|_86|32-bit", RegexOptions.IgnoreCase).Success)
{
archMatches.Add(InstallerArchitecture.X86);
archMatches.Add(Architecture.X86);
}

return archMatches.Count == 1 ? archMatches.Single() : null;
Expand Down Expand Up @@ -713,7 +712,7 @@ private static bool ParseMsi(string path, Installer baseInstaller, Manifests man
archString.EqualsIC("Arm64") ? "Arm64" :
archString.EqualsIC("Arm") ? "Arm" : archString;

baseInstaller.Architecture = archString.ToEnumOrDefault<InstallerArchitecture>() ?? InstallerArchitecture.Neutral;
baseInstaller.Architecture = archString.ToEnumOrDefault<Architecture>() ?? Architecture.Neutral;

if (baseInstaller.InstallerLocale == null)
{
Expand Down Expand Up @@ -793,7 +792,7 @@ private static string GetApplicationProperty(AppxMetadata appxMetadata, string p

private static void SetInstallerPropertiesFromAppxMetadata(AppxMetadata appxMetadata, Installer installer, InstallerManifest installerManifest)
{
installer.Architecture = appxMetadata.Architecture.ToEnumOrDefault<InstallerArchitecture>() ?? InstallerArchitecture.Neutral;
installer.Architecture = appxMetadata.Architecture.ToEnumOrDefault<Architecture>() ?? Architecture.Neutral;

installer.MinimumOSVersion = SetInstallerStringPropertyIfNeeded(installerManifest?.MinimumOSVersion, appxMetadata.MinOSVersion?.ToString());
installer.PackageFamilyName = SetInstallerStringPropertyIfNeeded(installerManifest?.PackageFamilyName, appxMetadata.PackageFamilyName);
Expand Down Expand Up @@ -839,7 +838,7 @@ private static AppxMetadata GetAppxMetadataAndSetInstallerProperties(string path
appxMetadatas.Add(new AppxMetadata(appxFile.GetStream()));
}
}
catch (COMException)
catch (System.Runtime.InteropServices.COMException)
{
// Check if package is an Msix
var appxMetadata = new AppxMetadata(path);
Expand All @@ -862,7 +861,7 @@ private static AppxMetadata GetAppxMetadataAndSetInstallerProperties(string path

return appxMetadatas.First();
}
catch (COMException)
catch (System.Runtime.InteropServices.COMException)
{
// Binary wasn't an MSIX
return null;
Expand Down
Loading