private static async Task <string> GetLatestPackageVersionAsync(string packageId, CancellationToken cancellationToken = default) { var providers = new List <Lazy <INuGetResourceProvider> >(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support // We SHOULD use all the sources from the target's nuget.config file. // But I don't know what API to use to do that. var packageSource = new PackageSource("https://api.nuget.org/v3/index.json"); var sourceRepository = new SourceRepository(packageSource, providers); var resolutionContext = new ResolutionContext( DependencyBehavior.Highest, includePrelease: false, includeUnlisted: false, VersionConstraints.None); // The target framework doesn't matter, since our package doesn't depend on this for its target projects. var framework = new NuGet.Frameworks.NuGetFramework("net45"); var pkg = await NuGetPackageManager.GetLatestVersionAsync( packageId, framework, resolutionContext, sourceRepository, NullLogger.Instance, cancellationToken); return(pkg.LatestVersion.ToNormalizedString()); }
private List <NugetDependency> GetDependencies() { NuGet.PackageReferenceFile configFile = new NuGet.PackageReferenceFile(PackagesConfigPath); List <NuGet.PackageReference> packages = new List <NuGet.PackageReference>(configFile.GetPackageReferences()); var dependencies = new List <NugetDependency>(); foreach (var packageRef in packages) { string componentName = packageRef.Id; var version = new NuGet.Versioning.NuGetVersion(packageRef.Version.Version, packageRef.Version.SpecialVersion, packageRef.Version.Metadata); var versionRange = new NuGet.Versioning.VersionRange(version, true, version, true); NuGet.Frameworks.NuGetFramework framework = null; if (packageRef.TargetFramework != null) { try { framework = NuGet.Frameworks.NuGetFramework.Parse(packageRef.TargetFramework.FullName); } catch (Exception e) { Console.WriteLine("Unable to parse framework: " + packageRef.TargetFramework.FullName); } } var dep = new NugetDependency(componentName, versionRange, framework); dependencies.Add(dep); } return(dependencies); }
public DependencyResolverCache(Func <DependencyNode, IEnumerable <SatisfyingInfo> > fallbackSatisfyingInfos, NuGet.Frameworks.NuGetFramework framework) { _versionCache = new Dictionary <string, List <SatisfyingInfo> >(); _manifestCache = new Dictionary <PackageKey, PackageManifest>(); _fallbackSatisfyingInfos = fallbackSatisfyingInfos; _framework = framework; }
private static IEnumerable <NuGet.Packaging.PackageDependencyGroup> ToNuGetPackageDependencyGroup( this IEnumerable <PackageDependency> packageDependency, NuGet.Frameworks.NuGetFramework framework) { var dependencies = new NuGet.Packaging.PackageDependencyGroup(framework, packageDependency.Select(p => p.ToNuGetPackageDependency())); return(dependencies.Packages.Any() ? new[] { dependencies } : new NuGet.Packaging.PackageDependencyGroup[0]); //return packageDependency // .GroupBy(dependency => dependency.Framework, dependency => dependency) // .Select(grupedDepenencies => new NuGet.Packaging.PackageDependencyGroup( // grupedDepenencies.Key, // grupedDepenencies.Select(dependency => dependency.ToNuGetPackageDependency()))); }
public PackageManifest GetManifest(PackageKey key, NuGet.Frameworks.NuGetFramework projectFramework) { if (key.Framework != null) { var fullPath = Path.Combine(RootPath, key.GetFileName()); if (!File.Exists(fullPath)) { throw new FileNotFoundException("package not found"); } using (IPackageReader reader = _packageReaderFactory.Get(RepositoryType.Pundit, File.OpenRead(fullPath))) return(reader.ReadManifest()); } // From here on, we resolve packages that come from a NuGet package and therefore, have no FW var filePattern = key.GetNoFrameworkFileName(); var results = new DirectoryInfo(RootPath).GetFiles(filePattern).ToArray(); if (results.Length == 0) { return(null); } var matches = 0; foreach (var info in results) { var tempKey = PackageExtensions.GetPackageKeyFromFileName(info.Name); var nearestFw = NuGet.Frameworks.NuGetFrameworkUtility.GetNearest(new[] { new FakedFrameworkGroup(tempKey.Framework) }, projectFramework); if (nearestFw.TargetFramework.GetShortFolderName() == tempKey.Framework) { matches++; } } if (matches != 1) { throw new NotSupportedException("Error, 0 or more than 1 package found matching the framework."); } using (IPackageReader reader = _packageReaderFactory.Get(RepositoryType.Pundit, File.OpenRead(results[0].FullName))) return(reader.ReadManifest()); }
private static async Task <string> GetLatestPackageVersionAsync(string packageId, string root, IReadOnlyList <string> sources, CancellationToken cancellationToken = default) { var settings = Settings.LoadDefaultSettings(root); var providers = new List <Lazy <INuGetResourceProvider> >(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers); // Select package sources based on NuGet.Config files or given options, as 'nuget.exe restore' command does // See also 'DownloadCommandBase.GetPackageSources(ISettings)' at https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.CommandLine/Commands/DownloadCommandBase.cs var availableSources = sourceRepositoryProvider.PackageSourceProvider.LoadPackageSources().Where(s => s.IsEnabled); var packageSources = new List <PackageSource>(); foreach (var source in sources) { var resolvedSource = availableSources.FirstOrDefault(s => s.Source.Equals(source, StringComparison.OrdinalIgnoreCase) || s.Name.Equals(source, StringComparison.OrdinalIgnoreCase)); packageSources.Add(resolvedSource ?? new PackageSource(source)); } if (sources.Count == 0) { packageSources.AddRange(availableSources); } var sourceRepositories = packageSources.Select(sourceRepositoryProvider.CreateRepository).ToArray(); var resolutionContext = new ResolutionContext( DependencyBehavior.Highest, includePrelease: false, includeUnlisted: false, VersionConstraints.None); // The target framework doesn't matter, since our package doesn't depend on this for its target projects. var framework = new NuGet.Frameworks.NuGetFramework("net45"); var pkg = await NuGetPackageManager.GetLatestVersionAsync( packageId, framework, resolutionContext, sourceRepositories, NullLogger.Instance, cancellationToken); return(pkg.LatestVersion?.ToNormalizedString()); }
public static bool IsNetCore50AndUp(NuGet.Frameworks.NuGetFramework framework) { throw null; }
public static T GetNearest <T>(System.Collections.Generic.IEnumerable <T> items, NuGet.Frameworks.NuGetFramework framework, System.Func <T, NuGet.Frameworks.NuGetFramework> selector) where T : class { throw null; }
public static T GetNearest <T>(System.Collections.Generic.IEnumerable <T> items, NuGet.Frameworks.NuGetFramework framework, NuGet.Frameworks.IFrameworkNameProvider frameworkMappings, NuGet.Frameworks.IFrameworkCompatibilityProvider compatibilityProvider) where T : NuGet.Frameworks.IFrameworkSpecific { throw null; }
public static bool IsDesktop(this NuGet.Frameworks.NuGetFramework framework) { throw null; }
public bool HasFramework(NuGet.Frameworks.NuGetFramework framework) { throw null; }
public static string GetName(NuGet.Frameworks.NuGetFramework framework, string runtimeIdentifier) { throw null; }
public int CompareFrameworks(NuGet.Frameworks.NuGetFramework x, NuGet.Frameworks.NuGetFramework y) { throw null; }
public System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework> GetFrameworksSupporting(NuGet.Frameworks.NuGetFramework target) { throw null; }
public FallbackFramework(NuGet.Frameworks.NuGetFramework framework, System.Collections.Generic.IReadOnlyList <NuGet.Frameworks.NuGetFramework> fallbackFrameworks) : base(default(NuGet.Frameworks.NuGetFramework)) { }
public NuGet.Frameworks.NuGetFramework GetNearest(NuGet.Frameworks.NuGetFramework framework, System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework> possibleFrameworks) { throw null; }
public FrameworkRuntimePair(NuGet.Frameworks.NuGetFramework framework, string runtimeIdentifier) { }
public NuGet.Frameworks.NuGetFramework GetShortNameReplacement(NuGet.Frameworks.NuGetFramework framework) { throw null; }
public System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework> GetNearest(NuGet.Frameworks.NuGetFramework framework) { throw null; }
public bool TryGetCompatibilityMappings(NuGet.Frameworks.NuGetFramework framework, out System.Collections.Generic.IEnumerable <NuGet.Frameworks.FrameworkRange> supportedFrameworkRanges) { supportedFrameworkRanges = default(System.Collections.Generic.IEnumerable <NuGet.Frameworks.FrameworkRange>); throw null; }
public bool TryGetCompatible(NuGet.Frameworks.NuGetFramework framework, out System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework> compatible) { compatible = default(System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework>); throw null; }
public bool TryGetEquivalentFrameworks(NuGet.Frameworks.NuGetFramework framework, out System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework> frameworks) { frameworks = default(System.Collections.Generic.IEnumerable <NuGet.Frameworks.NuGetFramework>); throw null; }
public static T GetNearest <T>(System.Collections.Generic.IEnumerable <T> items, NuGet.Frameworks.NuGetFramework framework) where T : NuGet.Frameworks.IFrameworkSpecific { throw null; }
public FrameworkRange(NuGet.Frameworks.NuGetFramework min, NuGet.Frameworks.NuGetFramework max) { }
public static T GetNearest <T>(System.Collections.Generic.IEnumerable <T> items, NuGet.Frameworks.NuGetFramework framework, NuGet.Frameworks.IFrameworkNameProvider frameworkMappings, NuGet.Frameworks.IFrameworkCompatibilityProvider compatibilityProvider, System.Func <T, NuGet.Frameworks.NuGetFramework> selector) where T : class { throw null; }
public FrameworkRange(NuGet.Frameworks.NuGetFramework min, NuGet.Frameworks.NuGetFramework max, bool includeMin, bool includeMax) { }
public static bool IsCompatibleWithFallbackCheck(NuGet.Frameworks.NuGetFramework projectFramework, NuGet.Frameworks.NuGetFramework candidate) { throw null; }
public bool IsCompatible(NuGet.Frameworks.NuGetFramework target, NuGet.Frameworks.NuGetFramework candidate) { throw null; }
/// <summary> /// Creates a Nuget package from a SmartInk Package /// </summary> /// <param name="package">Package to use for Nuget creation</param> /// <param name="destination">File handle for saving the Nuget package</param> public async Task PublishPackageAsync(ISmartInkPackage package, IStorageFile destination) { if (package == null) { throw new ArgumentNullException($"{nameof(package)} cannot be null"); } if (destination == null) { throw new ArgumentNullException($"{nameof(destination)} cannot be null"); } Debug.WriteLine($"Publish package"); ManifestMetadata metadata = new ManifestMetadata() { Title = $"{package.Name}", Owners = new string[] { "jabj" }, Authors = new string[] { "mauvo" }, Version = new NuGet.Versioning.NuGetVersion(new Version(package.Version)), Id = $"SmartInk.{package.Name}", Description = $"{package.Description}", MinClientVersionString = "3.3.0" }; NuGet.Frameworks.NuGetFramework targetFramework = new NuGet.Frameworks.NuGetFramework(new NuGet.Frameworks.NuGetFramework(".NETStandard2.0")); IEnumerable <NuGet.Packaging.Core.PackageDependency> packages = new NuGet.Packaging.Core.PackageDependency[] { new NuGet.Packaging.Core.PackageDependency("NETStandard.Library", new NuGet.Versioning.VersionRange(new NuGet.Versioning.NuGetVersion(2, 0, 0))) }; var dependencyGroup = new PackageDependencyGroup(targetFramework, packages); metadata.DependencyGroups = new PackageDependencyGroup[] { dependencyGroup }; PackageBuilder builder = new PackageBuilder(); builder.Populate(metadata); builder.ContentFiles.Add(new ManifestContentFiles() { Include = $"**/SmartInkPackages/*", CopyToOutput = "true", Flatten = "false", BuildAction = "None" }); builder.ContentFiles.Add(new ManifestContentFiles() { Include = $"**/SmartInkPackages/{package.Name}/*", CopyToOutput = "true", Flatten = "false", BuildAction = "None" }); builder.ContentFiles.Add(new ManifestContentFiles() { Include = $"**/SmartInkPackages/{package.Name}/Model/*", CopyToOutput = "true", Flatten = "false", BuildAction = "None" }); builder.ContentFiles.Add(new ManifestContentFiles() { Include = $"**/SmartInkPackages/{package.Name}/Icons/*", CopyToOutput = "true", Flatten = "false", BuildAction = "None" }); var root = $"{_provider.RootFolderPath}\\{package.Name}\\"; List <ManifestFile> manifestFiles = new List <ManifestFile>(); var rootFolder = await StorageFolder.GetFolderFromPathAsync(root); var files = await rootFolder.GetFilesAsync(Windows.Storage.Search.CommonFileQuery.OrderByName); foreach (var file in files) { ManifestFile manifestFile = new ManifestFile(); manifestFile.Source = file.Path; manifestFile.Target = $"contentFiles\\cs\\uap10.0\\SmartInkPackages{file.Path.Replace(_provider.RootFolderPath, "")}"; manifestFiles.Add(manifestFile); } builder.PopulateFiles(root, manifestFiles); using (var fileaccess = await destination.OpenAsync(FileAccessMode.ReadWrite)) { Debug.WriteLine($"Publish package: {builder.ToString()}"); var stream = fileaccess.AsStreamForWrite(); builder.Save(stream); await stream.FlushAsync(); } }
public bool Satisfies(NuGet.Frameworks.NuGetFramework framework) { throw null; }