【发布时间】:2016-11-21 22:59:01
【问题描述】:
我将一个应用从 .NET Core 1.0 升级到 1.1。在此过程中,dotnet build 命令开始使用 .csproj 项目文件,因此我摆脱了旧的 project.json 文件。一切正常,直到我尝试运行 docker build 命令:
docker build -t 示例。
当它在 Dockerfile 中运行 RUN ["dotnet", "build"] 命令时,我得到一个错误:
Sending build context to Docker daemon 3.418 MB
Step 1 : FROM microsoft/dotnet:latest
---> 3693707d4f7f
Step 2 : COPY . /app
---> 771e2b035ea1
Removing intermediate container c271f962518e
Step 3 : WORKDIR /app
---> Running in 6a07c60bab1d
---> e819bc2a9e25
Removing intermediate container 6a07c60bab1d
Step 4 : RUN dotnet restore
---> Running in 99d1cf514fa3
warn : The folder '/app' does not contain a project to restore.
---> cf063f4db808
Removing intermediate container 99d1cf514fa3
Step 5 : RUN dotnet build
---> Running in c2ed65925939
Couldn't find 'project.json' in current directory
The command 'dotnet build' returned a non-zero code: 1
但是不再有“project.json”文件了。为什么我在运行 docker build 时会得到这个,而在运行 dotnet build 时却没有?
这是完整的 Dockerfile:
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
CMD ["dotnet", "run", "--server.urls", "http://*:5000"]
【问题讨论】:
-
您确定不再需要 project.json 文件吗?阅读release announcement他们谈论旧版本和新版本之间的区别。
标签: docker dockerfile .net-core csproj