【问题标题】:Issue in .net core build using docker in Azure devops在 Azure devops 中使用 docker 构建 .net 核心时出现问题
【发布时间】:2021-05-22 14:00:41
【问题描述】:

我目前正在为 .netcore 项目在 Azure Devops 中为 .netcore buildandpush 设置一个 dockerfile。 我在“RUN dotnet restore”中遇到以下错误。

The current .NET SDK does not support targeting .NET Core 3.1.  Either target .NET Core 2.0 or lower, or use a version of the .NET SDK that supports .NET Core 3.1.

我正在使用以下 SDK 进行构建。

FROM microsoft/aspnetcore-build:2.0 AS build

我尝试使用指定的构建修改上述内容,我得到了同样的错误。 1.我应该在yaml文件中添加安装.NET core SDK的任务吗? 2.我有一个解决方案文件和 4 个 csproj 文件。当我使用 Visual Studio 构建时,它会提供多个 dll。在 dockerfile 中,我只给出了以下内容:

ENTRYPOINT ["dotnet", "Example.dll"]

如何传递所有 dll?

【问题讨论】:

    标签: docker asp.net-core azure-devops yaml


    【解决方案1】:

    这发生在我身上,这是 microsoft CLI 工具在 linux 上无法正常工作...根据上下文,它通常会忽略环境变量。要选择您的 dotnet 版本,只需在与 dotnet 交互之前添加此命令,这将强制 dotnet 使用正确的版本

    dotnet new globaljson --sdk-version 2.2.401 --force
    

    更新此命令以匹配您的 dotnet 版本

    【讨论】:

    • 谢谢。它修复了错误。有没有办法在案卷入口点传递多个 dll?
    • 你是什么意思,在什么情况下你需要它?您想一次运行 2 个应用程序吗?
    • 您需要添加一个复制命令,然后入口点只是一个执行 DLL 的命令,COPY ./ /whereyourfileswillbecopied,这将使您可以访问该命令,然后该命令应该类似于 dotnet whereyourfileswillbecopied/somedll.dll,确实这回答了你的问题?
    • docker命令可以参考这里:p riptutorial.com/docker/example/11005/copy-instruction
    • 您可以简单地复制整个文件夹而不是单个文件
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    • 2021-08-18
    • 1970-01-01
    • 2020-08-03
    • 1970-01-01
    • 2021-05-27
    相关资源
    最近更新 更多