如何有效地缓存货物/生锈项目在Azure Build Pipeline中

发布于 2025-01-27 16:10:14 字数 659 浏览 3 评论 0原文

我有一组Azure构建管道来编译Rust Projects,目前使用Blob存储存储.cargotarget文件夹作为缓存。

When compiling locally, once a binary is compiled the first time, subsequent cargo build's don't compile the dependent libraries/crates again, just the local binary, however with my current pipeline system, after downloading缓存并使用正确的目标文件夹构建,管道仍下载并构建板条箱。

这是我的Config.toml,用于缓存和任何管道构建。

[build]
target-dir = "./target"
dep-info-basedir = "."
incremental = true

在某些情况下,它减少了汇编时间,但并不像我预期的那样多。 我可以缓存更多文件夹以提高速度吗?是否有一些缓存标识符,货物正在检查和污染缓存?

管道运行一个自定义XTASK二进制文件,该二进制执行许多任务,包括运行货物构建 - 释放这会引起问题吗?

I have a set of Azure Build Pipelines that compile rust projects and currently use blob storage to store the .cargo and target folders as a cache.

When compiling locally, once a binary is compiled the first time, subsequent cargo build's don't compile the dependent libraries/crates again, just the local binary, however with my current pipeline system, after downloading the cache and using the correct target folder to build into, the pipeline still downloads and builds crates.

This is my config.toml for the cache and any pipeline builds.

[build]
target-dir = "./target"
dep-info-basedir = "."
incremental = true

It has reduced compilation times in some cases but not nearly as much as I expect.
Can I cache more folders to increase speed? Is there some cache identifier that cargo is checking and fouling the cache over?

The pipelines run a custom xtask binary which performs many tasks including running cargo build --release could this be causing issues?

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

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

发布评论

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

评论(1

再可℃爱ぅ一点好了 2025-02-03 16:10:14

您需要缓存target〜/.cargo/.cargo/registristr,凯撒在上面的评论中提到。

以下对我有用():

- task: Cache@2
  inputs:
    key: '"cargo" | "$(Agent.OS)" | Cargo.lock'
    path: $(Build.SourcesDirectory)\target
  displayName: cache cargo build

- task: Cache@2
  inputs:
    key: '"cargo-registry" | "$(Agent.OS)" | Cargo.lock'
    path: $(UserProfile)\.cargo\registry
  displayName: cache cargo registry

You need to cache target and ~/.cargo/registry as mentioned by Caesar in the comments above.

The following worked for me (docs):

- task: Cache@2
  inputs:
    key: '"cargo" | "$(Agent.OS)" | Cargo.lock'
    path: $(Build.SourcesDirectory)\target
  displayName: cache cargo build

- task: Cache@2
  inputs:
    key: '"cargo-registry" | "$(Agent.OS)" | Cargo.lock'
    path: $(UserProfile)\.cargo\registry
  displayName: cache cargo registry
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文