我有一个使用.NET Framework 4.6.2编写的小型应用程序,其中包含一些NuGet软件包引用。 在执行以下命令时:docker build -t myapp .
我会收到错误消息:无法解析此引用。
对于每个引用的NuGet软件包。
我已经尝试过:
- 添加
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输出是什么? - Boas EnklerRUN 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)).
- Wijnand