IAddInPostDeploymentAction.Execute 方法
运行后期部署操作,该操作可以将其他安装步骤作为 ClickOnce 安装程序中的最后一步来执行。
命名空间: Microsoft.VisualStudio.Tools.Applications.Deployment
程序集: Microsoft.VisualStudio.Tools.Applications.Runtime(在 Microsoft.VisualStudio.Tools.Applications.Runtime.dll 中)
语法
声明
Sub Execute ( _
args As AddInPostDeploymentActionArgs _
)
void Execute(
AddInPostDeploymentActionArgs args
)
参数
- args
类型:Microsoft.VisualStudio.Tools.Applications.Deployment.AddInPostDeploymentActionArgs
后期部署操作的参数,包括 ClickOnce 安装程序的路径。
示例
Sub Execute(ByVal args As AddInPostDeploymentActionArgs) Implements IAddInPostDeploymentAction.Execute
Dim dataDirectory As String = "Data\ExcelWorkbook.xlsx"
Dim file As String = "ExcelWorkbook.xlsx"
Dim sourcePath As String = args.AddInPath
Dim deploymentManifestUri As Uri = args.ManifestLocation
Dim destPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
Dim sourceFile As String = System.IO.Path.Combine(sourcePath, dataDirectory)
Dim destFile As String = System.IO.Path.Combine(destPath, file)
Select Case args.InstallationStatus
Case AddInInstallationStatus.InitialInstall, AddInInstallationStatus.Update
System.IO.File.Copy(sourceFile, destFile)
ServerDocument.RemoveCustomization(destFile)
ServerDocument.AddCustomization(destFile, deploymentManifestUri)
Exit Select
Case AddInInstallationStatus.Uninstall
If System.IO.File.Exists(destFile) Then
System.IO.File.Delete(destFile)
End If
Exit Select
End Select
End Sub
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;
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。