public Task Do(ProjectBazelConfig prjConfig, string package, string version, string mainFile, bool skipSha256, bool lowest, string variable) { var project = new ProjectBazelManipulator(prjConfig, mainFile, skipSha256, variable); if (prjConfig.ProjectFiles != null) { var projectFileParser = new ProjectFileParser(prjConfig); var packages = projectFileParser.GetNugetPackages(); var nugetTasks = packages.Select(p => DoWithProject(prjConfig.NugetSource, p.Name, p.Version, project, lowest)).ToArray(); return(Task.WhenAll(nugetTasks)); } return(DoWithProject(prjConfig.NugetSource, package, version, project, lowest)); }
public async Task DoWithProject(string package, string version, ProjectBazelManipulator project, bool lowest) { var logger = new Logger(); var providers = new List <Lazy <INuGetResourceProvider> >(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support var packageSource = new PackageSource("https://api.nuget.org/v3/index.json"); var sourceRepository = new SourceRepository(packageSource, providers); var packageMetadataResource = await sourceRepository.GetResourceAsync <PackageMetadataResource>(); var verParsed = NuGetVersion.Parse(version); var identity = new NuGet.Packaging.Core.PackageIdentity(package, verParsed); var content = new SourceCacheContext(); var found = await packageMetadataResource.GetMetadataAsync(identity, content, logger, CancellationToken.None); var settings = Settings.LoadDefaultSettings(project.ProjectConfig.RootPath, null, new MachineWideSettings()); var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers); var packageManager = new NuGetPackageManager(sourceRepositoryProvider, settings, project.ProjectConfig.RootPath) { PackagesFolderNuGetProject = project }; const bool allowPrereleaseVersions = true; const bool allowUnlisted = false; var resolutionContext = new ResolutionContext( lowest ? DependencyBehavior.Lowest : DependencyBehavior.HighestMinor, allowPrereleaseVersions, allowUnlisted, VersionConstraints.None); var projectContext = new ProjectContext(settings); var projects = new ProjectBazelManipulator[] { project }; var actions = await packageManager.PreviewUpdatePackagesAsync(identity, projects, resolutionContext, projectContext, new SourceRepository[] { sourceRepository }, Array.Empty <SourceRepository>(), // This is a list of secondary source respositories, probably empty CancellationToken.None); project.NuGetProjectActions = actions; var sourceCacheContext = new SourceCacheContext(); await packageManager.ExecuteNuGetProjectActionsAsync(project, actions, projectContext, sourceCacheContext, CancellationToken.None); NuGetPackageManager.ClearDirectInstall(projectContext); }
public async Task Do(ProjectBazelConfig prjConfig, string package) { var providers = new List <Lazy <INuGetResourceProvider> >(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support var settings = Settings.LoadDefaultSettings(prjConfig.RootPath, null, new MachineWideSettings()); var project = new ProjectBazelManipulator(prjConfig, null, false, null); var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers); var solutionManager = new BazelSolutionManager(project, prjConfig.RootPath); var deleteManager = new DeleteOnRestart(); var packageManager = new NuGetPackageManager(sourceRepositoryProvider, settings, solutionManager, deleteManager) { PackagesFolderNuGetProject = project, }; var projectContext = new ProjectContext(settings); var uninstallContext = new UninstallationContext(true, true); await packageManager.UninstallPackageAsync(packageManager.PackagesFolderNuGetProject, package, uninstallContext, projectContext, CancellationToken.None); }
#pragma warning restore 67 public BazelSolutionManager(ProjectBazelManipulator project, string rootPath) { _project = project; SolutionDirectory = rootPath; }
public Task Do(ProjectBazelConfig prjConfig, string package, string version, string mainFile, bool skipSha256, bool lowest, string variable) { var project = new ProjectBazelManipulator(prjConfig, mainFile, skipSha256, variable); return(DoWithProject(package, version, project, lowest)); }
public async Task DoWithProject(string nugetSource, string package, string version, ProjectBazelManipulator project, bool lowest) { var logger = new Logger(); var providers = new List <Lazy <INuGetResourceProvider> >(); providers.AddRange(Repository.Provider.GetCoreV3()); // Add v3 API support var packageSource = new PackageSource(nugetSource); var sourceRepository = new SourceRepository(packageSource, providers); var packageMetadataResource = await sourceRepository.GetResourceAsync <PackageMetadataResource>(); var verParsed = NuGetVersion.Parse(version); var identity = new NuGet.Packaging.Core.PackageIdentity(package, verParsed); var content = new SourceCacheContext(); var found = await packageMetadataResource.GetMetadataAsync(identity, content, logger, CancellationToken.None); //var settings = Settings.LoadDefaultSettings(project.ProjectConfig.RootPath, null, new MachineWideSettings()); var settings = Settings.LoadDefaultSettings(project.ProjectConfig.RootPath, null, null); var sourceRepositoryProvider = new SourceRepositoryProvider(settings, providers); var packageManager = new NuGetPackageManager(sourceRepositoryProvider, settings, project.ProjectConfig.RootPath) { PackagesFolderNuGetProject = project }; const bool allowPrereleaseVersions = true; const bool allowUnlisted = false; var resolutionContext = new ResolutionContext( lowest ? DependencyBehavior.Lowest : DependencyBehavior.HighestMinor, allowPrereleaseVersions, allowUnlisted, VersionConstraints.None); var projectContext = new ProjectContext(settings); var actions = await packageManager.PreviewInstallPackageAsync(packageManager.PackagesFolderNuGetProject, identity, resolutionContext, projectContext, sourceRepository, sourceRepositoryProvider.GetRepositories(), CancellationToken.None); project.NuGetProjectActions = actions; await packageManager.InstallPackageAsync(packageManager.PackagesFolderNuGetProject, identity, resolutionContext, projectContext, sourceRepository, sourceRepositoryProvider.GetRepositories(), CancellationToken.None); NuGetPackageManager.ClearDirectInstall(projectContext); }