You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Dockerfile中用Azure DevOps Feed执行dotnet restore替代全局NuGet

使用Azure DevOps Feed执行dotnet restore的Dockerfile配置

核心配置修改

Azure DevOps私有Feed的NuGet源地址格式为:
https://pkgs.dev.azure.com/{你的组织名}/_packaging/{你的Feed ID}/nuget/v3/index.json

将你现有Dockerfile中的源地址替换为上述格式,同时需要添加私有Feed的认证参数(使用Azure DevOps的Personal Access Token,简称PAT,需具备包读取权限)。

修改后的Dockerfile示例

# 替换为你的Azure DevOps组织名和已有的Feed ID
ARG nuget_repository=https://pkgs.dev.azure.com/{你的组织名}/_packaging/{你的Feed ID}/nuget/v3/index.json
# 传入具备包读取权限的Azure DevOps PAT
ARG nuget_pat

RUN dotnet restore "Xyz.csproj" \
    -s ${nuget_repository} \
    --no-cache \
    -u dummyuser \
    -p ${nuget_pat}

关键说明

  • 替换{你的组织名}为实际的Azure DevOps组织名称,{你的Feed ID}替换为你已有的Feed ID
  • nuget_pat需提前在Azure DevOps中生成,权限需勾选Packaging (Read)
  • -u参数可填写任意字符串,Azure DevOps PAT认证仅校验密码部分
  • --no-cache为可选参数,用于避免缓存旧的源配置,确保拉取最新包信息

内容的提问来源于stack exchange,提问作者vfdavdeasw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 07:15:36