private bool InstallPackageReference(Package provider, string fastPath, BootstrapRequest request, SoftwareIdentity[] packages) { IHostApi installRequest = request; if (packages[0].Provider.Name.EqualsIgnoreCase("PowerShellGet") && !request.ProviderServices.IsElevated) { // if we're not elevated, we want powershellget to install to the user scope installRequest = new object[] { new { GetOptionKeys = new Func <IEnumerable <string> >(() => request.OptionKeys.ConcatSingleItem("Scope")), GetOptionValues = new Func <string, IEnumerable <string> >((key) => { if (key != null && key.EqualsIgnoreCase("Scope")) { return("CurrentUser".SingleItemAsEnumerable()); } return(request.GetOptionValues(key)); }) } , installRequest }.As <IHostApi>(); } var installing = packages[0].Provider.InstallPackage(packages[0], installRequest); SoftwareIdentity lastPackage = null; foreach (var i in installing) { lastPackage = i; // should we echo each package back as it comes back? request.YieldSoftwareIdentity(i.FastPackageReference, i.Name, i.Version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename); if (request.IsCanceled) { installing.Cancel(); } } if (!request.IsCanceled && lastPackage != null) { if (provider.Name.EqualsIgnoreCase("PowerShellGet")) { // special case. PSModules we can just ask the PowerShell provider to pick it up // rather than try to scan for it. PackageManagementService.TryLoadProviderViaMetaProvider("PowerShell", lastPackage.FullPath, request); request.YieldFromSwidtag(provider, fastPath); return(true); } // looks like it installed ok. request.YieldFromSwidtag(provider, fastPath); // rescan providers PackageManagementService.LoadProviders(request.As <IRequest>()); return(true); } return(false); }
private bool InstallPackageFile(Package provider, string fastPath, BootstrapRequest request) { // we can download and verify this package and get the core to install it. var file = request.DownloadAndValidateFile(provider._swidtag); if (file != null) { // we have a valid file. // run the installer if (request.ProviderServices.Install(file, "", request)) { // it installed ok! request.YieldFromSwidtag(provider, fastPath); PackageManagementService.LoadProviders(request.As <IRequest>()); return(true); } request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath); } return(false); }
private bool InstallPackageReference(Package provider, string fastPath, BootstrapRequest request, SoftwareIdentity[] packages) { IHostApi installRequest = request; if (packages[0].Provider.Name.EqualsIgnoreCase("PowerShellGet") && !request.ProviderServices.IsElevated) { // if we're not elevated, we want powershellget to install to the user scope installRequest = new object[] { new { GetOptionKeys = new Func<IEnumerable<string>>(() => request.OptionKeys.ConcatSingleItem("Scope")), GetOptionValues = new Func<string, IEnumerable<string>>((key) => { if (key != null && key.EqualsIgnoreCase("Scope")) { return "CurrentUser".SingleItemAsEnumerable(); } return request.GetOptionValues(key); }) } , installRequest }.As<IHostApi>(); } var installing = packages[0].Provider.InstallPackage(packages[0], installRequest); SoftwareIdentity lastPackage = null; foreach (var i in installing) { lastPackage = i; // should we echo each package back as it comes back? request.YieldSoftwareIdentity(i.FastPackageReference, i.Name, i.Version, i.VersionScheme, i.Summary, i.Source, i.SearchKey, i.FullPath, i.PackageFilename); if (request.IsCanceled) { installing.Cancel(); } } if (!request.IsCanceled && lastPackage != null) { if (provider.Name.EqualsIgnoreCase("PowerShellGet")) { // special case. PSModules we can just ask the PowerShell provider to pick it up // rather than try to scan for it. PackageManagementService.TryLoadProviderViaMetaProvider("PowerShell", lastPackage.FullPath, request); request.YieldFromSwidtag(provider, fastPath); return true; } // looks like it installed ok. request.YieldFromSwidtag(provider, fastPath); // rescan providers PackageManagementService.LoadProviders(request.As<IRequest>()); return true; } return false; }
private bool InstallPackageFile(Package provider, string fastPath, BootstrapRequest request) { // we can download and verify this package and get the core to install it. var file = request.DownloadAndValidateFile(provider.Name, provider._swidtag); if (file != null) { // we have a valid file. // run the installer if (request.ProviderServices.Install(file, "", request)) { // it installed ok! request.YieldFromSwidtag(provider, fastPath); PackageManagementService.LoadProviders(request.As<IRequest>()); return true; } request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath); } return false; }