Partager via


IAddInPostDeploymentAction.Execute, méthode

Exécute l'action de post-déploiement qui peut effectuer des étapes d'installation supplémentaires comme l'étape finale d'un programme d'installation ClickOnce.

Espace de noms :  Microsoft.VisualStudio.Tools.Applications.Deployment
Assembly :  Microsoft.VisualStudio.Tools.Applications.Runtime (dans Microsoft.VisualStudio.Tools.Applications.Runtime.dll)

Syntaxe

'Déclaration
Sub Execute ( _
    args As AddInPostDeploymentActionArgs _
)
void Execute(
    AddInPostDeploymentActionArgs args
)

Paramètres

Exemples

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;
    }
}

Sécurité .NET Framework

Voir aussi

Référence

IAddInPostDeploymentAction Interface

Microsoft.VisualStudio.Tools.Applications.Deployment, espace de noms

AddInPostDeploymentActionArgs