Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release builds fail during dotnet restore #84

Closed
TomGillen opened this issue Mar 14, 2018 · 9 comments
Closed

Release builds fail during dotnet restore #84

TomGillen opened this issue Mar 14, 2018 · 9 comments
Labels
stale Stale issues--reopen if desired

Comments

@TomGillen
Copy link

TomGillen commented Mar 14, 2018

  1. Create a new project in Visual Studio 2017 15.6.2.
  2. Right click on the project and add docker support.
  3. Switch to Release, and hit compile.

The compile fails with the following:

1>Step 7/16 : RUN dotnet restore -nowarn:msb3202,nu1503
1> ---> Running in 7b165cda3f88
1>/usr/share/dotnet/sdk/2.1.101/NuGet.targets(229,5): error MSB3202: The project file "/src/docker-compose.dcproj" was not found. [/src/DockerTest.sln]
1>Service 'dockertest' failed to build: The command '/bin/sh -c dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(111,5): error : Building dockertest
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(111,5): error : Service 'dockertest' failed to build: The command '/bin/sh -c dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(111,5): error : 
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.Docker.targets(111,5): error : For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting

The same error can also be reproduced in any build that attempts to build the docker image, including running docker build locally and on CI services such as Docker Cloud.

There will also be additional errors about further missing .csproj files for each additional project in the solution, e.g. unit test projects.

@natemcmaster
Copy link

This error was caused by changes in NuGet between the 2.1.4 and 2.1.101 SDK. We are working on a hotfix to the aspnet-docker image which includes a workaround for this error. (see aspnet/aspnet-docker#389). In the long-run, we hope to eliminate the need to suppress MSB3202 (see #87)

In the meantime, you can apply this workaround locally to unblock your builds. Change any lines with dotnet restore to this:

dotnet restore -nowarn:msb3202,nu1503 -p:RestoreUseSkipNonexistentTargets=false

Adding RestoreUseSkipNonexistentTargets reverts NuGet to its previous behavior, in which MSB3202 is a warning which can be suppressed.

@elanderson
Copy link

I'm having this issue in Visual Studio 15.7.4 as well.

@bwateratmsft bwateratmsft added the stale Stale issues--reopen if desired label May 2, 2019
@bwateratmsft
Copy link
Contributor

This issue is being closed as an inactive issue. If you wish to keep it active, please reply with any additional context for our consideration, we are happy to take a look!

@DotsYatin
Copy link

Hi Team,

I am facing this issue when creating the image.
Please look into this and let me know .

C:\Program Files\dotnet\sdk\2.1.700\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\LearnDocker\LearnDocker.csproj]
C:\Program Files\dotnet\sdk\2.1.700\NuGet.targets(121,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [C:\src\LearnDocker\LearnDocker.csproj]
The command 'cmd /S /C dotnet restore "LearnDocker/LearnDocker.csproj"' returned a non-zero code: 1

@DotsYatin
Copy link

#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat

FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1709 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.1-sdk-nanoserver-1709 AS build
WORKDIR /src
COPY ["LearnDocker/LearnDocker.csproj", "LearnDocker/"]

RUN dotnet restore -nowarn:msb3202,nu1503 -p:RestoreUseSkipNonexistentTargets=false "LearnDocker/LearnDocker.csproj"
COPY . .
WORKDIR "/src/LearnDocker"
RUN dotnet build "LearnDocker.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "LearnDocker.csproj" -c Release -o /app

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

@bwateratmsft
Copy link
Contributor

@DotsYatin It seems like your container may have some networking issue in accessing NuGet.org. Sometimes restarting Docker Desktop fixes this?

@dukefox11
Copy link

Facing similar issue. Restarting and re-installing Docker Desktop had no effect. https://api.nuget.org/v3/index.json is accessible via browser. I am also able to run "dotnet restore" on my project successfully.

I will appreciate any help.

Error
C:\Program Files\dotnet\sdk\2.2.301\NuGet.targets(121,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\src\ContaineredWebApp.csproj]
C:\Program Files\dotnet\sdk\2.2.301\NuGet.targets(121,5): error : No such host is known [C:\src\ContaineredWebApp.csproj]
The command 'cmd /S /C dotnet restore -nowarn:msb3202,nu1503 -p:RestoreUseSkipNonexistentTargets=false "ContaineredWebApp.csproj"' returned a non-zero code: 1

Dockerfile
FROM microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.2-sdk-nanoserver-1803 AS build
WORKDIR /src
COPY ["ContaineredWebApp.csproj", "ContaineredWebApp.csproj"]
RUN dotnet restore -nowarn:msb3202,nu1503 -p:RestoreUseSkipNonexistentTargets=false "ContaineredWebApp.csproj"
COPY . .
WORKDIR "/src"
RUN dotnet build "ContaineredWebApp.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "ContaineredWebApp.csproj" -c Release -o /app

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

@bwateratmsft
Copy link
Contributor

bwateratmsft commented Jul 15, 2019

@dukefox11 Is the result the same from the command line if you do "docker build"?

EDIT: It could be related to proxy settings, like in here: NuGet/Home#2880

@kibblewhite
Copy link

I was also experiencing the same issue. Used the -nowarn:msb3202,nu1503 -p:RestoreUseSkipNonexistentTargets=false flags to resolve the problem. Using Microsoft Visual Studio Enterprise 2019 - Version 16.9.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues--reopen if desired
Projects
None yet
Development

No branches or pull requests

7 participants