前言

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的更多相关文章

  1. 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”错误,   解决方 ...

  2. WPF error: does not contain a static 'Main' method suitable for an entry point

    WPF error: does not contain a static &apos;Main&apos; method suitable for an entry point doe ...

  3. 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 ...

  4. .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 入 ...

  5. 阿里云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 ...

  6. 安装Phalcon报错:gcc: Internal error: Killed (program cc1)

    起因 安装Phalcon可以参考github上面的README.md 下面是我在阿里云ECS服务器上面执行命令的过程: # 安装依赖 sudo yum install php-devel pcre-d ...

  7. 用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 ...

  8. 安装lxml时gcc: internal compiler error: Killed (program cc1)的解决方法

    在安装lxml时出现如下错误 gcc: internal compiler error: Killed (program cc1) 通过查看dmesg发现下述错误信息[2517343.500178] ...

  9. 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 ...

  10. rpm build error: invalid predicate

    rpm build error error message:/usr/lib/rpm/find-debuginfo.sh /usr/src/redhat/BUILD/RPMS find: invali ...

随机推荐

  1. KingbaseES V8R6 集群运维系列 -- trusted_server

    案例说明: 在KingbaseES V8R3及V8R6早期的版本,对于读写分离的集群如果网关地址无法连通,将会导致整个集群关闭,数据库服务无法访问.在后期版本的改进中,降低了对网关的依赖性,当网关地址 ...

  2. KingbaseES 基于SQL的函数过程

    什么是SQL函数? SQL函数包体是一些可执行的SQL语言.同时包含1条以上的查询,但是函数只返回最后一个查询(必须是SELECT)的结果. 除非SQL函数声明为返回void,否则最后一条语句必须是S ...

  3. #树状数组#洛谷 3531 [POI2012] LIT-Letters

    题目 给出两个长度相同且由大写英文字母组成的字符串\(A\).\(B\),保证\(A\)和\(B\)中每种字母出现的次数相同. 现在每次可以交换\(A\)中相邻两个字符,求最少需要交换多少次可以使得\ ...

  4. #树状数组,dp#洛谷 3506 [POI2010]MOT-Monotonicity 2

    题目 给出\(N\)个正整数\(a[1..N]\),再给出\(K\)个关系符号(>.<或=)\(s[1..k]\). 选出一个长度为\(L\)的子序列(不要求连续),要求这个子序列的第\( ...

  5. #背包#nssl 1488 上升子序列

    题目 给一个长度为\(n\)的数组\(a\).试将其划分为两个严格上升子序列,并使其长度差最小. 分析 当\(max([1,i])<min([i+1,n])\)时显然两个区间互不影响,把\(i\ ...

  6. Jetty的http3模块

    启用http3模块,执行如下命令: java -jar $JETTY_HOME/start.jar --add-modules=http3 命令的输出,如下: ALERT: There are ena ...

  7. MySQL 8.0字符集校正

    MySQL升级为8.0版本时,之前版本的字符集往往是不同的,需要校正. 执行下面的三个SQL语句的查询结果,可以从库.表.列三个层面对字符集进行校正. 库 select concat('alter d ...

  8. 仅需30行代码,轻松集成HMS Core视频编辑服务屏幕录制能力

    现如今,手机录屏是必不可少的能力之一.对于游戏领域作者来说,在平时直播玩游戏.制作攻略.操作集锦时,不方便切屏,这时在游戏内如果有一个录制按钮就可以随时开启,记录下每个精彩瞬间,减少后期剪辑工作量:在 ...

  9. Mybatis总体框架设计

    Mybatis架构概览 Mybatis架构整体设计如下: 接口层和数据库交互的方式 Mybatis和数据库的交互方式有两种 使用传统的MyBatis提供的API: 使用Mapper接口 使用传统的My ...

  10. HDC2021技术分论坛:ArkUI 3.0让多设备开发更简单!

    作者:wanglei,华为UI编程框架技术专家 HarmonyOS自诞生以来,就是为满足分布式多设备应用场景而设计的,大到智慧屏.车机.平板,小到手机.手表.在多设备场景下进行应用UI界面开发,面临新 ...