Reputation: 2933
On the destination server I want do delete a folder (and all it's files) under the App_Data folder. It should happen just before I push the new files to the destination server.
How can I to this?
Current configuration
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>QA</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://qa.mysite.test:80/</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>https://my-server:8172/msdeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>qa.mysite.test</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
</PropertyGroup>
Upvotes: 1
Views: 1530
Reputation: 76670
WebDeploy to IIS - how to delete a folder on destination server?
You can check out the Delete task in MSBuild:
http://msdn2.microsoft.com/en-us/library/7wd15byf.aspx
You will probably have to create an PropertyGroup
that will contain the folder of files to delete, then add the delate
task into AfterBuild
target:
<PropertyGroup>
<AppDataFolder>AppdataFoler</AppDataFolder>
</PropertyGroup>
To accomplish this, unload your project, edit the project file .csproj. Then at the very end of the project, just before the end-tag , place below scripts:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AppdataFolder>\\YourServer\Appdata</AppdataFolder>
</PropertyGroup>
<Target Name="AfterBuild">
<Delete Files="$(AppdataFolder)\YourDeleteFile" />
</Target>
</Project>
Upvotes: 2