我正在尝试构建并推送 Docker 映像。这给了我一个错误NU1301:无法加载源的服务索引
文件夹结构如下:src/appfolder/在appfolder中我有Dockerfile和nuget.config
我正在尝试使用的下两个任务是:
- task: DockerInstaller@0
inputs:
dockerVersion: '17.09.0-ce'
- task: Docker@2
inputs:
containerRegistry: '$(dockerRegistryServiceConnection)'
repository: $(imageRepository)
command: 'buildAndPush'
Dockerfile: $(dockerfilePath)
tags: 'latest'
buildContext: '$(Build.SourcesDirectory)/src'
查看 Docker 和 nuget.config 文件
码头工人:
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY . .
RUN dotnet restore "./appfolder/app.csproj"
WORKDIR "/src/appfolder"
RUN dotnet build "./app.csproj" -c $BUILD_CONFIGURATION -o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./app.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "app.dll"]
nuget.config 文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="Feed name" value="https://companyname.pkgs.visualstudio.com/project name/_packaging/feedname/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<companyname>
<add key="Username" value="my username" />
<add key="ClearTextPassword" value="my own PAT" />
</companyname>
</packageSourceCredentials>
</configuration>
在 Feed 设置 -> 权限选项卡中,我将两个服务用户都添加为 Feed 发布者(贡献者)。
我尝试了很多选项,但我从这里描述的选项开始。