I'm working on a C# project, having the following nuget.config
file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="nuget"
value="https://www.nuget.org/api/v2/"/>
<add key="gitlab"
value="https://localdomain/api/v4/projects/5/packages/nuget/index.json"/>
</packageSources>
<packageSourceCredentials>
<gitlab>
<add key="Username"
value="MyUserName"/>
<add key="ClearTextPassword"
value="MyToken"/>
</gitlab>
</packageSourceCredentials>
</configuration>
"MyToken" looks as follows: "glpat-".
It has been created, using menu item "Settings>Access Token" in my project.
During the build, the following error message is shown:
error NU1301: Unable to load the service index for source
The build is done, using the dotnet build
command from a container, based on the following image: "mcr.microsoft.com/dotnet/sdk:6.0".
Does anybody have an idea?
Thanks in advance
Edit:
It seems to be a problem with the local domain as NuGet.org
seems to work, there are no error messages.
For your information: localdomain
is defined in /etc/hosts
file.
In the runner's configuration file, a volume
parameter is defined in order to link the auto-signed certificate. In top of that, a parameter, called extra host
, is defined too for the DNS, corresponding with localdomain
.
Hereby the dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Service.API/Service.API.csproj", "Service.API/"]
COPY ["Service.Application/Service.Application.csproj", "Service.Application/"]
COPY ["Service.Domain/Service.Domain.csproj", "Service.Domain/"]
COPY ["Service.Database/Service.Database.csproj", "Service.Database/"]
RUN dotnet restore "Service.API/Service.API.csproj"
COPY . .
WORKDIR "/src/Service.API"
RUN dotnet build "Service.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Service.API.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Service.API.dll"]
Edit2:
I'm working in a CI (Continuous Integration) environment, so the error message is not local on my computer.
While performing a curl
to the mentioned address on the container, I get an error 401 (Unauthorised) although I have no problem surfing, using a browser. The 401 error message is also shown while performing curl
, mentioning username and password.
As far as the corresponding token is concerned: it has full right/read access and is not expired.
It smells like a 401 Unauthorized issue to me.
I would try to take the index.json file and put it somewhere you 100% sure that you can access using CURL. ie. an HTTP link with no authentication or possibly a local file path. then work backwards.
From there, you can work to resolve the 401 error. It could be a locked account, IP restriction, bad password (case insensitive) etc. etc.
I'm thinking it would be related to the localdomain certificate or something along those lines. The TRUSTED ROOT AUTHORITY for the cert may not exist on your build. For example, our company moved from Verisign or Thwarte to ENTRUST... and it blew up all kinds of code everywhere because the entrust auth wasn't installed.
Anyway good luck. I think you need to start with HTTP and no auth, then add HTTPS and no auth, then HTTPS and auth. something like that.