public void Execute(AddInPostDeploymentActionArgs args) { var sourceFile = ""; switch (Properties.Settings.Default.ReleaseType) { case "dev": sourceFile = Properties.Settings.Default.DevAddr + TextCollection.QuickTutorialFileName; break; case "release": sourceFile = Properties.Settings.Default.ReleaseAddr + TextCollection.QuickTutorialFileName; break; } switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: try { if (sourceFile != "") { System.Diagnostics.Process.Start("POWERPNT", sourceFile); } } catch { //MessageBox.Show("Can't open"); } break; case AddInInstallationStatus.Update: break; case AddInInstallationStatus.Uninstall: break; } }
// <snippet3> public void Execute(AddInPostDeploymentActionArgs args) { string dataDirectory = @"Data\ExcelWorkbook.xlsx"; string file = @"ExcelWorkbook.xlsx"; string sourcePath = args.AddInPath; Uri deploymentManifestUri = args.ManifestLocation; string destPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string sourceFile = System.IO.Path.Combine(sourcePath, dataDirectory); string destFile = System.IO.Path.Combine(destPath, file); switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: case AddInInstallationStatus.Update: File.Copy(sourceFile, destFile); ServerDocument.RemoveCustomization(destFile); ServerDocument.AddCustomization(destFile, deploymentManifestUri); break; case AddInInstallationStatus.Uninstall: if (File.Exists(destFile)) { File.Delete(destFile); } break; } }
SetAssemblyLocationInTemplateFile ( AddInPostDeploymentActionArgs args ) { // Before this method is called, the _AssemblyLocation property in the // template file is set to this: // // Smrf.NodeXL.ExcelTemplate.vsto|aa51c0f3-62b4-4782-83a8-a15dcdd17698|vstolocal // // The "vstolocal" is a marker added by Visual Studio to assist during // development, but it has to be removed during deployment. Also, the // relative path to the Smrf.NodeXL.ExcelTemplate.vsto deployment // manifest needs to be replaced with an absolute path. // // This method changes the _AssemblyLocation property to something like // this: // // http://SomeSite/SomePath/Smrf.NodeXL.ExcelTemplate.vsto|aa51c0f3-62b4-4782-83a8-a15dcdd17698 // // It gets the absolute path to the deployment manifest from the // AddInPostDeploymentActionArgs.ManifestLocation property. // String nodeXLTemplatePath = GetNodeXLTemplatePath(args); ServerDocument.RemoveCustomization(nodeXLTemplatePath); ServerDocument.AddCustomization( nodeXLTemplatePath, args.ManifestLocation); }
SetAssemblyLocationInTemplateFile ( AddInPostDeploymentActionArgs args ) { // Before this method is called, the _AssemblyLocation property in the // template file is set to this: // // Smrf.NodeXL.ExcelTemplate.vsto|aa51c0f3-62b4-4782-83a8-a15dcdd17698|vstolocal // // The "vstolocal" is a marker added by Visual Studio to assist during // development, but it has to be removed during deployment. Also, the // relative path to the Smrf.NodeXL.ExcelTemplate.vsto deployment // manifest needs to be replaced with an absolute path. // // This method changes the _AssemblyLocation property to something like // this: // // http://SomeSite/SomePath/Smrf.NodeXL.ExcelTemplate.vsto|aa51c0f3-62b4-4782-83a8-a15dcdd17698 // // It gets the absolute path to the deployment manifest from the // AddInPostDeploymentActionArgs.ManifestLocation property. // String nodeXLTemplatePath = GetNodeXLTemplatePath(args); ServerDocument.RemoveCustomization(nodeXLTemplatePath); ServerDocument.AddCustomization( nodeXLTemplatePath, args.ManifestLocation); }
GetNodeXLTemplatePath ( AddInPostDeploymentActionArgs args ) { String sNodeXLTemplatePath = Path.Combine( args.AddInPath, ProjectInformation.ExcelTemplateSubfolder); sNodeXLTemplatePath = Path.Combine( sNodeXLTemplatePath, ProjectInformation.ExcelTemplateName); return(sNodeXLTemplatePath); }
//<snippet6> public void Execute(AddInPostDeploymentActionArgs args) { switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: Microsoft.Win32.RegistryKey key; key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\VSTO Runtime Setup\\v4"); key.SetValue("RegKeyString", "Post-Deployment Action Test"); key.Close(); break; case AddInInstallationStatus.Uninstall: Microsoft.Win32.Registry.LocalMachine.DeleteSubKey("SOFTWARE\\Microsoft\\VSTO Runtime Setup\\v4\\RegKeyString"); break; } }
CreateStartMenuShortcut ( AddInPostDeploymentActionArgs args ) { // This was adapted from Rustam Irzaev's reply to this post: // // http://stackoverflow.com/questions/4897655/create-shortcut-on-desktop-c-sharp WshShell wshShell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut( GetStartMenuShortcutFilePath()); shortcut.Description = StartMenuShortcutDescription; shortcut.TargetPath = GetNodeXLTemplatePath(args); shortcut.Save(); }
DeleteStartMenuShortcut ( AddInPostDeploymentActionArgs args ) { String startMenuShortcutFilePath = GetStartMenuShortcutFilePath(); if (System.IO.File.Exists(startMenuShortcutFilePath)) { try { System.IO.File.Delete(startMenuShortcutFilePath); } catch { // Ignore file deletion errors. } } }
Execute ( AddInPostDeploymentActionArgs args ) { switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: case AddInInstallationStatus.Update: SetAssemblyLocationInTemplateFile(args); CreateStartMenuShortcut(args); break; case AddInInstallationStatus.Uninstall: DeleteStartMenuShortcut(args); break; } }
Execute ( AddInPostDeploymentActionArgs args ) { switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: case AddInInstallationStatus.Update: SetAssemblyLocationInTemplateFile(args); CreateStartMenuShortcut(args); break; case AddInInstallationStatus.Uninstall: DeleteStartMenuShortcut(args); break; } }
public void Execute(AddInPostDeploymentActionArgs args) { var sourceFile = ""; switch (Properties.Settings.Default.ReleaseType) { case "dev": sourceFile = Properties.Settings.Default.DevAddr + CommonText.QuickTutorialFileName; break; case "release": sourceFile = Properties.Settings.Default.ReleaseAddr + CommonText.QuickTutorialFileName; break; } switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: try { if (sourceFile != "") { System.Diagnostics.Process.Start("POWERPNT", sourceFile); } } catch { //MessageBox.Show("Can't open"); } break; case AddInInstallationStatus.Update: break; case AddInInstallationStatus.Uninstall: break; } }
public void Execute(AddInPostDeploymentActionArgs args) { XElement parameters = XElement.Parse(args.PostActionManifestXml); //configurabili string dataDirectory = @"Data\"; string file = parameters.Attribute("filename").Value; //statici string sourcePath = args.AddInPath; string destPath = Environment.ExpandEnvironmentVariables(Base.Simboli.LocalBasePath); Uri deploymentManifestUri = args.ManifestLocation; string sourceFile = Path.Combine(sourcePath, dataDirectory, file); string destFile = Path.Combine(destPath, file); switch (args.InstallationStatus) { case AddInInstallationStatus.InitialInstall: if (!Directory.Exists(destPath)) { Directory.CreateDirectory(destPath); } System.IO.File.Copy(sourceFile, destFile, true); if (ServerDocument.IsCustomized(destFile)) { ServerDocument.RemoveCustomization(destFile); } ServerDocument.AddCustomization(destFile, deploymentManifestUri); break; case AddInInstallationStatus.Update: string dirUPDATE = Path.Combine(destPath, "UPDATE"); string fileUPDATE = Path.Combine(dirUPDATE, file); if (!Directory.Exists(dirUPDATE)) { Directory.CreateDirectory(dirUPDATE); } System.IO.File.Copy(sourceFile, fileUPDATE, true); if (ServerDocument.IsCustomized(fileUPDATE)) { ServerDocument.RemoveCustomization(fileUPDATE); } ServerDocument.AddCustomization(fileUPDATE, deploymentManifestUri); break; case AddInInstallationStatus.Uninstall: if (System.IO.File.Exists(destFile)) { //rimuovo file di installazione System.IO.File.Delete(destFile); //rimuovo directory di update string update = Path.Combine(destPath, "UPDATE"); if (Directory.Exists(update) && !Directory.EnumerateFileSystemEntries(update).Any()) { Directory.Delete(update); } //rimuovo directory PSO if (!Directory.EnumerateFileSystemEntries(destPath).Any()) { Directory.Delete(destPath); } } break; } }
public void Execute(AddInPostDeploymentActionArgs args) { File.Create(@"C:\Users\krack\Desktop\testAjout.txt"); }
GetNodeXLTemplatePath ( AddInPostDeploymentActionArgs args ) { String sNodeXLTemplatePath = Path.Combine( args.AddInPath, ProjectInformation.ExcelTemplateSubfolder); sNodeXLTemplatePath = Path.Combine( sNodeXLTemplatePath, ProjectInformation.ExcelTemplateName); return (sNodeXLTemplatePath); }
DeleteStartMenuShortcut ( AddInPostDeploymentActionArgs args ) { String startMenuShortcutFilePath = GetStartMenuShortcutFilePath(); if ( System.IO.File.Exists(startMenuShortcutFilePath) ) { try { System.IO.File.Delete(startMenuShortcutFilePath); } catch { // Ignore file deletion errors. } } }
CreateStartMenuShortcut ( AddInPostDeploymentActionArgs args ) { // This was adapted from Rustam Irzaev's reply to this post: // // http://stackoverflow.com/questions/4897655/create-shortcut-on-desktop-c-sharp WshShell wshShell = new WshShell(); IWshShortcut shortcut = (IWshShortcut)wshShell.CreateShortcut( GetStartMenuShortcutFilePath() ); shortcut.Description = StartMenuShortcutDescription; shortcut.TargetPath = GetNodeXLTemplatePath(args); shortcut.Save(); }