void packageManagerProxy_PackageInstalling(object sender, PackageOperationEventArgs e) { var package = e.Package; var entryPoint = package.Id + Constants.BonsaiExtension; if (package.GetContentFiles().Any(file => file.EffectivePath == entryPoint)) { Invoke((Action)(() => { var message = string.Format(Resources.InstallExecutablePackageWarning, package.Id); var result = MessageBox.Show(this, message, Resources.InstallExecutablePackageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { saveFolderDialog.FileName = package.Id; if (saveFolderDialog.ShowDialog(this) == DialogResult.OK) { var targetPath = saveFolderDialog.FileName; var targetFileSystem = new PhysicalFileSystem(targetPath); InstallPath = PackageHelper.InstallExecutablePackage(package, targetFileSystem); DialogResult = DialogResult.OK; } } })); } }
static string LaunchPackageBootstrapper( PackageConfiguration packageConfiguration, string editorRepositoryPath, string editorPath, string targetPath, string packageId, Func <IPackageManager, Task> installPackage) { EnableVisualStyles(); var installPath = string.Empty; var executablePackage = default(IPackage); var packageManager = CreatePackageManager(editorRepositoryPath); using (var monitor = new PackageConfigurationUpdater(packageConfiguration, packageManager, editorPath)) { packageManager.PackageInstalling += (sender, e) => { var package = e.Package; if (package.Id == packageId && e.Cancel) { executablePackage = package; } }; PackageHelper.RunPackageOperation(packageManager, () => installPackage(packageManager)); } if (executablePackage != null) { if (string.IsNullOrEmpty(targetPath)) { var entryPoint = executablePackage.Id + NuGet.Constants.BonsaiExtension; var message = string.Format(Resources.InstallExecutablePackageWarning, executablePackage.Id); var result = MessageBox.Show(message, Resources.InstallExecutablePackageCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { using (var dialog = new SaveFolderDialog()) { dialog.FileName = executablePackage.Id; if (dialog.ShowDialog() == DialogResult.OK) { targetPath = dialog.FileName; } } } } if (!string.IsNullOrEmpty(targetPath)) { var targetFileSystem = new PhysicalFileSystem(targetPath); installPath = PackageHelper.InstallExecutablePackage(executablePackage, targetFileSystem); } } return(installPath); }
void packageManagerProxy_PackageInstalling(object sender, PackageOperationEventArgs e) { var package = e.Package; if (package == targetPackage) { var entryPoint = package.Id + Constants.BonsaiExtension; if (!package.GetContentFiles().Any(file => file.EffectivePath == entryPoint)) { var message = string.Format(Resources.MissingWorkflowEntryPoint, entryPoint); throw new InvalidOperationException(message); } var targetFileSystem = new PhysicalFileSystem(targetPath); InstallPath = PackageHelper.InstallExecutablePackage(package, targetFileSystem); DialogResult = DialogResult.OK; } }