WebDeploy到IIS-如何删除目标服务器上的文件夹? [英] WebDeploy to IIS - how to delete a folder on destination server?
问题描述
在目标服务器上,我要删除App_Data文件夹下的文件夹(及其所有文件). 应该在我将新文件推送到目标服务器之前发生.
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.
我该怎么办?
当前配置
<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>
推荐答案
WebDeploy到IIS-如何删除目标服务器上的文件夹?
WebDeploy to IIS - how to delete a folder on destination server?
您可以在MSBuild中检出 Delete任务:
You can check out the Delete task in MSBuild:
http://msdn2.microsoft.com/en-us/library /7wd15byf.aspx
您可能必须创建一个PropertyGroup
,其中将包含要删除的文件的文件夹,然后将delate
任务添加到AfterBuild
目标中:
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>
要完成此操作,请卸载项目,然后编辑项目文件.csproj.然后在项目的最后,在end-tag之前,放在脚本下面:
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>
这篇关于WebDeploy到IIS-如何删除目标服务器上的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!