sdk: VS2017 Docker-Compose Project breaks build on command line
Steps to reproduce
In Visual Studio 2017: File->New Project->ASP.NET Core Web Application Choose either Web API or Web Application Check “Enable Docker Support”
Go to command line and run
dotnet restore ./[NAME].sln
dotnet build ./[NAME].sln
Expected behavior
Restore and build work when a Docker-Compose project (.dcproj) is in the solution.
Should work across all platforms that dotnet is supported
Actual behavior
error MSB4019: The imported project “C:\Program Files\dotnet\sdk\1.0.0\Sdks\Microsoft.Docker.Sdk\Sdk\Sdk.props” was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
PS C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10> dotnet --version
1.0.0
PS C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10> dotnet restore .\WebApplication10.sln
C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\docker-compose.dcproj : error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.0\Sdks\Microsoft.Docker.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Restoring packages for C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\WebApplication10.csproj...
Restoring packages for C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\WebApplication10.csproj...
Restore completed in 785.82 ms for C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\WebApplication10.csproj.
Lock file has not changed. Skipping lock file write. Path: C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\obj\project.assets.json
Restore completed in 1.08 sec for C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\WebApplication10.csproj.
NuGet Config files used:
C:\Users\foo\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
PS C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10> dotnet build .\WebApplication10.sln
Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\docker-compose.dcproj : error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.0\Sdks\Microsoft.Docker.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
WebApplication10 -> C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\WebApplication10\bin\Debug\netcoreapp1.1\WebApplication10.dll
Build FAILED.
C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10\docker-compose.dcproj : error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.0\Sdks\Microsoft.Docker.Sdk\Sdk\Sdk.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:04.20
PS C:\Users\foo\Documents\Visual Studio 2017\Projects\WebApplication10>
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.1)
Product Information: Version: 1.0.1 Commit SHA-1 hash: 005db40cd1
Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.1
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 72 (9 by maintainers)
Commits related to this issue
- Remove the docker-compose project from the sln It was blocking solution-level restore from working (dotnet/cli#6178) and didn't work to launch Docker containers from VS anyhow (Microsoft/DockerTools#... — committed to mjrousos/dotnet-apiport by mjrousos 6 years ago
- Remove docker-compose project from the sln (#647) * Remove the docker-compose project from the sln * It was blocking solution-level restore from working (dotnet/cli#6178) and didn't work to laun... — committed to microsoft/dotnet-apiport by mjrousos 6 years ago
@DamianEdwards @shanselman Sorry to include you two on this issue but we haven’t received feedback on this issue for some time now and we are looking for help. More and more people are coming to this issue as well as the closed PR that would have fixed it.
Reopening this issue since it hasn’t been resolved yet. I think not being able to build a solution that contains a dcproj without hacks is a significant blocker.
@dazhao-msft - any updates on https://github.com/dotnet/cli/pull/6180
@livarcocc I propose that this issue be re-opened since there is no fix currently in place except for manually copying SDK files.
After so many years of generating frustration it seems that Visual Studio still takes priority to having a working/proper CLI. It seems that having a strong CLI that always works is much more useful than having a slow running IDE that either way should not be installed on the CI machine. But for the sake of having this single IDE more click-friendly you are willing to break something so foundational as platform independence.
I was looking through the eShopOnContainers. I was so happy to have dotnet, docker and Mac working together. I wanted to start with the WebMonolithic solution. But I cannot even dotnet restore.
You’ve put a lot of effort in making dotnet core a good platform for the current times. Is it a bad idea to make sure that whatever feature is added it is working first on the CLI and then see what can be done for VS?
The fix (copying VS Docker SDK to dotnet sdk) does not seem to work for 2.0.0-preview2. I get this error: C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(80,45): error MSB4022: The result “” of evaluating the value “$(DockerBuildTasksAssembly)” of the “AssemblyFile” attribute in element <UsingTask> is not valid. [C:\repos\WebApplication1\docker-compose.dcproj]
Any solutions for this?
Just to summarize the steps I had to perform to make it work on Windows and Linux (Ubuntu):
dotnet build SolutionName.slnwill work fine.These steps will fix both errors:
This is still broken after .NET Core 2.0 release. Can anyone comment on the state of affairs?
I’ve tried to do a
dotnet build ./MySolution.slnon a solution which contained a project with enabled Docker (linux) support.@dmitry606 It looks like that you copied the Microsoft.Docker.Sdk folder from VS 15.3 Preview, under which there are 3 folders: build, Sdk, tools. Please delete build and tools and only keep Sdk.
Manually copying the files also worked for me, but I also suggest to reopen this issue, as it is indeed an issue until the files are distributed with the CLI.
@jgreene In the short term, you just need to copy the appropriate files from the VS 2017 installation (C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk) to where
dotnetexpects to find them (C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.Docker.Sdk on Windows, /opt/dotnet/sdk/1.0.1/Sdks/Microsoft.Docker.Sdk on *nix). Longer term hopefully the SDK will be open sourced and these files can be distributed…As another workaround, one could run
dotnet sln MySolution.sln remove docker-compose.dcprojto remove the project reference.This is what I do in my VSTS build definition.
@rainersigwald Not on my Linux CI build agents I can’t 😃
Right, completely understand that. By adding the docker-compose project feature to a solution completely breaks running
dotnet restoreanddotnet buildon a solution file. Since the dcproj is a VS2017 feature, I dont expectdotnetto build it, but perhaps ignore it.The microsoft/aspnetcore-build:1.0-1.1 docker image has “fixed” this by adding the SDK in the dotnet path. Howerver, I hope this is a temporary workaround.
For all the watchers here: dotnet/cli#8416 should fix this one. I’ve just bumped it to see if there’s anything blocking it.
Will this ever be fixed?
@livarcocc Can we please have an update on this issue?
How is this issue closed? dotnet restore is still broken for me with a dcproj file in the solution. Why are these projects not simply ignored?
Just for any others needing a workaround in their linux CI agents: Use something like
dotnet sln remove $(dotnet sln list | grep .dcproj)and you’re goodping @richlander ?
now Linux .net core 2.0 sdk doesn’t support docker? I got
docker-compose.dcproj : error MSB4236: The SDK 'Microsoft.Docker.Sdk' specified could not be found.For all those trying to get the docker image (
microsoft/aspnetcore-build) working see: https://github.com/aspnet/aspnet-docker/issues/299Apparently there is also a
microsoft/aspnetcore-build:1.0-2.0image that comes with the Microsoft.Docker.Sdk.Finally my build is working again thanks to @natemcmaster who provided that solution.
@livarcocc @dazhao-msft @eerhardt Can we please have an update on this? Even a “we are working on it…” would be helpful. More and more people are coming to this issue as well as the closed PR that would have fixed it.
So no fix?
With vague apologies for the self-promotion, having put together a whole pipeline of .NET Core 1.1, Visual Studio 2017 and Docker on TeamCity, I wrote a blog post for work on it - hopefully it will help anyone else trying to do this.
@philcontrolf1 thank you for the solution, this worked for me
@SeWieland - I also have the same problem. As this one is closed I have opened issue https://github.com/dotnet/sdk/issues/35134
3.0.100-preview8-013656still broken. @livarcocc can you reopen this?I hadn’t even noticed that feature!
I always use the “basic” Docker support (i.e. no
.dcproj), and adddocker-composefiles manually as required.If I want to debug a containerized app with its dependencies running in Docker as well (which rarely happens), I start all dependencies using
docker-composebefore debugging the actual app, and expose their ports on the host. In this setup, the application can resolve its dependencies usinghost.docker.internalas host name. It’s requires a few more manual steps and works only for a debugging a single container, but it saves me all the.dcprojheadache you’ve mentioned.A workaround to this - if you’re using teamcity, change your build script to execute the commands in your docker-compose file…
Replace:
docker-compose docker-compose docker-compose.ci.build.yml upWith:
dotnet restore mysolution.sln dotnet publish mysolution.sln -c Release -o ./obj/Docker/publishremoves the dependency on Microsoft.Docker.Sdk…
hope it helps someone!
Any ETA on fix?
@philcontrolf1 thanks for checking. It’s confirmed that this is a mistake, I built some vsts build agents for different purposes of testing, some of them don’t have docker installed. and the agent I used and occurred this problem just doesn’t have. Now everything is working perfectly.