WebDeploy 到 IIS - 如何删除目标服务器上的文件夹?
WebDeploy to IIS - how to delete a folder on destination server?
在目标服务器上,我想删除 App_Data 文件夹下的一个文件夹(及其所有文件)。
它应该发生在我将新文件推送到目标服务器之前。
我该怎么办?
当前配置
<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 to IIS - how to delete a folder on destination server?
您可以查看 MSBuild 中的删除任务:
http://msdn2.microsoft.com/en-us/library/7wd15byf.aspx
您可能必须创建一个 PropertyGroup
来包含要删除的文件的文件夹,然后将 delate
任务添加到 AfterBuild
目标中:
<PropertyGroup>
<AppDataFolder>AppdataFoler</AppDataFolder>
</PropertyGroup>
为此,请卸载您的项目,编辑项目文件 .csproj。然后在项目的最后,就在结束标记之前,放置在脚本下面:
<?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>
在目标服务器上,我想删除 App_Data 文件夹下的一个文件夹(及其所有文件)。 它应该发生在我将新文件推送到目标服务器之前。
我该怎么办?
当前配置
<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 to IIS - how to delete a folder on destination server?
您可以查看 MSBuild 中的删除任务:
http://msdn2.microsoft.com/en-us/library/7wd15byf.aspx
您可能必须创建一个 PropertyGroup
来包含要删除的文件的文件夹,然后将 delate
任务添加到 AfterBuild
目标中:
<PropertyGroup>
<AppDataFolder>AppdataFoler</AppDataFolder>
</PropertyGroup>
为此,请卸载您的项目,编辑项目文件 .csproj。然后在项目的最后,就在结束标记之前,放置在脚本下面:
<?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>