├── .gitignore
└── src
├── WinGet.Sharp.Sandbox
├── Program.cs
└── WinGet.Sharp.Sandbox.csproj
├── WinGet.Sharp.Tests
├── CommunityRepository.cs
├── GlobalUsings.cs
├── Primary.cs
└── WinGet.Sharp.Tests.csproj
├── WinGet.Sharp.sln
└── WinGet.Sharp
├── CommunityRepo.cs
├── Enums
├── ElevationRequirement.cs
├── EnumIgnoreCaseStringConverter.cs
├── ExpectedReturnCodeReturnResponse.cs
├── Icons.cs
├── InstallModes.cs
├── InstallerArchitecture.cs
├── InstallerType.cs
├── ManifestType.cs
├── Platform.cs
├── Scope.cs
├── UpgradeBehavior.cs
└── YamlStringEnumConverter.cs
├── Models
├── Agreement.cs
├── AppsAndFeaturesEntry.cs
├── DefaultLocale.cs
├── Dependencies.cs
├── Document.cs
├── ExpectedReturnCode.cs
├── IManifest.cs
├── Icon.cs
├── Installer.cs
├── InstallerManifest.cs
├── InstallerSwitches.cs
├── Locale.cs
├── NestedFile.cs
├── PackageDependencies.cs
└── Version.cs
├── WinGet.Sharp.csproj
├── WinGet.Sharp.targets
└── WinGetFactory.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | # The following command works for downloading when using Git for Windows:
2 | # curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
3 | #
4 | # Download this file using PowerShell v3 under Windows with the following comand:
5 | # Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
6 | #
7 | # or wget:
8 | # wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
9 |
10 | # User-specific files
11 | *.suo
12 | *.user
13 | *.sln.docstates
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Rr]elease/
18 | x64/
19 | [Bb]in/
20 | [Oo]bj/
21 | # build folder is nowadays used for build scripts and should not be ignored
22 | #build/
23 |
24 | # NuGet Packages
25 | *.nupkg
26 | # The packages folder can be ignored because of Package Restore
27 | **/packages/*
28 | # except build/, which is used as an MSBuild target.
29 | !**/packages/build/
30 | # Uncomment if necessary however generally it will be regenerated when needed
31 | #!**/packages/repositories.config
32 |
33 | # MSTest test Results
34 | [Tt]est[Rr]esult*/
35 | [Bb]uild[Ll]og.*
36 |
37 | *_i.c
38 | *_p.c
39 | *.ilk
40 | *.meta
41 | *.obj
42 | *.pch
43 | *.pdb
44 | *.pgc
45 | *.pgd
46 | *.rsp
47 | *.sbr
48 | *.tlb
49 | *.tli
50 | *.tlh
51 | *.tmp
52 | *.tmp_proj
53 | *.log
54 | *.vspscc
55 | *.vssscc
56 | .builds
57 | *.pidb
58 | *.scc
59 |
60 | # Visual C++ cache files
61 | ipch/
62 | *.aps
63 | *.ncb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 |
68 | # Visual Studio profiler
69 | *.psess
70 | *.vsp
71 | *.vspx
72 |
73 | # Guidance Automation Toolkit
74 | *.gpState
75 |
76 | # ReSharper is a .NET coding add-in
77 | _ReSharper*/
78 | *.[Rr]e[Ss]harper
79 |
80 | # TeamCity is a build add-in
81 | _TeamCity*
82 |
83 | # DotCover is a Code Coverage Tool
84 | *.dotCover
85 |
86 | # NCrunch
87 | *.ncrunch*
88 | .*crunch*.local.xml
89 |
90 | # Installshield output folder
91 | [Ee]xpress/
92 |
93 | # DocProject is a documentation generator add-in
94 | DocProject/buildhelp/
95 | DocProject/Help/*.HxT
96 | DocProject/Help/*.HxC
97 | DocProject/Help/*.hhc
98 | DocProject/Help/*.hhk
99 | DocProject/Help/*.hhp
100 | DocProject/Help/Html2
101 | DocProject/Help/html
102 |
103 | # Click-Once directory
104 | publish/
105 |
106 | # Publish Web Output
107 | *.Publish.xml
108 |
109 | # Windows Azure Build Output
110 | csx
111 | *.build.csdef
112 |
113 | # Windows Store app package directory
114 | AppPackages/
115 |
116 | # Others
117 | *.Cache
118 | ClientBin/
119 | [Ss]tyle[Cc]op.*
120 | ~$*
121 | *~
122 | *.dbmdl
123 | *.[Pp]ublish.xml
124 | *.pfx
125 | *.publishsettings
126 | modulesbin/
127 | tempbin/
128 |
129 | # EPiServer Site file (VPP)
130 | AppData/
131 |
132 | # RIA/Silverlight projects
133 | Generated_Code/
134 |
135 | # Backup & report files from converting an old project file to a newer
136 | # Visual Studio version. Backup files are not needed, because we have git ;-)
137 | _UpgradeReport_Files/
138 | Backup*/
139 | UpgradeLog*.XML
140 | UpgradeLog*.htm
141 |
142 | # vim
143 | *.txt~
144 | *.swp
145 | *.swo
146 |
147 | # Temp files when opening LibreOffice on ubuntu
148 | .~lock.*
149 |
150 | # svn
151 | .svn
152 |
153 | # CVS - Source Control
154 | **/CVS/
155 |
156 | # Remainings from resolving conflicts in Source Control
157 | *.orig
158 |
159 | # SQL Server files
160 | **/App_Data/*.mdf
161 | **/App_Data/*.ldf
162 | **/App_Data/*.sdf
163 |
164 |
165 | #LightSwitch generated files
166 | GeneratedArtifacts/
167 | _Pvt_Extensions/
168 | ModelManifest.xml
169 |
170 | # =========================
171 | # Windows detritus
172 | # =========================
173 |
174 | # Windows image file caches
175 | Thumbs.db
176 | ehthumbs.db
177 |
178 | # Folder config file
179 | Desktop.ini
180 |
181 | # Recycle Bin used on file shares
182 | $RECYCLE.BIN/
183 |
184 | # OS generated files #
185 | Icon?
186 |
187 | # Mac desktop service store files
188 | .DS_Store
189 |
190 | # SASS Compiler cache
191 | .sass-cache
192 |
193 | # Visual Studio 2014 CTP
194 | **/*.sln.ide
195 |
196 | # Visual Studio temp something
197 | .vs/
198 |
199 | # dotnet stuff
200 | project.lock.json
201 |
202 | # VS 2015+
203 | *.vc.vc.opendb
204 | *.vc.db
205 |
206 | # Rider
207 | .idea/
208 |
209 | # Visual Studio Code
210 | .vscode/
211 |
212 | # Output folder used by Webpack or other FE stuff
213 | **/node_modules/*
214 | **/wwwroot/*
215 |
216 | # SpecFlow specific
217 | *.feature.cs
218 | *.feature.xlsx.*
219 | *.Specs_*.html
220 |
221 | # UWP Projects
222 | AppPackages/
223 |
224 | #####
225 | # End of core ignore list, below put you custom 'per project' settings (patterns or path)
226 | #####
227 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Sandbox/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Management.Deployment;
2 | using System;
3 | using System.Threading.Tasks;
4 |
5 | namespace WinGet.Sharp.Sandbox;
6 |
7 | internal class Program
8 | {
9 | static async Task Main(string[] args)
10 | {
11 | Console.WriteLine("Hello, World!");
12 |
13 | Guid clsid = new("C53A4F16-787E-42A4-B304-29EFFB4BF597");
14 | Type packageManagerType = Type.GetTypeFromCLSID(clsid, true)!;
15 | var manager = (PackageManager)Activator.CreateInstance(packageManagerType)!;
16 |
17 | var catalogRef = manager.GetLocalPackageCatalog(LocalPackageCatalog.InstalledPackages);
18 | var catalog = catalogRef.Connect().PackageCatalog;
19 |
20 | clsid = new("572DED96-9C60-4526-8F92-EE7D91D38C1A");
21 | var findPackagesOptionsType = Type.GetTypeFromCLSID(clsid, true)!;
22 | var options = (FindPackagesOptions)Activator.CreateInstance(findPackagesOptionsType)!;
23 |
24 | var results = await catalog.FindPackagesAsync(options);
25 |
26 | foreach (var match in results.Matches)
27 | {
28 | var package = match.CatalogPackage;
29 |
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Sandbox/WinGet.Sharp.Sandbox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net48
6 | latest
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Tests/CommunityRepository.cs:
--------------------------------------------------------------------------------
1 | using WinGet.Sharp.Enums;
2 | using Xunit.Abstractions;
3 |
4 | namespace WinGet.Sharp.Tests;
5 |
6 | public class CommunityRepository
7 | {
8 | private readonly ITestOutputHelper _log;
9 |
10 | public CommunityRepository(ITestOutputHelper log)
11 | {
12 | _log = log;
13 | }
14 |
15 | [Theory]
16 | [InlineData("YoYoGames.GameMaker.Studio.2", "2023.8.2.108")]
17 | [InlineData("7zip.7zip", "23.01")]
18 | [InlineData("MHNexus.HxD", "2.5")]
19 | public async Task GetManifest(string id, string version)
20 | {
21 | var manifest = await CommunityRepo.GetManifestAsync(id, version);
22 |
23 | Assert.NotNull(manifest);
24 | Assert.NotNull(manifest.ManifestVersion);
25 | Assert.Equal(ManifestType.Version, manifest.ManifestType);
26 | Assert.Equal(id, manifest.PackageIdentifier);
27 | Assert.Equal(version, manifest.PackageVersion);
28 | Assert.NotNull(manifest.DefaultLocale);
29 | }
30 |
31 | [Theory]
32 | [InlineData("YoYoGames.GameMaker.Studio.2", "2023.8.2.108")]
33 | [InlineData("7zip.7zip", "23.01")]
34 | [InlineData("MHNexus.HxD", "2.5")]
35 | public async Task GetInstaller(string id, string version)
36 | {
37 | var installer = await CommunityRepo.GetInstallerAsync(id, version);
38 |
39 | Assert.NotNull(installer);
40 | Assert.NotNull(installer.ManifestVersion);
41 | Assert.Equal(ManifestType.Installer, installer.ManifestType);
42 | Assert.Equal(id, installer.PackageIdentifier);
43 | Assert.Equal(version, installer.PackageVersion);
44 |
45 | Assert.NotNull(installer.Installers);
46 | Assert.NotEmpty(installer.Installers);
47 |
48 | foreach (var inst in installer.Installers)
49 | {
50 | _log.WriteLine($"{inst.InstallerType} {inst.Architecture} ({inst.InstallerUrl})");
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Tests/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using Xunit;
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Tests/Primary.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Management.Deployment;
2 | using Xunit.Abstractions;
3 |
4 | namespace WinGet.Sharp.Tests;
5 |
6 | public class Primary
7 | {
8 | private readonly ITestOutputHelper _log;
9 |
10 | public Primary(ITestOutputHelper log)
11 | {
12 | _log = log;
13 | }
14 |
15 | [Fact]
16 | public async Task ListInstalledPackages()
17 | {
18 | PackageManager manager = WinGetFactory.CreatePackageManager();
19 |
20 | var catalogRef = manager.GetLocalPackageCatalog(LocalPackageCatalog.InstalledPackages);
21 | var catalog = catalogRef.Connect().PackageCatalog;
22 |
23 | FindPackagesOptions options = WinGetFactory.CreateFindPackagesOptions();
24 | var result = await catalog.FindPackagesAsync(options);
25 | Assert.Equal(FindPackagesResultStatus.Ok, result.Status);
26 |
27 | var matches = result.Matches.ToList();
28 | Assert.NotEmpty(matches);
29 |
30 | foreach (var match in matches)
31 | {
32 | var package = match.CatalogPackage;
33 | _log.WriteLine($"{package.Name} ({package.Id})");
34 | }
35 | }
36 |
37 | [Theory]
38 | [InlineData("blender")]
39 | [InlineData("Visual studio")]
40 | public async Task FilterInstalledPackages(string query)
41 | {
42 | PackageManager manager = WinGetFactory.CreatePackageManager();
43 |
44 | var catalogRef = manager.GetLocalPackageCatalog(LocalPackageCatalog.InstalledPackages);
45 | var catalog = catalogRef.Connect().PackageCatalog;
46 |
47 | var filter = WinGetFactory.CreatePackageMatchFilter();
48 | filter.Field = PackageMatchField.Name;
49 | filter.Option = PackageFieldMatchOption.ContainsCaseInsensitive;
50 | filter.Value = query;
51 |
52 | FindPackagesOptions options = WinGetFactory.CreateFindPackagesOptions();
53 | options.Filters.Add(filter);
54 |
55 | var result = await catalog.FindPackagesAsync(options);
56 | Assert.Equal(FindPackagesResultStatus.Ok, result.Status);
57 |
58 | var matches = result.Matches.ToList();
59 | Assert.NotEmpty(matches);
60 |
61 | foreach (var match in matches)
62 | {
63 | var package = match.CatalogPackage;
64 | _log.WriteLine($"{package.Name} ({package.Id})");
65 | }
66 | }
67 |
68 | [Theory]
69 | [InlineData("blender")]
70 | [InlineData("Visual studio")]
71 | [InlineData("trumpet")]
72 | public async Task FilterCommunityRepoPackages(string query)
73 | {
74 | PackageManager manager = WinGetFactory.CreatePackageManager();
75 |
76 | var catalogRef = manager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.OpenWindowsCatalog);
77 | var catalog = catalogRef.Connect().PackageCatalog;
78 |
79 | var filter = WinGetFactory.CreatePackageMatchFilter();
80 | filter.Field = PackageMatchField.Name;
81 | filter.Option = PackageFieldMatchOption.ContainsCaseInsensitive;
82 | filter.Value = query;
83 |
84 | FindPackagesOptions options = WinGetFactory.CreateFindPackagesOptions();
85 | options.Filters.Add(filter);
86 |
87 | var result = await catalog.FindPackagesAsync(options);
88 | Assert.Equal(FindPackagesResultStatus.Ok, result.Status);
89 |
90 | var matches = result.Matches.ToList();
91 | Assert.NotEmpty(matches);
92 |
93 | foreach (var match in matches)
94 | {
95 | var package = match.CatalogPackage;
96 | _log.WriteLine($"{package.Name} ({package.Id})");
97 | }
98 | }
99 |
100 | [Theory]
101 | [InlineData("notepad++")]
102 | public async Task DownloadCommunityRepoPackage(string query)
103 | {
104 | var downloadOptions = WinGetFactory.CreateDownloadOptions();
105 | //downloadOptions.Architecture = Windows.System.ProcessorArchitecture.X64;
106 | //downloadOptions.InstallerType = PackageInstallerType.Msix;
107 | downloadOptions.DownloadDirectory = Path.GetTempPath();
108 |
109 | PackageManager manager = WinGetFactory.CreatePackageManager();
110 |
111 | var catalogRef = manager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.OpenWindowsCatalog);
112 | var catalog = catalogRef.Connect().PackageCatalog;
113 |
114 | var filter = WinGetFactory.CreatePackageMatchFilter();
115 | filter.Field = PackageMatchField.Name;
116 | filter.Option = PackageFieldMatchOption.ContainsCaseInsensitive;
117 | filter.Value = query;
118 |
119 | FindPackagesOptions searchOptions = WinGetFactory.CreateFindPackagesOptions();
120 | searchOptions.Filters.Add(filter);
121 |
122 | var result = await catalog.FindPackagesAsync(searchOptions);
123 | Assert.Equal(FindPackagesResultStatus.Ok, result.Status);
124 |
125 | var matches = result.Matches.ToList();
126 | Assert.NotEmpty(matches);
127 |
128 | var match = matches.First();
129 | await manager.DownloadPackageAsync(match.CatalogPackage, downloadOptions)
130 | .AsTask(new Progress(DownloadProgress));
131 |
132 | _log.WriteLine("Download complete");
133 |
134 | void DownloadProgress(PackageDownloadProgress prog)
135 | {
136 | _log.WriteLine($"{prog.DownloadProgress * 100:00.00}%");
137 | }
138 | }
139 |
140 | [Fact]
141 | public void CreateAuthenticationArguments()
142 | {
143 | var args = WinGetFactory.CreateAuthenticationArguments();
144 | args.AuthenticationAccount = "Account";
145 | args.AuthenticationMode = AuthenticationMode.Interactive;
146 | }
147 | }
--------------------------------------------------------------------------------
/src/WinGet.Sharp.Tests/WinGet.Sharp.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0-windows10.0.22621.0
5 | enable
6 | enable
7 |
8 | false
9 | true
10 |
11 | false
12 |
13 |
14 | $(RestoreAdditionalProjectSources);
15 | $(MSBuildThisFileDirectory)\..\WinGet.Sharp\bin\Debug
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | runtime; build; native; contentfiles; analyzers; buildtransitive
24 | all
25 |
26 |
27 | runtime; build; native; contentfiles; analyzers; buildtransitive
28 | all
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.34009.444
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGet.Sharp", "WinGet.Sharp\WinGet.Sharp.csproj", "{05A87DE2-FA63-444D-B025-4FFB5B53793F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGet.Sharp.Tests", "WinGet.Sharp.Tests\WinGet.Sharp.Tests.csproj", "{59B2FA36-4570-4686-82E5-AD7A7FB6109E}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinGet.Sharp.Sandbox", "WinGet.Sharp.Sandbox\WinGet.Sharp.Sandbox.csproj", "{03831FF1-FE9B-479E-A5A4-284CD6EC7320}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {05A87DE2-FA63-444D-B025-4FFB5B53793F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {05A87DE2-FA63-444D-B025-4FFB5B53793F}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {05A87DE2-FA63-444D-B025-4FFB5B53793F}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {05A87DE2-FA63-444D-B025-4FFB5B53793F}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {59B2FA36-4570-4686-82E5-AD7A7FB6109E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {59B2FA36-4570-4686-82E5-AD7A7FB6109E}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {59B2FA36-4570-4686-82E5-AD7A7FB6109E}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {59B2FA36-4570-4686-82E5-AD7A7FB6109E}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {03831FF1-FE9B-479E-A5A4-284CD6EC7320}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {03831FF1-FE9B-479E-A5A4-284CD6EC7320}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {03831FF1-FE9B-479E-A5A4-284CD6EC7320}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {03831FF1-FE9B-479E-A5A4-284CD6EC7320}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {F356C673-1A74-4C99-B706-814A1CF7EA46}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/CommunityRepo.cs:
--------------------------------------------------------------------------------
1 | using Flurl;
2 | using Flurl.Http;
3 | using System.Globalization;
4 | using WinGet.Sharp.Models;
5 | using WinGet.Sharp.Enums;
6 | using YamlDotNet.Serialization;
7 |
8 | namespace WinGet.Sharp;
9 |
10 | public static class CommunityRepo
11 | {
12 | private static readonly IDeserializer _deserializer = new DeserializerBuilder()
13 | .WithTypeConverter(new YamlStringEnumConverter())
14 | .IgnoreUnmatchedProperties()
15 | .Build();
16 |
17 | public static Task GetManifestAsync(string id, string version, CancellationToken cancellationToken = default)
18 | {
19 | return GetAndDeserializeAsync(id, version, cancellationToken: cancellationToken);
20 | }
21 |
22 | public static Task GetInstallerAsync(string id, string version, CancellationToken cancellationToken = default)
23 | {
24 | return GetAndDeserializeAsync(id, version, "installer", cancellationToken);
25 | }
26 |
27 | public static Task GetLocaleAsync(string id, string version, string locale, CancellationToken cancellationToken = default)
28 | {
29 | return GetAndDeserializeAsync(id, version, $"locale.{locale}", cancellationToken);
30 | }
31 |
32 | public static Task GetLocaleAsync(string id, string version, CultureInfo culture, CancellationToken cancellationToken = default)
33 | {
34 | return GetLocaleAsync(id, version, culture.ToString(), cancellationToken);
35 | }
36 |
37 | public static async Task GetDefaultLocaleAsync(string id, string version, CancellationToken cancellationToken = default)
38 | {
39 | var manifest = await GetManifestAsync(id, version, cancellationToken);
40 | return await GetAndDeserializeAsync(id, version,
41 | $"locale.{manifest.DefaultLocale}", cancellationToken);
42 | }
43 |
44 | public static Url BuildManifestUrl(string id, string version, ManifestType manifestType)
45 | {
46 | if (manifestType == ManifestType.Manifest)
47 | return BuildManifestUrl(id, version);
48 |
49 | var manifestString = manifestType.ToString();
50 | manifestString = char.ToLower(manifestString[0]) + manifestString.Substring(1);
51 |
52 | return BuildManifestUrl(id, version, manifestString);
53 | }
54 |
55 | private static async Task GetAndDeserializeAsync(string id, string version, string? manifestType = null, CancellationToken cancellationToken = default)
56 | {
57 | var url = BuildManifestUrl(id, version, manifestType);
58 | var yaml = await url.GetStringAsync(cancellationToken: cancellationToken);
59 |
60 | return _deserializer.Deserialize(yaml);
61 | }
62 |
63 | private static Url BuildManifestUrl(string id, string version, string? manifestType = null)
64 | {
65 | string filename = manifestType == null
66 | ? $"{id}.yaml"
67 | : $"{id}.{manifestType}.yaml";
68 |
69 | return "https://raw.githubusercontent.com/microsoft/winget-pkgs/master/manifests"
70 | .AppendPathSegments(char.ToLower(id[0]))
71 | .AppendPathSegments(id.Split('.'))
72 | .AppendPathSegments(version, filename);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/ElevationRequirement.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | ///
6 | /// The installer's elevation requirement
7 | ///
8 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
9 | public enum ElevationRequirement
10 | {
11 |
12 | [EnumMember(Value = @"elevationRequired")]
13 | ElevationRequired = 0,
14 |
15 | [EnumMember(Value = @"elevationProhibited")]
16 | ElevationProhibited = 1,
17 |
18 | [EnumMember(Value = @"elevatesSelf")]
19 | ElevatesSelf = 2,
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/EnumIgnoreCaseStringConverter.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 |
4 | namespace WinGet.Sharp.Enums;
5 |
6 | public class EnumIgnoreCaseStringConverter : JsonConverter where TEnum : struct
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | public EnumIgnoreCaseStringConverter()
12 | {
13 | }
14 |
15 | ///
16 | /// Writes the JSON representation of the object.
17 | ///
18 | /// The to write to.
19 | /// The value.
20 | /// The calling serializer.
21 | public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
22 | {
23 | if (value == null)
24 | {
25 | writer.WriteNull();
26 | return;
27 | }
28 |
29 | Enum e = (Enum)value;
30 | string enumName = Enum.GetName(e.GetType(), value);
31 |
32 | if (enumName != null)
33 | {
34 | // enum value has no name so write number
35 | writer.WriteValue(value);
36 | }
37 | else
38 | {
39 | writer.WriteValue(enumName);
40 | }
41 | }
42 |
43 | ///
44 | /// Reads the JSON representation of the object.
45 | ///
46 | /// The to read from.
47 | /// Type of the object.
48 | /// The existing value of object being read.
49 | /// The calling serializer.
50 | /// The object value.
51 | public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
52 | {
53 | try
54 | {
55 | switch (reader.TokenType)
56 | {
57 | case JsonToken.String:
58 | string name = reader.Value?.ToString();
59 | if (name is null)
60 | goto default;
61 | return Parse(name);
62 |
63 | case JsonToken.Integer:
64 | return (TEnum)reader.Value;
65 |
66 | case JsonToken.Null:
67 | default:
68 | throw new JsonSerializationException($"Error converting value {reader.Value} to type '{typeof(TEnum).Name}'.");
69 | }
70 | }
71 | catch (Exception ex)
72 | {
73 | throw new JsonSerializationException($"Error converting value {reader.Value} to type '{typeof(TEnum).Name}'.", ex);
74 | }
75 | }
76 |
77 | ///
78 | /// Determines whether this instance can convert the specified object type.
79 | ///
80 | /// Type of the object.
81 | ///
82 | /// true if this instance can convert the specified object type; otherwise, false.
83 | ///
84 | public override bool CanConvert(Type objectType)
85 | {
86 | return objectType.IsEnum;
87 | }
88 |
89 | public static TEnum Parse(string enumText)
90 | {
91 | if (string.IsNullOrEmpty(enumText))
92 | enumText = "Unknown";
93 |
94 | if (Enum.TryParse(enumText, true, out var platWindows))
95 | return platWindows;
96 | else
97 | throw new JsonSerializationException($"Error converting value '{enumText}' to type '{typeof(TEnum).Name}'.");
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/ExpectedReturnCodeReturnResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public enum ExpectedReturnCodeReturnResponse
7 | {
8 |
9 | [EnumMember(Value = @"packageInUse")]
10 | PackageInUse = 0,
11 |
12 | [EnumMember(Value = @"installInProgress")]
13 | InstallInProgress = 1,
14 |
15 | [EnumMember(Value = @"fileInUse")]
16 | FileInUse = 2,
17 |
18 | [EnumMember(Value = @"missingDependency")]
19 | MissingDependency = 3,
20 |
21 | [EnumMember(Value = @"diskFull")]
22 | DiskFull = 4,
23 |
24 | [EnumMember(Value = @"insufficientMemory")]
25 | InsufficientMemory = 5,
26 |
27 | [EnumMember(Value = @"noNetwork")]
28 | NoNetwork = 6,
29 |
30 | [EnumMember(Value = @"contactSupport")]
31 | ContactSupport = 7,
32 |
33 | [EnumMember(Value = @"rebootRequiredToFinish")]
34 | RebootRequiredToFinish = 8,
35 |
36 | [EnumMember(Value = @"rebootRequiredForInstall")]
37 | RebootRequiredForInstall = 9,
38 |
39 | [EnumMember(Value = @"rebootInitiated")]
40 | RebootInitiated = 10,
41 |
42 | [EnumMember(Value = @"cancelledByUser")]
43 | CancelledByUser = 11,
44 |
45 | [EnumMember(Value = @"alreadyInstalled")]
46 | AlreadyInstalled = 12,
47 |
48 | [EnumMember(Value = @"downgrade")]
49 | Downgrade = 13,
50 |
51 | [EnumMember(Value = @"blockedByPolicy")]
52 | BlockedByPolicy = 14,
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/Icons.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
6 | public enum IconFileType
7 | {
8 | [EnumMember(Value = @"png")]
9 | Png = 0,
10 |
11 | [EnumMember(Value = @"jpeg")]
12 | Jpeg = 1,
13 |
14 | [EnumMember(Value = @"ico")]
15 | Ico = 2,
16 |
17 | }
18 |
19 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
20 | public enum IconResolution
21 | {
22 | [EnumMember(Value = @"custom")]
23 | Custom = 0,
24 |
25 | [EnumMember(Value = @"16x16")]
26 | _16x16 = 1,
27 |
28 | [EnumMember(Value = @"20x20")]
29 | _20x20 = 2,
30 |
31 | [EnumMember(Value = @"24x24")]
32 | _24x24 = 3,
33 |
34 | [EnumMember(Value = @"30x30")]
35 | _30x30 = 4,
36 |
37 | [EnumMember(Value = @"32x32")]
38 | _32x32 = 5,
39 |
40 | [EnumMember(Value = @"36x36")]
41 | _36x36 = 6,
42 |
43 | [EnumMember(Value = @"40x40")]
44 | _40x40 = 7,
45 |
46 | [EnumMember(Value = @"48x48")]
47 | _48x48 = 8,
48 |
49 | [EnumMember(Value = @"60x60")]
50 | _60x60 = 9,
51 |
52 | [EnumMember(Value = @"64x64")]
53 | _64x64 = 10,
54 |
55 | [EnumMember(Value = @"72x72")]
56 | _72x72 = 11,
57 |
58 | [EnumMember(Value = @"80x80")]
59 | _80x80 = 12,
60 |
61 | [EnumMember(Value = @"96x96")]
62 | _96x96 = 13,
63 |
64 | [EnumMember(Value = @"256x256")]
65 | _256x256 = 14,
66 |
67 | }
68 |
69 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
70 | public enum IconTheme
71 | {
72 | [EnumMember(Value = @"default")]
73 | Default = 0,
74 |
75 | [EnumMember(Value = @"light")]
76 | Light = 1,
77 |
78 | [EnumMember(Value = @"dark")]
79 | Dark = 2,
80 |
81 | [EnumMember(Value = @"highContrast")]
82 | HighContrast = 3,
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/InstallModes.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public enum InstallModes
7 | {
8 |
9 | [EnumMember(Value = @"interactive")]
10 | Interactive = 0,
11 |
12 | [EnumMember(Value = @"silent")]
13 | Silent = 1,
14 |
15 | [EnumMember(Value = @"silentWithProgress")]
16 | SilentWithProgress = 2,
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/InstallerArchitecture.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System.Runtime.Serialization;
3 |
4 | namespace WinGet.Sharp.Enums;
5 |
6 | [JsonConverter(typeof(EnumIgnoreCaseStringConverter))]
7 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
8 | public enum InstallerArchitecture
9 | {
10 | [EnumMember(Value = "x86")]
11 | X86 = 0,
12 |
13 | [EnumMember(Value = "x64")]
14 | X64 = 1,
15 |
16 | [EnumMember(Value = "arm")]
17 | Arm = 2,
18 |
19 | [EnumMember(Value = "arm64")]
20 | Arm64 = 3,
21 |
22 | [EnumMember(Value = "neutral")]
23 | Neutral = 4,
24 | }
25 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/InstallerType.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System.Runtime.Serialization;
3 |
4 | namespace WinGet.Sharp.Enums;
5 |
6 | [JsonConverter(typeof(EnumIgnoreCaseStringConverter))]
7 | public enum InstallerType
8 | {
9 | [EnumMember(Value = "unknown")]
10 | Unknown = -1,
11 |
12 |
13 | [EnumMember(Value = "msix")]
14 | Msix = 0,
15 |
16 | [EnumMember(Value = "msi")]
17 | Msi = 1,
18 |
19 | [EnumMember(Value = "appx")]
20 | Appx = 2,
21 |
22 | [EnumMember(Value = "exe")]
23 | Exe = 3,
24 |
25 | [EnumMember(Value = "zip")]
26 | Zip = 4,
27 |
28 | [EnumMember(Value = "inno")]
29 | Inno = 5,
30 |
31 | [EnumMember(Value = "nullsoft")]
32 | Nullsoft = 6,
33 |
34 | [EnumMember(Value = "wix")]
35 | Wix = 7,
36 |
37 | [EnumMember(Value = "burn")]
38 | Burn = 8,
39 |
40 | [EnumMember(Value = "pwa")]
41 | Pwa = 9,
42 |
43 | [EnumMember(Value = "portable")]
44 | Portable = 10,
45 | }
46 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/ManifestType.cs:
--------------------------------------------------------------------------------
1 | namespace WinGet.Sharp.Enums;
2 |
3 | public enum ManifestType : byte
4 | {
5 | DefaultLocale,
6 | Installer,
7 | Locale,
8 | Manifest,
9 | Version
10 | }
11 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/Platform.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public enum Platform
7 | {
8 |
9 | [EnumMember(Value = @"Windows.Desktop")]
10 | WindowsDesktop = 0,
11 |
12 | [EnumMember(Value = @"Windows.Universal")]
13 | WindowsUniversal = 1,
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/Scope.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | ///
6 | /// Scope indicates if the installer is per user or per machine
7 | ///
8 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
9 | public enum Scope
10 | {
11 |
12 | [EnumMember(Value = @"user")]
13 | User = 0,
14 |
15 | [EnumMember(Value = @"machine")]
16 | Machine = 1,
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/UpgradeBehavior.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.Serialization;
2 |
3 | namespace WinGet.Sharp.Enums;
4 |
5 | ///
6 | /// The upgrade method
7 | ///
8 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
9 | public enum UpgradeBehavior
10 | {
11 |
12 | [EnumMember(Value = @"install")]
13 | Install = 0,
14 |
15 | [EnumMember(Value = @"uninstallPrevious")]
16 | UninstallPrevious = 1,
17 |
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Enums/YamlStringEnumConverter.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.Serialization;
3 | using YamlDotNet.Core;
4 | using YamlDotNet.Core.Events;
5 | using YamlDotNet.Serialization;
6 |
7 | namespace WinGet.Sharp.Enums;
8 |
9 | public class YamlStringEnumConverter : IYamlTypeConverter
10 | {
11 | public bool Accepts(Type type) => type.IsEnum;
12 |
13 | public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
14 | {
15 | var parsedEnum = parser.Consume();
16 | var serializableValues = type.GetMembers()
17 | .Select(m => new
18 | {
19 | Key = m.GetCustomAttributes(true).Select(ema => ema.Value).FirstOrDefault(),
20 | Value = m
21 | })
22 | .Where(pa => !string.IsNullOrEmpty(pa.Key))
23 | .ToDictionary(pa => pa.Key!, pa => pa.Value);
24 |
25 | if (!serializableValues.ContainsKey(parsedEnum.Value))
26 | {
27 | if (parsedEnum.Value == "null")
28 | return null;
29 |
30 | return Enum.Parse(type, parsedEnum.Value, true);
31 | }
32 |
33 | return Enum.Parse(type, serializableValues[parsedEnum.Value].Name);
34 | }
35 |
36 | public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer rootSerializer)
37 | {
38 | if (value is null)
39 | {
40 | emitter.Emit(new Scalar("~"));
41 | return;
42 | }
43 |
44 | var enumMember = type.GetMember(value.ToString()!).FirstOrDefault();
45 | var yamlValue = enumMember?.GetCustomAttributes(true).Select(ema => ema.Value).FirstOrDefault() ?? value.ToString();
46 | emitter.Emit(new Scalar(yamlValue));
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Agreement.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using YamlDotNet.Serialization;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
7 | public class Agreement
8 | {
9 | ///
10 | /// The label of the Agreement. i.e. EULA, AgeRating, etc. This field should be localized. Either Agreement or AgreementUrl is required. When we show the agreements, we would Bold the AgreementLabel
11 | ///
12 | [StringLength(100, MinimumLength = 1)]
13 | public string AgreementLabel { get; set; }
14 |
15 | ///
16 | /// The agreement text content.
17 | ///
18 | [YamlMember(Alias = "Agreement")]
19 | [StringLength(10000, MinimumLength = 1)]
20 | public string AgreementContent { get; set; }
21 |
22 | ///
23 | /// The agreement URL.
24 | ///
25 | [StringLength(2048)]
26 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
27 | public string AgreementUrl { get; set; }
28 | }
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/AppsAndFeaturesEntry.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using WinGet.Sharp.Enums;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | ///
7 | /// Various key values under installer's ARP entry
8 | ///
9 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
10 | public class AppsAndFeaturesEntry
11 | {
12 | ///
13 | /// The DisplayName registry value
14 | ///
15 | [StringLength(256, MinimumLength = 1)]
16 | public string DisplayName { get; set; }
17 |
18 | ///
19 | /// The Publisher registry value
20 | ///
21 | [StringLength(256, MinimumLength = 1)]
22 | public string Publisher { get; set; }
23 |
24 | ///
25 | /// The DisplayVersion registry value
26 | ///
27 | [StringLength(128, MinimumLength = 1)]
28 | public string DisplayVersion { get; set; }
29 |
30 | public string ProductCode { get; set; }
31 |
32 | public string UpgradeCode { get; set; }
33 |
34 | public InstallerType? InstallerType { get; set; }
35 | }
36 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/DefaultLocale.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace WinGet.Sharp.Models;
4 |
5 | ///
6 | /// A representation of a multiple-file manifest representing a default app metadata in the OWC. v1.1.0
7 | ///
8 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
9 | public class DefaultLocale : Locale
10 | {
11 | public DefaultLocale()
12 | {
13 | ManifestType = Enums.ManifestType.DefaultLocale;
14 | }
15 |
16 | ///
17 | /// The most common package term
18 | ///
19 | [StringLength(40, MinimumLength = 1)]
20 | public string Moniker { get; set; }
21 | }
22 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Dependencies.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
7 | public class Dependencies
8 | {
9 | ///
10 | /// List of Windows feature dependencies
11 | ///
12 | [MaxLength(16)]
13 | public List WindowsFeatures { get; set; }
14 |
15 | ///
16 | /// List of Windows library dependencies
17 | ///
18 | [MaxLength(16)]
19 | public List WindowsLibraries { get; set; }
20 |
21 | ///
22 | /// List of package dependencies from current source
23 | ///
24 | [MaxLength(16)]
25 | public List PackageDependencies { get; set; }
26 |
27 | ///
28 | /// List of external package dependencies
29 | ///
30 | [MaxLength(16)]
31 | public List ExternalDependencies { get; set; }
32 | }
33 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Document.cs:
--------------------------------------------------------------------------------
1 | namespace WinGet.Sharp.Models;
2 |
3 | public class Document
4 | {
5 | ///
6 | /// Represents the label for a documentation
7 | ///
8 | public string DocumentLabel { get; set; }
9 |
10 | ///
11 | /// Represents the URL for a documentation
12 | ///
13 | public string DocumentUrl { get; set; }
14 | }
15 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/ExpectedReturnCode.cs:
--------------------------------------------------------------------------------
1 | using WinGet.Sharp.Enums;
2 |
3 | namespace WinGet.Sharp.Models;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public partial class ExpectedReturnCode
7 | {
8 | public long InstallerReturnCode { get; set; }
9 |
10 | public ExpectedReturnCodeReturnResponse ReturnResponse { get; set; }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/IManifest.cs:
--------------------------------------------------------------------------------
1 | using WinGet.Sharp.Enums;
2 |
3 | namespace WinGet.Sharp.Models;
4 |
5 | public interface IManifest
6 | {
7 | public ManifestType ManifestType { get; set; }
8 |
9 | public string ManifestVersion { get; set; }
10 | }
11 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Icon.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System.ComponentModel.DataAnnotations;
3 | using WinGet.Sharp.Enums;
4 |
5 | namespace WinGet.Sharp.Models;
6 |
7 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.4.3.0 (Newtonsoft.Json v11.0.0.0)")]
8 | public partial class Icon
9 | {
10 | /// The url of the hosted icon file
11 | [StringLength(2048)]
12 | public string IconUrl { get; set; }
13 |
14 | /// The icon file type
15 | [Required(AllowEmptyStrings = true)]
16 | public IconFileType IconFileType { get; set; }
17 |
18 | /// Optional icon resolution
19 | public IconResolution? IconResolution { get; set; }
20 |
21 | /// Optional icon theme
22 | public IconTheme? IconTheme { get; set; }
23 |
24 | /// Optional Sha256 of the icon file
25 | [RegularExpression(@"^[A-Fa-f0-9]{64}$")]
26 | public string IconSha256 { get; set; }
27 |
28 | private IDictionary _additionalProperties = new Dictionary();
29 |
30 | [JsonExtensionData]
31 | public IDictionary AdditionalProperties
32 | {
33 | get => _additionalProperties;
34 | set => _additionalProperties = value;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Installer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 | using WinGet.Sharp.Enums;
4 |
5 | namespace WinGet.Sharp.Models;
6 |
7 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
8 | public class Installer
9 | {
10 | [StringLength(20)]
11 | [RegularExpression(@"^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$")]
12 | public string InstallerLocale { get; set; }
13 |
14 | ///
15 | /// The installer supported operating system
16 | ///
17 | [MaxLength(2)]
18 | public List Platform { get; set; }
19 |
20 | [RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){0,3}$")]
21 | public string MinimumOSVersion { get; set; }
22 |
23 | ///
24 | /// The installer target architecture
25 | ///
26 | [Required(AllowEmptyStrings = true)]
27 | public InstallerArchitecture Architecture { get; set; }
28 |
29 | public InstallerType? InstallerType { get; set; }
30 |
31 | public Scope? Scope { get; set; }
32 |
33 | ///
34 | /// The installer Url
35 | ///
36 | [Required(AllowEmptyStrings = true)]
37 | [StringLength(2048)]
38 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
39 | public string InstallerUrl { get; set; }
40 |
41 | ///
42 | /// Sha256 is required. Sha256 of the installer
43 | ///
44 | [Required(AllowEmptyStrings = true)]
45 | [RegularExpression(@"^[A-Fa-f0-9]{64}$")]
46 | public string InstallerSha256 { get; set; }
47 |
48 | ///
49 | /// SignatureSha256 is recommended for appx or msix. It is the sha256 of signature file inside appx or msix. Could be used during streaming install if applicable
50 | ///
51 | [RegularExpression(@"^[A-Fa-f0-9]{64}$")]
52 | public string SignatureSha256 { get; set; }
53 |
54 | ///
55 | /// The installer type when InstallerType is an archive type.
56 | /// This is the installer type of the file within the archive which will be used as the installer.
57 | ///
58 | public InstallerType? NestedInstallerType { get; set; }
59 |
60 | ///
61 | /// NestedInstallerFiles is required when InstallerType is an archive type such as .
62 | /// This is a list of all the installers to be executed within an archive.
63 | /// This field can only contain one nested installer file unless the is .
64 | ///
65 | public List NestedInstallerFiles { get; set; }
66 |
67 | [MaxLength(3)]
68 | public List InstallModes { get; set; }
69 |
70 | public InstallerSwitches InstallerSwitches { get; set; }
71 |
72 | ///
73 | /// List of additional non-zero installer success exit codes other than known default values by winget
74 | ///
75 | [MaxLength(16)]
76 | public List InstallerSuccessCodes { get; set; }
77 |
78 | ///
79 | /// Installer exit codes for common errors
80 | ///
81 | [MaxLength(128)]
82 | public List ExpectedReturnCodes { get; set; }
83 |
84 | public UpgradeBehavior? UpgradeBehavior { get; set; }
85 |
86 | ///
87 | /// List of commands or aliases to run the package
88 | ///
89 | [MaxLength(16)]
90 | public List Commands { get; set; }
91 |
92 | ///
93 | /// List of protocols the package provides a handler for
94 | ///
95 | [MaxLength(16)]
96 | public List Protocols { get; set; }
97 |
98 | ///
99 | /// List of file extensions the package could support
100 | ///
101 | [MaxLength(256)]
102 | public List FileExtensions { get; set; }
103 |
104 | public Dependencies Dependencies { get; set; }
105 |
106 | [StringLength(255)]
107 | [RegularExpression(@"^[A-Za-z0-9][-\.A-Za-z0-9]+_[A-Za-z0-9]{13}$")]
108 | public string PackageFamilyName { get; set; }
109 |
110 | [StringLength(255, MinimumLength = 1)]
111 | public string ProductCode { get; set; }
112 |
113 | ///
114 | /// List of APPX or MSIX installer capabilities
115 | ///
116 | [MaxLength(1000)]
117 | public List Capabilities { get; set; }
118 |
119 | ///
120 | /// List of APPX or MSIX installer restricted capabilities
121 | ///
122 | [MaxLength(1000)]
123 | public List RestrictedCapabilities { get; set; }
124 |
125 | ///
126 | /// Optional markets the package is allowed to be installed
127 | ///
128 | public List Markets { get; set; }
129 |
130 | ///
131 | /// Optional markets the package is not allowed to be installed
132 | ///
133 | public List ExcludedMarkets { get; set; }
134 |
135 | public bool? InstallerAbortsTerminal { get; set; }
136 |
137 | //[Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))]
138 | public DateTimeOffset? ReleaseDate { get; set; }
139 |
140 | public bool? InstallLocationRequired { get; set; }
141 |
142 | public bool? RequireExplicitUpgrade { get; set; }
143 |
144 | ///
145 | /// List of OS architectures the installer does not support
146 | ///
147 | public List UnsupportedOSArchitectures { get; set; }
148 |
149 | ///
150 | /// List of ARP entries.
151 | ///
152 | [MaxLength(128)]
153 | public List AppsAndFeaturesEntries { get; set; }
154 |
155 | public ElevationRequirement? ElevationRequirement { get; set; }
156 |
157 | public bool IsNested() => InstallerType == Enums.InstallerType.Zip;
158 | }
159 |
160 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
161 | internal class DateFormatConverter : Newtonsoft.Json.Converters.IsoDateTimeConverter
162 | {
163 | public DateFormatConverter()
164 | {
165 | DateTimeFormat = "yyyy-MM-dd";
166 | }
167 | }
168 |
169 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/InstallerManifest.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using WinGet.Sharp.Enums;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | ///
7 | /// A representation of a single-file manifest representing an app installers in the OWC. v1.1.0
8 | ///
9 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
10 | public class InstallerManifest : IManifest
11 | {
12 | [Required(AllowEmptyStrings = true)]
13 | [StringLength(128)]
14 | [RegularExpression(@"^[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}(\.[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}){1,3}$")]
15 | public string PackageIdentifier { get; set; }
16 |
17 | [Required(AllowEmptyStrings = true)]
18 | [StringLength(128)]
19 | [RegularExpression(@"^[^\\/:\*\?""<>\|\x01-\x1f]+$")]
20 | public string PackageVersion { get; set; }
21 |
22 | [StringLength(16, MinimumLength = 1)]
23 | public string Channel { get; set; }
24 |
25 | [StringLength(20)]
26 | [RegularExpression(@"^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$")]
27 | public string InstallerLocale { get; set; }
28 |
29 | ///
30 | /// The installer supported operating system
31 | ///
32 | [MaxLength(2)]
33 | public List Platform { get; set; }
34 |
35 | [RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){0,3}$")]
36 | public string MinimumOSVersion { get; set; }
37 |
38 | public InstallerType? InstallerType { get; set; }
39 |
40 | public Scope? Scope { get; set; }
41 |
42 | [MaxLength(3)]
43 | public List InstallModes { get; set; }
44 |
45 | public InstallerSwitches InstallerSwitches { get; set; }
46 |
47 | ///
48 | /// List of additional non-zero installer success exit codes other than known default values by winget
49 | ///
50 | [MaxLength(16)]
51 | public List InstallerSuccessCodes { get; set; }
52 |
53 | ///
54 | /// Installer exit codes for common errors
55 | ///
56 | [MaxLength(128)]
57 | public List ExpectedReturnCodes { get; set; }
58 |
59 | public UpgradeBehavior? UpgradeBehavior { get; set; }
60 |
61 | ///
62 | /// List of commands or aliases to run the package
63 | ///
64 | [MaxLength(16)]
65 | public List Commands { get; set; }
66 |
67 | ///
68 | /// List of protocols the package provides a handler for
69 | ///
70 | [MaxLength(16)]
71 | public List Protocols { get; set; }
72 |
73 | ///
74 | /// List of file extensions the package could support
75 | ///
76 | [MaxLength(256)]
77 | public List FileExtensions { get; set; }
78 |
79 | public Dependencies Dependencies { get; set; }
80 |
81 | [StringLength(255)]
82 | [RegularExpression(@"^[A-Za-z0-9][-\.A-Za-z0-9]+_[A-Za-z0-9]{13}$")]
83 | public string PackageFamilyName { get; set; }
84 |
85 | [StringLength(255, MinimumLength = 1)]
86 | public string ProductCode { get; set; }
87 |
88 | ///
89 | /// List of APPX or MSIX installer capabilities
90 | ///
91 | [MaxLength(1000)]
92 | public List Capabilities { get; set; }
93 |
94 | ///
95 | /// List of APPX or MSIX installer restricted capabilities
96 | ///
97 | [MaxLength(1000)]
98 | public List RestrictedCapabilities { get; set; }
99 |
100 | ///
101 | /// Optional markets the package is allowed to be installed
102 | ///
103 | public List Markets { get; set; }
104 |
105 | ///
106 | /// Optional markets the package is not allowed to be installed
107 | ///
108 | public List ExcludedMarkets { get; set; }
109 |
110 | public bool? InstallerAbortsTerminal { get; set; }
111 |
112 | //[Newtonsoft.Json.JsonConverter(typeof(DateFormatConverter))]
113 | public DateTimeOffset? ReleaseDate { get; set; }
114 |
115 | public bool? InstallLocationRequired { get; set; }
116 |
117 | public bool? RequireExplicitUpgrade { get; set; }
118 |
119 | ///
120 | /// List of OS architectures the installer does not support
121 | ///
122 | public List UnsupportedOSArchitectures { get; set; }
123 |
124 | ///
125 | /// List of ARP entries.
126 | ///
127 | [MaxLength(128)]
128 | public List AppsAndFeaturesEntries { get; set; }
129 |
130 | public ElevationRequirement? ElevationRequirement { get; set; }
131 |
132 | [Required]
133 | [MinLength(1)]
134 | [MaxLength(1024)]
135 | public List Installers { get; set; } = new List();
136 |
137 | ///
138 | /// The manifest type
139 | ///
140 | [Required(AllowEmptyStrings = true)]
141 | public ManifestType ManifestType { get; set; } = ManifestType.Installer;
142 |
143 | ///
144 | /// The manifest syntax version
145 | ///
146 | [Required(AllowEmptyStrings = true)]
147 | [RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")]
148 | public string ManifestVersion { get; set; } = "1.1.0";
149 | }
150 |
151 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/InstallerSwitches.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace WinGet.Sharp.Models;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public class InstallerSwitches
7 | {
8 | ///
9 | /// Silent is the value that should be passed to the installer when user chooses a silent or quiet install
10 | ///
11 | [StringLength(512, MinimumLength = 1)]
12 | public string Silent { get; set; }
13 |
14 | ///
15 | /// SilentWithProgress is the value that should be passed to the installer when user chooses a non-interactive install
16 | ///
17 | [StringLength(512, MinimumLength = 1)]
18 | public string SilentWithProgress { get; set; }
19 |
20 | ///
21 | /// Interactive is the value that should be passed to the installer when user chooses an interactive install
22 | ///
23 | [StringLength(512, MinimumLength = 1)]
24 | public string Interactive { get; set; }
25 |
26 | ///
27 | /// InstallLocation is the value passed to the installer for custom install location. <INSTALLPATH> token can be included in the switch value so that winget will replace the token with user provided path
28 | ///
29 | [StringLength(512, MinimumLength = 1)]
30 | public string InstallLocation { get; set; }
31 |
32 | ///
33 | /// Log is the value passed to the installer for custom log file path. <LOGPATH> token can be included in the switch value so that winget will replace the token with user provided path
34 | ///
35 | [StringLength(512, MinimumLength = 1)]
36 | public string Log { get; set; }
37 |
38 | ///
39 | /// Upgrade is the value that should be passed to the installer when user chooses an upgrade
40 | ///
41 | [StringLength(512, MinimumLength = 1)]
42 | public string Upgrade { get; set; }
43 |
44 | ///
45 | /// Custom switches will be passed directly to the installer by winget
46 | ///
47 | [StringLength(2048, MinimumLength = 1)]
48 | public string Custom { get; set; }
49 | }
50 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Locale.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.ComponentModel.DataAnnotations;
3 | using WinGet.Sharp.Enums;
4 |
5 | namespace WinGet.Sharp.Models;
6 |
7 | ///
8 | /// A representation of a multiple-file manifest representing app metadata in other locale in the OWC. v1.1.0
9 | ///
10 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
11 | public class Locale : IManifest
12 | {
13 | ///
14 | /// The package unique identifier
15 | ///
16 | [Required(AllowEmptyStrings = true)]
17 | [StringLength(128)]
18 | [RegularExpression(@"^[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}(\.[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}){1,3}$")]
19 | public string PackageIdentifier { get; set; }
20 |
21 | ///
22 | /// The package version
23 | ///
24 | [Required(AllowEmptyStrings = true)]
25 | [StringLength(128)]
26 | [RegularExpression(@"^[^\\/:\*\?""<>\|\x01-\x1f]+$")]
27 | public string PackageVersion { get; set; }
28 |
29 | ///
30 | /// The package meta-data locale
31 | ///
32 | [Required(AllowEmptyStrings = true)]
33 | [StringLength(20)]
34 | [RegularExpression(@"^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$")]
35 | public string PackageLocale { get; set; }
36 |
37 | ///
38 | /// The publisher name
39 | ///
40 | [StringLength(256, MinimumLength = 2)]
41 | public string Publisher { get; set; }
42 |
43 | ///
44 | /// The publisher home page
45 | ///
46 | [StringLength(2048)]
47 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
48 | public string PublisherUrl { get; set; }
49 |
50 | ///
51 | /// The publisher support page
52 | ///
53 | [StringLength(2048)]
54 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
55 | public string PublisherSupportUrl { get; set; }
56 |
57 | ///
58 | /// The publisher privacy page or the package privacy page
59 | ///
60 | [StringLength(2048)]
61 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
62 | public string PrivacyUrl { get; set; }
63 |
64 | ///
65 | /// The package author
66 | ///
67 | [StringLength(256, MinimumLength = 2)]
68 | public string Author { get; set; }
69 |
70 | ///
71 | /// The package name
72 | ///
73 | [StringLength(256, MinimumLength = 2)]
74 | public string PackageName { get; set; }
75 |
76 | ///
77 | /// The package home page
78 | ///
79 | [StringLength(2048)]
80 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
81 | public string PackageUrl { get; set; }
82 |
83 | ///
84 | /// The package license
85 | ///
86 | [StringLength(512, MinimumLength = 3)]
87 | public string License { get; set; }
88 |
89 | ///
90 | /// The license page
91 | ///
92 | [StringLength(2048)]
93 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
94 | public string LicenseUrl { get; set; }
95 |
96 | ///
97 | /// The package copyright
98 | ///
99 | [StringLength(512, MinimumLength = 3)]
100 | public string Copyright { get; set; }
101 |
102 | ///
103 | /// The package copyright page
104 | ///
105 | [StringLength(2048)]
106 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
107 | public string CopyrightUrl { get; set; }
108 |
109 | ///
110 | /// The short package description
111 | ///
112 | [StringLength(256, MinimumLength = 3)]
113 | public string ShortDescription { get; set; }
114 |
115 | ///
116 | /// The full package description
117 | ///
118 | [StringLength(10000, MinimumLength = 3)]
119 | public string Description { get; set; }
120 |
121 | ///
122 | /// List of additional package search terms
123 | ///
124 | [MaxLength(16)]
125 | public List Tags { get; set; }
126 |
127 | [MaxLength(128)]
128 | public List Agreements { get; set; }
129 |
130 | ///
131 | /// Any documentation for providing software guides such as manuals and troubleshooting URLs
132 | ///
133 | [MaxLength(128)]
134 | public List Documentations { get; set; }
135 |
136 | ///
137 | /// The package release notes
138 | ///
139 | [StringLength(10000, MinimumLength = 1)]
140 | public string ReleaseNotes { get; set; }
141 |
142 | ///
143 | /// The package release notes url
144 | ///
145 | [StringLength(2048)]
146 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
147 | public string ReleaseNotesUrl { get; set; }
148 |
149 | ///
150 | /// The purchase url for acquiring entitlement for the package.
151 | ///
152 | [StringLength(2048)]
153 | [RegularExpression(@"^([Hh][Tt][Tt][Pp][Ss]?)://.+$")]
154 | public string PurchaseUrl { get; set; }
155 |
156 | ///
157 | /// The notes displayed to the user upon completion of a package installation.
158 | ///
159 | [StringLength(10000, MinimumLength = 13)]
160 | public string InstallationNotes { get; set; }
161 |
162 | [MaxLength(1024)]
163 | public List Icons { get; set; }
164 |
165 | ///
166 | /// The manifest type
167 | ///
168 | [Required(AllowEmptyStrings = true)]
169 | public virtual ManifestType ManifestType { get; set; } = ManifestType.Locale;
170 |
171 | ///
172 | /// The manifest syntax version
173 | ///
174 | [Required(AllowEmptyStrings = true)]
175 | [RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")]
176 | public string ManifestVersion { get; set; } = "1.5.0";
177 | }
178 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/NestedFile.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using WinGet.Sharp.Enums;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | public class NestedFile
7 | {
8 | ///
9 | /// The relative path to the installer file contained within the archive.
10 | ///
11 | [Required]
12 | public string RelativeFilePath { get; set; }
13 |
14 | ///
15 | /// The alias which is added to the PATH for calling the package from the command line.
16 | /// Only valid when is .
17 | ///
18 | public string? PortableCommandAlias { get; set; }
19 | }
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/PackageDependencies.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 |
3 | namespace WinGet.Sharp.Models;
4 |
5 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
6 | public partial class PackageDependency
7 | {
8 | [Required(AllowEmptyStrings = true)]
9 | [StringLength(128)]
10 | [RegularExpression(@"^[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}(\.[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}){1,3}$")]
11 | public string PackageIdentifier { get; set; }
12 |
13 | [StringLength(128)]
14 | [RegularExpression(@"^[^\\/:\*\?""<>\|\x01-\x1f]+$")]
15 | public string MinimumVersion { get; set; }
16 | }
17 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/Models/Version.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel.DataAnnotations;
2 | using WinGet.Sharp.Enums;
3 |
4 | namespace WinGet.Sharp.Models;
5 |
6 | ///
7 | /// A representation of a multi-file manifest representing an app version in the OWC. v1.1.0
8 | ///
9 | [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.6.9.0 (Newtonsoft.Json v13.0.0.0)")]
10 | public class VersionManifest : IManifest
11 | {
12 | ///
13 | /// The package unique identifier
14 | ///
15 | [Required(AllowEmptyStrings = true)]
16 | [StringLength(128)]
17 | [RegularExpression(@"^[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}(\.[^\.\s\\/:\*\?""<>\|\x01-\x1f]{1,32}){1,3}$")]
18 | public string PackageIdentifier { get; set; }
19 |
20 | ///
21 | /// The package version
22 | ///
23 | [Required(AllowEmptyStrings = true)]
24 | [StringLength(128)]
25 | [RegularExpression(@"^[^\\/:\*\?""<>\|\x01-\x1f]+$")]
26 | public string PackageVersion { get; set; }
27 |
28 | ///
29 | /// The default package meta-data locale
30 | ///
31 | [Required(AllowEmptyStrings = true)]
32 | [StringLength(20)]
33 | [RegularExpression(@"^([a-zA-Z]{2,3}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*$")]
34 | public string DefaultLocale { get; set; } = "en-US";
35 |
36 | ///
37 | /// The manifest type
38 | ///
39 | [Required(AllowEmptyStrings = true)]
40 | public ManifestType ManifestType { get; set; } = ManifestType.Version;
41 |
42 | ///
43 | /// The manifest syntax version
44 | ///
45 | [Required(AllowEmptyStrings = true)]
46 | [RegularExpression(@"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(\.(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])){2}$")]
47 | public string ManifestVersion { get; set; } = "1.1.0";
48 |
49 | public override string ToString() => $"{PackageIdentifier}/{PackageVersion}";
50 | }
51 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/WinGet.Sharp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows10.0.22621;netstandard2.0
5 | false
6 | true
7 |
8 | enable
9 | enable
10 | true
11 | latest
12 |
13 | 1.8.1911
14 | 10.0.17763.0
15 |
16 |
17 |
18 | $(WinGetComVersion).0
19 | Joshua Askharoun,Microsoft
20 | A C# projection of the Windows Package Manager API provided by WinGet. Also includes models and wrappers around the WinGet Community Repository.
21 | https://github.com/yoshiask/winget-sharp
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | all
36 |
37 |
38 |
39 | true
40 | build
41 |
42 |
43 |
44 | true
45 | build
46 |
47 |
48 |
49 |
50 |
51 | 10.0.22621.0
52 | Microsoft.Management.Deployment
53 | Windows.Foundation.Diagnostics
54 |
55 | $(ReferencePath);$(PkgMicrosoft_WindowsPackageManager_ComInterop)
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/WinGet.Sharp.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 | <_WPMwinmd>$(MSBuildThisFileDirectory)*.winmd
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/WinGet.Sharp/WinGetFactory.cs:
--------------------------------------------------------------------------------
1 | #if WINDOWS
2 |
3 | using Microsoft.Management.Deployment;
4 | using System.Diagnostics.Contracts;
5 | using System.Runtime.InteropServices;
6 | using WinRT;
7 |
8 | namespace WinGet.Sharp;
9 |
10 | public static class WinGetFactory
11 | {
12 | [Pure]
13 | public static PackageManager CreatePackageManager() => CreateInstance(new("C53A4F16-787E-42A4-B304-29EFFB4BF597"));
14 |
15 | [Pure]
16 | public static FindPackagesOptions CreateFindPackagesOptions() => CreateInstance(new("572DED96-9C60-4526-8F92-EE7D91D38C1A"));
17 |
18 | [Pure]
19 | public static CreateCompositePackageCatalogOptions CreateCompositePackageCatalogOptions() => CreateInstance(new("526534B8-7E46-47C8-8416-B1685C327D37"));
20 |
21 | [Pure]
22 | public static InstallOptions CreateInstallOptions() => CreateInstance(new("1095F097-EB96-453B-B4E6-1613637F3B14"));
23 |
24 | [Pure]
25 | public static UninstallOptions CreateUninstallOptions() => CreateInstance(new("E1D9A11E-9F85-4D87-9C17-2B93143ADB8D"));
26 |
27 | [Pure]
28 | public static PackageMatchFilter CreatePackageMatchFilter() => CreateInstance(new("D02C9DAF-99DC-429C-B503-4E504E4AB000"));
29 |
30 | [Pure]
31 | public static DownloadOptions CreateDownloadOptions() => CreateInstance(new("4CBABE76-7322-4BE4-9CEA-2589A80682DC"));
32 |
33 | [Pure]
34 | public static AuthenticationArguments CreateAuthenticationArguments() => CreateInstance(new("BA580786-BDE3-4F6C-B8F3-44698AC8711A"));
35 |
36 | #if false
37 | public static ConfigurationStaticFunctions CreateConfigurationStaticFunctions() => CreateInstance(new("73D763B7-2937-432F-A97A-D98A4A596126"));
38 | public static PackageManagerSettings CreatePackageManagerSettings() => CreateInstance(new("80CF9D63-5505-4342-B9B4-BB87895CA8BB"));
39 | #endif
40 |
41 | [Pure]
42 | private static T CreateInstance(Guid clsid)
43 | {
44 | T obj;
45 | Type packageManagerType = Type.GetTypeFromCLSID(clsid, true)!;
46 | var unk = Activator.CreateInstance(packageManagerType)!;
47 |
48 | unsafe
49 | {
50 | var pUnk = Marshal.GetIUnknownForObject(unk);
51 | obj = MarshalInspectable.FromAbi(pUnk);
52 | }
53 |
54 | return obj;
55 | }
56 | }
57 |
58 | #endif
59 |
--------------------------------------------------------------------------------