VS 2017添加> Docker支持中断了构建-"CleanWorkspace"任务意外失败(控制台应用程序) [英] VS 2017 Add > Docker Support breaks build - "CleanWorkspace" task failed unexpectedly (console app)
问题描述
首先,我正在使用.NET 4.6.1.装有VS 2017的Docker不能与.NET Core一起使用吗?
First off I'm using .NET 4.6.1. Does Docker with VS 2017 not work with anything but .NET Core?
我从上下文菜单中使用了新功能Add > Docker Support
,它创建了一堆文件.这是我的Dockerfile(因为它是自动创建的,所以没有碰过它):
I used the new feature Add > Docker Support
from the context menu, and it created a bunch of files. Here's my Dockerfile (haven't touched it since it was auto-created):
FROM microsoft/windowsservercore
ARG source
WORKDIR /app
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["C:\app\nameofmyapp.exe"]
构建时,出现以下错误:
When I build, I get the following error:
"CleanWorkspace"任务意外失败. Microsoft.DotNet.Docker.CommandLineClientException:撰写文件 '... \ docker-compose.yml' 无效,因为:services.pas.parsemicroservice.build.context 包含null,这是无效的类型,应为字符串.
The "CleanWorkspace" task failed unexpectedly. Microsoft.DotNet.Docker.CommandLineClientException: The Compose file '...\docker-compose.yml' is invalid because: services.pas.parsemicroservice.build.context contains null, which is an invalid type, it should be a string.
这是我的docker-compose.yml文件:
Here's my docker-compose.yml file:
version: '2.1'
services:
pas.parsemicroservice:
image: pas.parsemicroservice
build:
context:
dockerfile: Dockerfile
如果我在上下文中添加.
(因为该错误暗示null
存在问题),则会收到另一个错误:
If I add a .
to context (as the error implies the null
there is the problem), I get a different error:
目标依存关系图中存在循环依存关系 涉及目标"DockerCleanServiceReferences".
There is a circular dependency in the target dependency graph involving target "DockerCleanServiceReferences".
全部是由于使用了错误的.NET框架导致的,还是我的文件设置有误? (可以肯定地说,我是Docker n00b.)
Is this all a result of using the wrong .NET framework, or are my files set up wrong? (I am a Docker n00b to be sure.)
推荐答案
更新:关于循环依赖问题,请确保您的SLN和CSPROJ文件不在同一文件夹中.这意味着,当您首次创建解决方案时,请确保选中为解决方案创建目录"框.
Update: Regarding your circular dependency issue, make sure your SLN and CSPROJ files are not in the same folder. Meaning that when you first create a solution, make sure to check the box that says "create directory for solution".
VS 2017绝对支持Docker对非.Net Core应用程序的支持,如该视频的9:15标记所示
Docker support for non .Net Core applications is definitely supported in VS 2017 as shown at the 9:15 mark of this video https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/T111
您的context
应指向Dockerfile
所在的目录.此路径应相对于docker-compose.yml文件所在的位置.
Your context
should point to the directory where your Dockerfile
exists. This path should be relative to where your docker-compose.yml file is located.
撰写文件版本2参考: https://docs.docker.com/compose/compose-file/compose-file-v2/#context
Compose file version 2 Reference: https://docs.docker.com/compose/compose-file/compose-file-v2/#context
这篇关于VS 2017添加> Docker支持中断了构建-"CleanWorkspace"任务意外失败(控制台应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!