我在 azure devops 中拥有私人提要,并尝试在 docker 文件内执行 dotnet 恢复,但它不起作用
我已附上 Dockerfile 以供参考
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /src
COPY Nuget.config /src/
COPY Project/ /src/Project/
WORKDIR "/src/Project"
ARG FEED_ACCESSTOKEN
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS="{\"endpointCredentials\": [{\"endpoint\":\"https://pkgs.dev.azure.com/OrgName/_packaging/FeedName/nuget/v3/index.json\", \"username\":\"docker\", \"password\":\"${FEED_ACCESSTOKEN}\"}]}"
RUN echo "Environment variables: VSS_NUGET_EXTERNAL_FEED_ENDPOINTS"
RUN echo $VSS_NUGET_EXTERNAL_FEED_ENDPOINTS
RUN apk --no-cache add curl
RUN sh -c "$(curl -fsSL https://aka.ms/install-artifacts-credprovider.sh)"
RUN dotnet restore "Project.csproj" --configfile /src/Nuget.config --verbosity detailed
RUN dotnet build "Project.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Project.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Project.dll"]
我正在使用天蓝色管道来执行这些有效的任务并且
- task: NuGetAuthenticate@1
displayName: 'Authenticate to Artifacts'
inputs:
nuGetServiceConnections: 'ServiceName'
- task: DotNetCoreCLI@2
displayName: 'dotnet Restore'
condition: ne(variables['CacheRestored'],'true')
inputs:
command: 'restore'
projects: '**/*$(projectName).csproj'
arguments: '-r win-x64'
nugetConfigPath: 'nuget.config'
feedsToUse: config
使用下面的代码进行 docker build ,但它不起作用
- task: NuGetAuthenticate@1
displayName: 'Authenticate to Artifacts'
inputs:
nuGetServiceConnections: 'ServiceName'
- task: Docker@2
displayName: 'Build image'
inputs:
command: 'build'
Dockerfile: '**/Dockerfile'
arguments: '--build-arg FEED_ACCESSTOKEN=$(VSS_NUGET_ACCESSTOKEN)'
我尝试通过在 dotnet Restore 中添加 --verbosity 详细信息来调试问题,并发现我在管道中收到以下消息
[CredentialProvider]VstsBuildTaskServiceEndpointCredentialProvider - IsRetry:True [CredentialProvider]VstsBuildTaskServiceEndpointCredentialProvider - 找到端点的凭据 https://pkgs.dev.azure.com/OrgName/_packaging/FeedName/nuget/v3/index.json [CredentialProvider]发送响应:“请求”“GetAuthenticationCredentials”。经过的时间(以毫秒为单位):0 [CredentialProvider]发送响应“Request”“GetAuthenticationCredentials”后经过的时间(以毫秒为单位):0 1>/src/directory/Project.csproj:错误NU1301:无法加载源的服务索引https://pkgs.dev.azure.com/OrgName/_packaging/FeedName/nuget/v3/index.json。
我不确定为什么在找到端点凭据后我收到错误无法加载源的服务索引