github / VisualStudio

GitHub Extension for Visual Studio
https://visualstudio.github.com
MIT License
2.36k stars 1.2k forks source link

visual studio docker error: NU1301: Unable to > load the service index for source #2738

Open TimOfTcc opened 1 year ago

TimOfTcc commented 1 year ago

Dear All.

I can not containerize .NET Web Api project in Visual Studio 2022.Below is my dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["API.Authentication/API.Authentication.csproj", "API.Authentication/"]
COPY ["API.Core/API.Core.csproj", "API.Core/"]
COPY ["Infrastructure.Persistence/Infrastructure.Persistence.csproj", "Infrastructure.Persistence/"]
COPY ["Core.Application/Core.Application.csproj", "Core.Application/"]
COPY ["Core.Domain/Core.Domain.csproj", "Core.Domain/"]
COPY ["Infrastructure.CustomAttributes/Infrastructure.CustomAttributes.csproj", "Infrastructure.CustomAttributes/"]
COPY ["Shared.Kernel/Shared.Kernel.csproj", "Shared.Kernel/"]
COPY ["Shared.ViewModel/Shared.ViewModel.csproj", "Shared.ViewModel/"]
RUN dotnet restore "API.Authentication/API.Authentication.csproj"
COPY . .
WORKDIR "/src/API.Authentication"
RUN dotnet build "API.Authentication.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "API.Authentication.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "API.Authentication.dll"]

Receiving below error:

Step 14/23 : RUN dotnet restore "API.Authentication/API.Authentication.csproj" ---> Running in 36ddc34cd2a1 Determining projects to restore... C:\src\Shared.Kernel\Shared.Kernel.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\API.Authentication\API.Authentication.csproj]

Thanks.