public async Task<IEnumerable<PackageAction>> ResolveActionsAsync( PackageIdentity packageIdentity, PackageActionType operation, InstallationTarget target) { // Construct the Action Resolver var oldResolver = new OldResolver(); if (Logger != null) { oldResolver.Logger = new ShimLogger(Logger); } // Apply context settings ApplyContext(oldResolver); var packageManager = target.GetRequiredFeature<IPackageManager>(); var nullProjectManager = new NullProjectManager( new CoreInteropPackageManager( packageManager.LocalRepository, _dependencyResolver, new CoreInteropSourceRepository(_source))); oldResolver.AddOperation( MapNewToOldActionType(operation), await CreateVirtualPackage(packageIdentity.Id, packageIdentity.Version), nullProjectManager); // Resolve actions! var actions = await Task.Factory.StartNew(() => oldResolver.ResolveActions()); // Convert the actions var converted = from action in actions select new PackageAction( MapOldToNewActionType(action.ActionType), new PackageIdentity( action.Package.Id, new NuGetVersion( action.Package.Version.Version, action.Package.Version.SpecialVersion)), UnwrapPackage(action.Package), target, _source, packageIdentity); // Identify update operations so we can mark them as such. foreach (var group in converted.GroupBy(c => c.PackageIdentity.Id)) { var installs = group.Where(p => p.ActionType == PackageActionType.Install).ToList(); var uninstalls = group.Where(p => p.ActionType == PackageActionType.Uninstall).ToList(); if (installs.Count > 0 && uninstalls.Count > 0) { var maxInstall = installs.OrderByDescending(a => a.PackageIdentity.Version).First(); maxInstall.IsUpdate = true; } } return converted; }
public PackageDetailControlModel( InstallationTarget target, UiSearchResultPackage searchResultPackage) : base(target, searchResultPackage) { Debug.Assert(!target.IsSolution); UpdateInstalledVersion(); }
public DetailControlModel( InstallationTarget target, UiSearchResultPackage searchResultPackage) { _target = target; _searchResultPackage = searchResultPackage; _allPackages = new List<NuGetVersion>(searchResultPackage.Versions); _options = new UI.Options(); CreateActions(); }
public DetailControlModel( InstallationTarget target, UiSearchResultPackage searchResultPackage) { _target = target; _searchResultPackage = searchResultPackage; _allPackages = new List <NuGetVersion>(searchResultPackage.Versions); _options = new UI.Options(); CreateActions(); }
public PackageAction(PackageActionType actionType, PackageIdentity packageName, JObject package, InstallationTarget target, SourceRepository source, PackageIdentity dependentPackage) { ActionType = actionType; PackageIdentity = packageName; Package = package; Target = target; Source = source; DependentPackage = dependentPackage; IsUpdate = false; }
public CoreInteropProjectManager( InstallationTarget target, SourceRepository activeSource, IDependencyResolver2 dependencyResolver) { // Get the required features from the target _sharedRepo = target.GetRequiredFeature <ISharedPackageRepository>(); _refRepo = target.GetRequiredFeature <IProjectManager>().LocalRepository; _projectSystem = target.TryGetFeature <IProjectSystem>(); _target = target; _sourceRepo = new CoreInteropSourceRepository(activeSource); _pacman = new CoreInteropPackageManager( _sharedRepo, dependencyResolver, _sourceRepo); }
public CoreInteropProjectManager( InstallationTarget target, SourceRepository activeSource, IDependencyResolver2 dependencyResolver) { // Get the required features from the target _sharedRepo = target.GetRequiredFeature<ISharedPackageRepository>(); _refRepo = target.GetRequiredFeature<IProjectManager>().LocalRepository; _projectSystem = target.TryGetFeature<IProjectSystem>(); _target = target; _sourceRepo = new CoreInteropSourceRepository(activeSource); _pacman = new CoreInteropPackageManager( _sharedRepo, dependencyResolver, _sourceRepo); }
public PackageLoader( SourceRepository source, InstallationTarget target, PackageLoaderOption option, string searchText) { _target = target; _option = option; _source = source; _searchText = searchText; LoadingMessage = string.IsNullOrWhiteSpace(searchText) ? Resx.Resources.Text_Loading : string.Format( CultureInfo.CurrentCulture, Resx.Resources.Text_Searching, searchText); }
public override void ExecuteScript(string packageInstallPath, string scriptRelativePath, object package, InstallationTarget target, IExecutionLogger logger) { IPackage packageObject = (IPackage)package; // If we don't have a project, we're at solution level string projectName = target.Name; FrameworkName targetFramework = target.GetSupportedFrameworks().FirstOrDefault(); VsProject targetProject = target as VsProject; Project dteProject = targetProject == null ? null : targetProject.DteProject; string fullPath = Path.Combine(packageInstallPath, scriptRelativePath); if (!File.Exists(fullPath)) { VsNuGetTraceSources.VsPowerShellScriptExecutionFeature.Error( "missing_script", "[{0}] Unable to locate expected script file: {1}", projectName, fullPath); } else { VsNuGetTraceSources.VsPowerShellScriptExecutionFeature.Info( "executing", "[{0}] Executing script file: {1}", projectName, fullPath); _scriptExecutor.ExecuteResolvedScript( fullPath, packageInstallPath, packageObject, dteProject, targetFramework, new ShimLogger(logger)); } }
public static void ExecutePowerShellScriptIfPresent(string scriptName, InstallationTarget target, IPackage package, string installPath, IExecutionContext context) { Debug.Assert(context != null); // If we don't have a project, we're at solution level // The <Solution> string is only for tracing so it probably doesn't need to be loc'ed string projectName = target.Name; var targetFramework = target.GetSupportedFrameworks().FirstOrDefault(); // Get the install script var scriptFile = FindScript( package, scriptName, targetFramework); // If there is a script to run if (scriptFile != null) { NuGetTraceSources.ActionExecutor.Info( "executingps1", "[{0}] Running {2} for {1}", projectName, package.GetFullName(), scriptFile.Path); context.ExecuteScript(installPath, scriptFile.Path, package, target); } else { NuGetTraceSources.ActionExecutor.Info( "nops1", "[{0}] No {2} script for {1}.", projectName, package.GetFullName(), scriptName); } }
/// <summary> /// Gets the status of the package specified by <paramref name="packageId"/> in /// the specified installation target. /// </summary> /// <param name="packageId">package id.</param> /// <param name="target">The installation target.</param> /// <param name="allVersions">List of all versions of the package.</param> /// <returns>The status of the package in the installation target.</returns> public static PackageStatus GetPackageStatus( string packageId, InstallationTarget target, IEnumerable <NuGetVersion> allVersions) { var latestStableVersion = allVersions .Where(p => !p.IsPrerelease) .Max(p => p); // Get the minimum version installed in any target project/solution var minimumInstalledPackage = target.GetAllTargetsRecursively() .Select(t => t.InstalledPackages.GetInstalledPackage(packageId)) .Where(p => p != null) .OrderBy(r => r.Identity.Version) .FirstOrDefault(); PackageStatus status; if (minimumInstalledPackage != null) { if (minimumInstalledPackage.Identity.Version < latestStableVersion) { status = PackageStatus.UpdateAvailable; } else { status = PackageStatus.Installed; } } else { status = PackageStatus.NotInstalled; } return(status); }
public PackageManagerModel(SourceRepositoryManager sources, InstallationTarget target) { Sources = sources; Target = target; }
// The type of parameter package should be IPackage but we use object instead since we // don't want to expose IPackage. public abstract void ExecuteScript(string packageInstallPath, string scriptRelativePath, object package, InstallationTarget target, IExecutionLogger logger);
public void ExecuteScript(string packageInstallPath, string scriptRelativePath, object package, InstallationTarget target) { // no-op }
/// <summary> /// Gets the status of the package specified by <paramref name="packageId"/> in /// the specified installation target. /// </summary> /// <param name="packageId">package id.</param> /// <param name="target">The installation target.</param> /// <param name="allVersions">List of all versions of the package.</param> /// <returns>The status of the package in the installation target.</returns> public static PackageStatus GetPackageStatus( string packageId, InstallationTarget target, IEnumerable<NuGetVersion> allVersions) { var latestStableVersion = allVersions .Where(p => !p.IsPrerelease) .Max(p => p); // Get the minimum version installed in any target project/solution var minimumInstalledPackage = target.GetAllTargetsRecursively() .Select(t => t.InstalledPackages.GetInstalledPackage(packageId)) .Where(p => p != null) .OrderBy(r => r.Identity.Version) .FirstOrDefault(); PackageStatus status; if (minimumInstalledPackage != null) { if (minimumInstalledPackage.Identity.Version < latestStableVersion) { status = PackageStatus.UpdateAvailable; } else { status = PackageStatus.Installed; } } else { status = PackageStatus.NotInstalled; } return status; }
public async Task <IEnumerable <PackageAction> > ResolveActionsAsync( PackageIdentity packageIdentity, PackageActionType operation, InstallationTarget target) { // Construct the Action Resolver var oldResolver = new OldResolver(); if (Logger != null) { oldResolver.Logger = new ShimLogger(Logger); } // Apply context settings ApplyContext(oldResolver); var packageManager = target.GetRequiredFeature <IPackageManager>(); var nullProjectManager = new NullProjectManager( new CoreInteropPackageManager( packageManager.LocalRepository, _dependencyResolver, new CoreInteropSourceRepository(_source))); oldResolver.AddOperation( MapNewToOldActionType(operation), await CreateVirtualPackage(packageIdentity.Id, packageIdentity.Version), nullProjectManager); // Resolve actions! var actions = await Task.Factory.StartNew(() => oldResolver.ResolveActions()); // Convert the actions var converted = from action in actions select new PackageAction( MapOldToNewActionType(action.ActionType), new PackageIdentity( action.Package.Id, new NuGetVersion( action.Package.Version.Version, action.Package.Version.SpecialVersion)), UnwrapPackage(action.Package), target, _source, packageIdentity); // Identify update operations so we can mark them as such. foreach (var group in converted.GroupBy(c => c.PackageIdentity.Id)) { var installs = group.Where(p => p.ActionType == PackageActionType.Install).ToList(); var uninstalls = group.Where(p => p.ActionType == PackageActionType.Uninstall).ToList(); if (installs.Count > 0 && uninstalls.Count > 0) { var maxInstall = installs.OrderByDescending(a => a.PackageIdentity.Version).First(); maxInstall.IsUpdate = true; } } return(converted); }