Description
From @christiansparre on March 8, 2018 17:22
I was playing around with 2.1 preview 1 and trying to get a simple ASP.NET Core 2.1 preview1 app up and running on docker using the VS docker tools. But my docker-compose build failed because dotnet restore on 2.1 throws error MSB3202: The project file "/src/SomeApp.SomeLib/SomeApp.SomeLib.csproj" was not found.
But it is not isolated to docker, see the repo below where there is also a repro for 2.0 and 2.1 outside docker. And they behave very differently. Yes this is not really "normal" restore behavior, but all dotnet docker examples and the VS tooling does it this way with multistage builds and they explicitly suppress MSB3202 using -nowarn:msb3202,nu1503
I have not been able to find any known issues by searching the different dotnet repos. Is dotnet restore throwing errors, instead of warnings, a new expected behavior?
Also this is the most correct place I could find to post the issue, please redirect me elsewhere if there is a better place for it :)
Steps to reproduce
Code to reproduce can be found here: https://github.com/christiansparre/DotNet2.1RestoreBehavior
- Create ASP.NET Core 2.1 web site
- with Docker support (I used Linux)
- Add another project, and reference in web app (does not really matter)
- Change the Dockerfile to use the correct image versions (defaults to 2.1 that does not exist yet)
- Run
docker-compose build
Expected behavior
Expected dotnet restore to complete with out errors or warnings because of -nowarn:msb3202,nu1503 arguments
Actual behavior
Restore failed with
/usr/share/dotnet/sdk/2.1.300-preview1-008174/NuGet.targets(239,5): error MSB3202: The project file "/src/SomeApp.SomeLib/SomeApp.SomeLib.csproj" was not found. [/src/SomeApp.sln] /usr/share/dotnet/sdk/2.1.300-preview1-008174/NuGet.targets(239,5): error MSB3202: The project file "/src/docker-compose.dcproj" was not found. [/src/SomeApp.sln] ERROR: Service 'someapp' failed to build: The command '/bin/sh -c dotnet restore -nowarn:msb3202,nu1503' returned a non-zero code: 1
Environment data
dotnet --info output:
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview1-008174\
Microsoft .NET Core Shared Framework Host
Version : 2.1.0-preview1-26216-03
Build : f2c3216183d20416568a4bbf5bb7d153e826f153
Copied from original issue: dotnet/cli#8747
Activity
livarcocc commentedon Mar 8, 2018
I am not sure if this has changed from warning to error. Moving it to NuGet for them to confirm.
daerhiel commentedon Mar 14, 2018
I have fixed that by changing Docker file from
to
christiansparre commentedon Mar 14, 2018
Yeah I thought that too, but then you are faced with the following when using the Docker Tools for VS stuff.
/src/docker-compose.dcproj : error MSB4236: The SDK 'Microsoft.Docker.Sdk' specified could not be found. ERROR: Service 'someapp' failed to build: The command '/bin/sh -c dotnet restore SomeApp.sln -nowarn:msb3202,nu1503' returned a non-zero code: 1You could then try to exclude the
docker-compose.dcprojfile, but then you are back with the MSB3202 failure.Only other alternative I can see is to roll a docker image for the build that includes
Microsoft.Docker.Sdkand I have not taken the time to do that just yet.I still wonder if the change from MSB3202 being a warning to an error is intentional. If it is, I hope the Docker Tools for VS guys are on top of it. Otherwise we won't be able to use the tooling with 2.1 out of the box.
martore commentedon Mar 14, 2018
Dockerfile
Output [docker-compose up]
christiansparre commentedon Mar 14, 2018
As @martore shows above it is not only an issue on 2.1 preview 1. The just released 2.1.101 sdk seems to be breaking the builds :(
nkolev92 commentedon Mar 15, 2018
The issue arises due to the fact that not all targets can be loaded during the CLI restore, and that breaks an MSBuild optimization that's supposed to help us detect projects that are restore incompatible.
As a temporary workaround you can try running restore with
christiansparre commentedon Mar 15, 2018
Thanks @nkolev92, it works! I can get on with trying out 2.1 :)
lakario commentedon Mar 15, 2018
Throwing in a me too on this issue as we ran into a hard stop with it last night after pulling the updated 2.0 tag for aspnetcore-build. The above switch from @nkolev92 added to the
dotnet restorecommand in the generated Dockerfile fixes the issue.Additionally, the latest version of Visual Studio 17 (15.6.x) changed the ASP.NET Core 2 Dockerfile template to be defined with
dotnet restore -nowarn:msb3202,nu1503. Adding this will clean up the output when combined with the above switch.nkolev92 commentedon Mar 15, 2018
We're actively working with the ASP.NET docker folks to get a fix soon.
@natemcmaster
Can you please follow up here when that's ready?
natemcmaster commentedon Mar 15, 2018
See aspnet/aspnet-docker#389. Once this is merged, it typically takes about an hour for these changes to make it up to Docker Hub.
Better fix for NuGet/Home#6651.
AceHack commentedon Jun 2, 2018
This issue is happening to me using dotnet:2.1-sdk. It's my understanding that this is the replacement for aspnet-build, can the same fix be made?
martore commentedon Jun 2, 2018
@AceHack
AceHack commentedon Jun 2, 2018
@martore I have several projects that need restoring, it would be nice if I could just copy everything into docker including the dcproj and when inside docker it would know to ignore this project type.
AceHack commentedon Jun 2, 2018
I've thought of creating different build configurations to do just this, so the outside build configuration build just the dcproj and the inside build configuration builds everything else. Don't know if that works for restore as well.
Eilyyyy commentedon Jun 4, 2018
i meet the same issue with the dockerfile:
fllow the output:
natemcmaster commentedon Jun 4, 2018
@Eilyyyy It appears your Dockerfile is using a bad pattern generated for you by Visual Studio tooling. The VS tooling has been updated, but your code needs to change manually. I recommmend either:
-nowarn:msb3202,nu1503and resolving the warnings/errors. This will require updating your Dockefile to include more files in theCOPY, such as the.dcprojor any extra.csprojfiles you've added to your.sln.@nkolev92 I recommend closing. I don't think there is any action item here for the NuGet team.
AceHack commentedon Jun 5, 2018
@natemcmaster I would be best if all the dotnet command could just target the sln inside the container and everything just work, like no-op dcproj sdk inside the container.
nkolev92 commentedon Jun 6, 2018
Thanks @natemcmaster. This specific issue slipped through my fingers.
Closing this as duplicate of #6665.
There is no NuGet actionable.
Please refer to #6665 (comment) for a detailed explanation.