在Docker容器中构建dotnet应用时找不到为Main方法指定的'xxx.Program' [英] Could not find 'xxx.Program' specified for Main method when building dotnet app in Docker container

查看:122
本文介绍了在Docker容器中构建dotnet应用时找不到为Main方法指定的'xxx.Program'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Docker容器中构建dotnet核心应用程序时遇到问题。我正在使用dotnet core 2.2。

I am having issues when building a dotnet core application inside a docker container. I am using dotnet core 2.2.

项目设置为:
输出:Console App
启动项目:Web.Project

The setting for the project are: Output: Console App Startup Project: Web.Project

在容器内运行以下命令时:

When running the command below inside the container:

RUN dotnet build "Web.csproj" -c Release -o /app

我收到以下错误:

Could not find 'Web.Program' specified for Main method [/src/Web/Web.csproj]

如果项目只是一个程序集(dll),一切正常,但我无法运行Web应用程序。

If the project is just an assembly (dll) everything works fine but I'm unable to run the web app.

有什么想法吗?

推荐答案

我的问题的解决方案是从csproj文件中删除以下行:

The solution to my problem was to remove the following line from my csproj file:

<OutputType>EXE</OutputType>

似乎Visual Studio 2107在更改输出类型时会添加该标签。删除该代码后,便可以在Docker容器和Windows中构建和发布。

It seems like visual studio 2107 adds that tag when changing the output type. Once I removed that, I was able to build and publish inside a Docker Container and Windows.

这篇关于在Docker容器中构建dotnet应用时找不到为Main方法指定的'xxx.Program'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆