【问题标题】:Finding the correct directory on target for MSBUILD removedir在目标上为 MSBUILD removedir 找到正确的目录
【发布时间】:2016-02-18 14:49:50
【问题描述】:

在目标上为 MSBUILD 找到正确的目录

你好,

我正在尝试在构建后远程清除我网站上的 .pubxml 文件中的“imagecache”文件夹。问题是,当我通过 Web Deploy 运行我的发布到远程服务器时,我收到以下错误:

目录“App_Data/images/imagecache/w-400”不存在。跳过。

这是我当前的构建脚本:

  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>mysite.com</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>NotRealServer</MSDeployServiceURL>
    <DeployIisAppPath>mysite.com</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
    <EnableMSDeployBackup>True</EnableMSDeployBackup>
    <UserName>UserNameHere</UserName>
    <_SavePWD>True</_SavePWD>
</PropertyGroup>

<Target Name="AfterBuild">
   <RemoveDir Directories="App_Data/images/imagecache/w-400"/>
</Target>

我也尝试了以下无济于事。我不确定如何将我需要删除的远程 Web 服务器上的目录提供给 MSBuild。

<RemoveDir Directories="$( DeployIisAppPath)/App_Data/images/imagecache/w-400"/>

<RemoveDir Directories="/App_Data/images/imagecache/w-400"/>

感谢您的宝贵时间。

【问题讨论】:

    标签: msbuild msdeploy webdeploy


    【解决方案1】:

    这取决于您的网络发布是如何配置的。

    如果您要发布到文件共享,请使用 UNC 路径。如果您要发布到 FTP,则 MSBuild 将无法访问该文件夹。

    以下是 UNC 共享上的 RemoveDir 任务示例。

    <RemoveDir Directories="\\Server\Share\folder" Condition="Exists('\\Server\Share\folder')" ContinueOnError="WarnAndContinue"/>

    我在上面输入的 ConditionContinueOnError 属性不是必需的,但它们是个好主意。此任务的配置方式将跳过 RemoveDir 如果文件夹不存在并且如果它确实存在并且存在错误,则该任务将发出警告并且构建过程将继续。

    【讨论】:

      猜你喜欢
      • 2011-02-06
      • 1970-01-01
      • 1970-01-01
      • 2019-01-27
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 2020-05-10
      相关资源
      最近更新 更多