public static IEnumerable <SourceRepository> GetRepositories( this ISourceRepositoryProvider repositoryProvider, IEnumerable <PackageSourceInfo> sources) { var allRepositories = repositoryProvider.GetRepositories().ToList(); var repositories = new List <SourceRepository> (); foreach (PackageSourceInfo source in sources) { var packageSource = new NuGet.Configuration.PackageSource(source.Source, source.Name); SourceRepository matchedRepository = FindSourceRepository(packageSource, allRepositories); if (matchedRepository != null) { repositories.Add(matchedRepository); } else { var repository = repositoryProvider.CreateRepository(packageSource); repositories.Add(repository); } } return(repositories); }
/// <summary> /// Create a package repository from the source by trying to resolve relative paths. /// </summary> SourceRepository CreateRepositoryFromSource(string source) { var packageSource = new PackageSource(source); var repository = sourceRepositoryProvider.CreateRepository(packageSource); var resource = repository.GetResource <PackageSearchResource> (); return(repository); }
void AddPackageSourceToViewModel(NuGet.Configuration.PackageSource packageSource) { var packageSourceViewModel = new PackageSourceViewModel(packageSource); packageSourceViewModels.Add(packageSourceViewModel); packageSourceChecker.Check(packageSourceViewModel); }
static string ConvertToString(NuGet.Configuration.PackageSource source) { if (source != null) { return(String.Format("[PackageSource] Name='{0}', Source='{1}'", source.Name, source.Source)); } return("[PackageSource] == Null"); }
void AddPackageSourceToViewModel(NuGet.Configuration.PackageSource packageSource, string password) { var packageSourceViewModel = new PackageSourceViewModel(packageSource); packageSourceViewModel.Password = password; packageSourceViewModels.Add(packageSourceViewModel); packageSourceChecker.Check(packageSourceViewModel); }
static SourceRepository FindSourceRepository(NuGet.Configuration.PackageSource source, List <SourceRepository> repositories) { foreach (SourceRepository repository in repositories) { if (repository.PackageSource.Equals(source)) { return(repository); } } return(null); }
void AddPackageSourceToViewModel(NuGet.Configuration.PackageSource packageSource, string password) { // HACK: Workaround NuGet 3.4.3 bug. // Set the password text after the view model is created. packageSource.PasswordText = null; var packageSourceViewModel = new PackageSourceViewModel(packageSource); packageSourceViewModel.Password = password; packageSourceViewModels.Add(packageSourceViewModel); packageSourceChecker.Check(packageSourceViewModel); }
/// <summary> /// Create a package repository from the source by trying to resolve relative paths. /// </summary> protected SourceRepository CreateRepositoryFromSource(string source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } var packageSource = new NuGet.Configuration.PackageSource(source); var repository = ConsoleHost.CreateRepository(packageSource); var resource = repository.GetResource <PackageSearchResource> (); // resource can be null here for relative path package source. if (resource == null) { Uri uri; // if it's not an absolute path, treat it as relative path if (Uri.TryCreate(source, UriKind.Relative, out uri)) { throw new NotImplementedException(); //string outputPath; //bool? exists; //string errorMessage; //// translate relative path to absolute path //if (TryTranslatePSPath (source, out outputPath, out exists, out errorMessage) && exists == true) { // source = outputPath; // packageSource = new Configuration.PackageSource (outputPath); //} } } var sourceRepo = ConsoleHost.CreateRepository(packageSource); // Right now if packageSource is invalid, CreateRepository will not throw. Instead, resource returned is null. var newResource = repository.GetResource <PackageSearchResource> (); if (newResource == null) { // Try to create Uri again to throw UriFormat exception for invalid source input. new Uri(source); } return(sourceRepo); }
/// <summary> /// If a relative local URI is passed, it converts it into an absolute URI. /// If the local URI does not exist or it is neither http nor local type, then the source is rejected. /// If the URI is not relative then no action is taken. /// </summary> /// <param name="inputSource">The source string specified by -Source switch.</param> /// <returns>The source validation result.</returns> SourceValidationResult CheckSourceValidity(string inputSource) { // Convert file:// to a local path if needed, this noops for other types var source = UriUtility.GetLocalPath(inputSource); // Convert a relative local URI into an absolute URI var packageSource = new PackageSource(source); Uri sourceUri; if (Uri.TryCreate(source, UriKind.Relative, out sourceUri)) { string outputPath; bool? exists; string errorMessage; if (PSPathUtility.TryTranslatePSPath(SessionState, source, out outputPath, out exists, out errorMessage) && exists == true) { source = outputPath; packageSource = new PackageSource(source); } else if (exists == false) { return(SourceValidationResult.UnknownSource(source)); } } else if (!packageSource.IsHttp) { // Throw and unknown source type error if the specified source is neither local nor http return(SourceValidationResult.UnknownSourceType(source)); } // Check if the source is a valid HTTP URI. if (packageSource.IsHttp && packageSource.TrySourceAsUri == null) { return(SourceValidationResult.UnknownSource(source)); } var sourceRepository = CreateRepositoryFromSource(source); return(SourceValidationResult.Valid(source, sourceRepository)); }
/// <summary> /// Create SourceRepository from given feed endpoint /// </summary> /// <param name="feedEndpoint">V2 or V3 feed endpoint</param> /// <returns>SourceRepository object</returns> private static SourceRepository GetSourceRepository(string feedEndpoint) { NuGet.Configuration.PackageSource source = new NuGet.Configuration.PackageSource(feedEndpoint); return new SourceRepository(source, _providers.Value); }
public void AddPackageSource(NuGet.Configuration.PackageSource source) { }
public void UpdatePackageSource(NuGet.Configuration.PackageSource source, bool updateCredentials, bool updateEnabled) { }
/// <summary> /// Create SourceRepository from given feed endpoint /// </summary> /// <param name="feedEndpoint">V2 or V3 feed endpoint</param> /// <returns>SourceRepository object</returns> private static SourceRepository GetSourceRepository(string feedEndpoint) { NuGet.Configuration.PackageSource source = new NuGet.Configuration.PackageSource(feedEndpoint); return(new SourceRepository(source, _providers.Value)); }
public NuGet.Protocol.Core.Types.SourceRepository CreateRepository(NuGet.Configuration.PackageSource source, NuGet.Protocol.FeedType type) { throw null; }
public SourceRepository(NuGet.Configuration.PackageSource source, System.Collections.Generic.IEnumerable <System.Lazy <NuGet.Protocol.Core.Types.INuGetResourceProvider> > providers, NuGet.Protocol.FeedType feedTypeOverride) { }
public SourceRepository(NuGet.Configuration.PackageSource source, System.Collections.Generic.IEnumerable <NuGet.Protocol.Core.Types.INuGetResourceProvider> providers) { }
public static NuGet.Protocol.Core.Types.SourceRepository CreateSource(System.Collections.Generic.IEnumerable <System.Lazy <NuGet.Protocol.Core.Types.INuGetResourceProvider> > resourceProviders, NuGet.Configuration.PackageSource source, NuGet.Protocol.FeedType type) { throw null; }
public PackageProgressEventArgs(NuGet.Packaging.Core.PackageIdentity identity, NuGet.Configuration.PackageSource source, double complete) { }
public void SaveActivePackageSource(NuGet.Configuration.PackageSource source) { }
public bool IsPackageSourceEnabled(NuGet.Configuration.PackageSource source) { throw null; }
public void DisablePackageSource(NuGet.Configuration.PackageSource source) { }