I am trying to build and push a docker image. This is giving me an error error NU1301: Unable to load the service index for source
The folder structure is as follows: src/appfolder/ In the appfolder I have the Dockerfile and nuget.config
The next two tasks I am trying to use are:
- 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'
See Docker and nuget.config files
Docker:
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 file
<?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>
In the Feed Settings -> permissions tab I have both of the service users addded as a Feed publisher (contributor).
I tried a lot of options, but I started with the one I described here.