前言

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. Navicat 连接MySQL 8.0.11 出现2059错误 解决

    原因 mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password 解决 mysql -uroot -pp ...

  2. KingbaseES错误分析 -- “requested character too large”

    一.适用于: 本文档使用于KingbaseES所有版本. 二.问题现象: 使用从其他数据库迁移到KingbaseES数据库的自定义函数.存储过程.Package包..出现以下错误信息: 错误:所请求的 ...

  3. 可能是迄今为止最好用的WPF加载动画功能(没有之一)

    前言 当我们在开发应用程序时,用户体验往往是至关重要的一环.在应用程序加载大量数据或执行复杂操作时,为用户提供一个良好的加载体验变得至关重要.加载动画是其中一个有效的方式,它不仅能够告知用户应用程序正 ...

  4. AndroidStudio配置 | 菜鸟教程

    https://www.runoob.com/android/android-studio-install.html

  5. 一文搞懂Java的工具类和API

    1.工具类(Utility Class) 在Java中,工具类通常包含一系列静态方法,用于执行常见的任务,这些任务可能不直接关联到特定的业务逻辑,而是用于处理一些基础的数据转换.字符串操作.文件操作等 ...

  6. Seaborn分布数据可视化---箱型分布图

    箱型分布图 boxplot() sns.boxplot( x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient ...

  7. 【Learning eBPF-3】一个 eBPF 程序的深入剖析

    从这一章开始,我们先放下 BCC 框架,来看仅通过 C 语言如何实现一个 eBPF.如此一来,你会更加理解 BCC 所做的底层工作. 在这一章中,我们会讨论一个 eBPF 程序被执行的完整流程,如下图 ...

  8. centos环境Jenkins配置war包Tomcat

    末尾有软件安装包,自行下载(centos环境) centos JDK Jenkins maven tomcat git myslq nginx 7.9 11.0.19 2.418 3.8.1 9.0. ...

  9. openGauss社区入门(openGauss-常用数据类型)

    常用数据类型 数据类型 说明 布尔类型 boolean true/'1'/'yes' false/'0'/'no' 数值类型 smallint 两字节 int 4 字节 bigint 8 字节 dou ...

  10. Go语言的100个错误使用场景(61-68)|并发实践

    目录 前言 9. 并发实践 9.1 context 的不恰当传播(#61) 9.2 开启一个协程但不知道何时关闭(#62) 9.3 在循环中没有谨慎使用协程(#63) 9.4 使用 select 和 ...