dotnet build error CS5001: Program does not contain a static 'Main' method suitable for an entry point
前言
Docker环境编译.Net6项目,出现诡异的CS5001
Program does not contain a static 'Main' method suitable for an entry point

排查
从报错信息看是Program.cs Main 方法找不到查看后没什么问题,都是默认的创建的看来不是这里的问题
经过一番Google后找到这个
https://stackoverflow.com/questions/9607702/does-not-contain-a-static-main-method-suitable-for-an-entry-point
解决
那就再.csproj 里添加
<OutputType >Library</OutputType>
确实有用 build成功了
但这有点问题啊 在win环境下运行报错了,没错你的OutputType不正确,要使用Exe才行,这就需要条件编译了,方法如下:
1.Dockerfile build时添加-r linux-x64
dotnet build xx.csproj -c Release -o /app/build -r linux-x64
2.在csproj里添加
<OutputType Condition="$(RuntimeIdentifier.StartsWith('linux'))">Library</OutputType>
OK! 不同平台下做了兼容
dotnet build error CS5001: Program does not contain a static 'Main' method suitable for an entry point的更多相关文章
- WPF开发“Program '*' does not contain a static 'Main' method suitable for an entry point”错误
WPF项目编译时出现“Program '*' does not contain a static 'Main' method suitable for an entry point”错误, 解决方 ...
- WPF error: does not contain a static 'Main' method suitable for an entry point
WPF error: does not contain a static 'Main' method suitable for an entry point doe ...
- Installing Wine 1.5: configure: error: Cannot build a 32-bit program, you need to install 32-bit development libraries(转载)
Installing Wine 1.5: configure: error: Cannot build a 32-bit program, you need to install 32-bit dev ...
- .NET Core的“dotnet restore”、“dotnet build”和“dotnet run”命令都是用来干什么的?
dotnet restore 源代码:https://github.com/dotnet/cli/tree/rel/1.0.0/src/dotnet/commands/dotnet-restore 入 ...
- 阿里云linux服务器安装Phalcon-----"phalcon Volt directory can't be written" "gcc: internal compiler error: Killed (program cc1)"
这里特别蛋疼的一件事是官方英文文档和中文文档命令参数略有不同 中文文档: //通用平台下安装指定的软件包: sudo yum install git gcc make pcre-devel php-d ...
- 安装Phalcon报错:gcc: Internal error: Killed (program cc1)
起因 安装Phalcon可以参考github上面的README.md 下面是我在阿里云ECS服务器上面执行命令的过程: # 安装依赖 sudo yum install php-devel pcre-d ...
- 用VS不同版本打开项目,报错:MS Build Error MSB4019: Microsoft.WebApplication.targets was not found
本例是在用VS2008打开项目是报错 未找到C:\Program Files\MSBuild\Microsoft\VisualStudio\V10.0 In the last article Buil ...
- 安装lxml时gcc: internal compiler error: Killed (program cc1)的解决方法
在安装lxml时出现如下错误 gcc: internal compiler error: Killed (program cc1) 通过查看dmesg发现下述错误信息[2517343.500178] ...
- maven:log4j:WARN No appenders could be found for logger (loggerInfo).或者maven build error:org.apache.maven.lifecycle.LifecycleExecutionExceptio
maven在build构建时,加载资源文件时需要配置资源文件插件: 1,在pom.xml文件中加入 <build> <finalName>${project.build.tar ...
- rpm build error: invalid predicate
rpm build error error message:/usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/RPMS find: invali ...
随机推荐
- OpenCV 方法及应用速查表
序 号 方 法 说 明 技术分类 1 image = cv2.imread(filename, flags) 读取图像 基本操作 2 cv2.imshow(winname, mat) 显 ...
- verilog设计知识集合(2)
verilog设计知识集合(2) 1.阻塞与非阻塞 阻塞赋值是存在先后关系的,非阻塞是不存在先后关系的.一般而言,阻塞用于组合逻辑,非阻塞用于时序逻辑(不一定).阻塞的执行时逐步赋值,非阻塞是同步赋值 ...
- CVS Excell乱码怎么修改
问题描述 日常办公,从网页或者其他web端下载的表格(excel格式或csv格式),打开后发现中文乱码,如下: 常规解法 百度会发现,大部分提供的方法,就是通过excel的另存为,然后选择相应的编码, ...
- SPEL表达式注入分析
环境依赖 <dependencies> <dependency> <groupId>org.springframework</groupId> < ...
- CSS浮动---float
一.标准文档流的特性 1.空白折叠 无论多少个空格.换行.tab,都会折叠为一个空格. 2.高矮不齐,底边对齐 3.自动换行,一行放不下就换行写 二.行内元素和块级元素的注意点 1.行内元素不能设置宽 ...
- Python---flask框架实现修改密码功能
数据库部分: 1 #重置密码 2 def reset_pass(phone,password): 3 conn,cursor=get_conn() 4 sql="update userdat ...
- #后缀数组,单调队列#洛谷 2852 [USACO06DEC]Milk Patterns G
题目 给定一个长度为\(n\)的字符串,求出现至少\(k\)次的最长子串长度 分析 由于后缀排序后的LCP才是最长的,既然要求至少\(k\)次, 实际上也就是维护长度为\(k\)的height数组最小 ...
- Python将依赖包导出到requirements.txt文件
代码 # 查询环境中已经安装的库 pip list # 将所有依赖库导出到 requirements.txt 文件 pip freeze > requirements.txt
- 【转】CentOS安装VMware Tools
[转]CentOS安装VMware Tools VMware 是非常好的虚拟机软件.如果系统安装了VMware Tools以后对虚拟机的性能会提升很多的.下面是如果在CentOS系统内安装VMware ...
- linux 忘记密码怎么破?
前言 适合硬件在自己旁边的,不适合云服务器,云服务器很方便的,可以直接重置密码,因为云服务器都是虚拟机. 正文 1.步骤 进入到可以看到节目的视图,按下esc键进入下面的视图! 2.接着进入下面的界面 ...