安装 MSDeploy 包时如何保留现有文件?

发布于 2024-12-23 07:03:57 字数 80 浏览 1 评论 0原文

我需要保留一些由我的网站生成的文件。

是否可以使 MSDeploy 不删除任何文件,并且仅当包包含较新版本的文件时才覆盖现有文件?

I need to preserve some files, generated by my site.

Is it possible to make MSDeploy not delete any files, and overwrite existing files only when the package contains a newer version of a file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流星番茄 2024-12-30 07:03:57

-enableRule:SkipNewerFilesRule 将跳过对具有较新写入时间的文件的更新。 -enableRule:DoNotDeleteRule 将阻止删除目标计算机上的文件,但此规则仅适用于 contentPathdirPath文件路径提供者。我使用了skipRule -skip:skipAction=Delete,objectName=dirPath,absolutePath=.* 来模拟DoNotDeleteRule。到目前为止,它对我来说效果很好。

-enableRule:SkipNewerFilesRule will skip updates to files that have a more recent write time. -enableRule:DoNotDeleteRule will block deletion of files on the destination computer, but this rule only works with the contentPath, dirPath, and filePath providers. I have used the skipRule -skip:skipAction=Delete,objectName=dirPath,absolutePath=.* to simulate the DoNotDeleteRule. It has worked well for me so far.

烟织青萝梦 2024-12-30 07:03:57

解决方案是将此代码添加到我的 csproj 文件中,它可以防止部署时 App_Data 文件夹中的任何删除和更新:

  <PropertyGroup>
    <OnBeforePackageUsingManifest>AddSkipRules</OnBeforePackageUsingManifest>
  </PropertyGroup>
  <Target Name="AddSkipRules">
    <ItemGroup>
      <MsDeploySkipRules Include="SkipDeleteAppData">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipDeleteAppData">
        <SkipAction>Delete</SkipAction>
        <ObjectName>dirPath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipUpdateAppData">
        <SkipAction>Update</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipUpdateAppData">
        <SkipAction>Update</SkipAction>
        <ObjectName>dirPath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
    </ItemGroup>
  </Target>

The solution was to add this code into my csproj file, it prevents any deletions and updates in App_Data folder on deploy:

  <PropertyGroup>
    <OnBeforePackageUsingManifest>AddSkipRules</OnBeforePackageUsingManifest>
  </PropertyGroup>
  <Target Name="AddSkipRules">
    <ItemGroup>
      <MsDeploySkipRules Include="SkipDeleteAppData">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipDeleteAppData">
        <SkipAction>Delete</SkipAction>
        <ObjectName>dirPath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipUpdateAppData">
        <SkipAction>Update</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
      <MsDeploySkipRules Include="SkipUpdateAppData">
        <SkipAction>Update</SkipAction>
        <ObjectName>dirPath</ObjectName>
        <AbsolutePath>$(_Escaped_PackageTempDir)\\App_Data\\.*</AbsolutePath>
        <XPath>
        </XPath>
      </MsDeploySkipRules>
    </ItemGroup>
  </Target>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文