【发布时间】:2018-02-06 12:19:59
【问题描述】:
我有一个带有几个 NuGet 包引用的小型 .NET Framework 4.6.2 应用程序。执行时:docker build -t myapp . 对于每个引用的 NuGet 包,我收到错误:Could not resolve this reference.。
我试过了:
- 添加
RUN ["dotnet", "restore"]以从 .csproj 恢复包 - 将图像标签更改为
:4.6.2
如何将 NuGet 包添加到构建过程?
感谢您的宝贵时间!
Dockerfile:
FROM microsoft/dotnet-framework-build:4.7.1 as build-env
WORKDIR /app
COPY . /app
RUN ["dotnet", "build"]
FROM microsoft/dotnet-framework:4.7.1
WORKDIR /app
COPY --from=build-env /app .
ENTRYPOINT ["MessageProcessor.exe"]
构建步骤中单个引用的完整错误:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "GreenPipes, Version=1.2.1.98, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:\app\MessageProcessor.csproj]
【问题讨论】:
-
在我的情况下,我只有
RUN dotnet restore并且它有效。当您运行COPY . .时,您在正确的文件夹中吗? dotnet restore 的输出是什么 -
编辑了 COPY 行。当我添加
RUN dotnet restore时,我得到输出:Restore: Nothing to do. None of the projects specified contain packages to restore. Done Building Project "C:\app\MessageProcessor.csproj" (Restore target(s)). -
原谅我的无知,但这不是 .NET 核心而不是完整的 .NET 框架,因此不使用 dotnet 来构建项目吗?
-
@GregorySuvalian 该应用基于 .NET Framework 4.6.2 项目。我希望使用 .NET Core 是一种选择...
标签: .net docker docker-for-windows windows-container