public static InstallPackagesAsync ( string>.Dictionary |
||
packages | string>.Dictionary | |
extensionId | string | |
logger | ConnectedServiceLogger | |
project | Project | |
packageInstallerServices | IVsPackageInstallerServices | |
packageInstaller | IVsPackageInstaller | |
Результат | System.Threading.Tasks.Task |
/// <summary> /// Ensures the appropriate version of the specified packages are installed. If an existing version of the package /// already exists the following will happen: /// If a semantically compatible version already exists, no change is made to the package. /// If an older major version exists, a warning is logged and the package is upgraded. /// If an older minor/build version exists, an information message is logged and the package is upgraded. /// If a newer major version exists, a warning is logged and no change is made to the package. /// </summary> public static async Task InstallPackagesAsync( Dictionary <string, string> packages, string extensionId, ConnectedServiceLogger logger, Project project, IVsPackageInstallerServices packageInstallerServices, IVsPackageInstaller packageInstaller) { Dictionary <string, string> packagesToInstall = new Dictionary <string, string>(); await NuGetUtilities.InstallPackagesAsync( project, packages, (packageId, packageVersion) => { packagesToInstall.Add(packageId, packageVersion); return(Task.FromResult <object>(null)); }, logger, packageInstallerServices); if (packagesToInstall.Any()) { packageInstaller.InstallPackagesFromVSExtensionRepository(extensionId, false, false, project, packagesToInstall); } }
private async Task AddSdkReferenceAsync(ConnectedServiceHandlerContext context, HandlerManifest manifest, CancellationToken ct) { ct.ThrowIfCancellationRequested(); foreach (var nuget in manifest.PackageReferences) { Dictionary <string, string> packages = new Dictionary <string, string>(); packages.Add(nuget.Id, nuget.Version); try { await NuGetUtilities.InstallPackagesAsync( packages, "ConnectedServiceForAzureIoTHub.9e26cafb-e929-4d85-a8af-42c42f72f771", context.Logger, ProjectUtilities.GetDteProject(context.ProjectHierarchy), this.PackageInstallerServices, this.PackageInstaller); } catch (Exception ex) { var status = string.Format("Package {0} installation failed. Exception: '{1}'. WARNING: The project might not compile!", nuget.Id, ex.Message); await context.Logger.WriteMessageAsync(LoggerMessageCategory.Warning, status); } } }