前言

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. mysql where子句 区分 大小写

    解决办法 使用binary关键字,此时就能区分大小写了 SELECT * FROM `tb_test` WHERE BINARY COL_1='abc'

  2. HashMap集合的map.values()返回的Collection集合执行add方法报空指针问题

    一.方法1. private Collection<String> setPermissionTenant(List<SysPermission> ls, int tenant ...

  3. veriog之四位全加器

    verilog之四位全加器 1.简易代码 module adder_4bit ( cout,sum,ina,inb,cin ); output[3:0] sum; output cout; input ...

  4. KingbaseES生成动态SQL

    1. 动态SQL 动态SQL在程序启动时会根据输入参数替换相应变量.使用动态SQL可以创建更强大和灵活的应用程序,但在编译时SQL语句的全文不确定,因此运行时编译会牺牲一些性能.动态SQL可以是代码或 ...

  5. UE4中的C++编程简介

    对官方文档的学习链接 利用UE创建一个C++基类 在编辑器中可以选择父类,根据这个父类我们可以创建一个基类用于后续的蓝图类制作. 以Actor父类为例创建基类,其头文件会包含一个构造函数,一个Tick ...

  6. 微服务集成Spring Cloud Alibaba Seata(一)Seata服务搭建

    1.Seata介绍 Seata是阿里开源的一款分布式事务解决方案,致力于提供高性能和简单易用的分布式事务服务.数据库事务我们都知道,事务都是遵循ACID原则.而通过使用Seata可以实现在两个服务模块 ...

  7. yml和properties打印SQL日志信息

    1.配置文件里面配置 第一种是properties类型如下 logging.level.com.datayes.mdi.dao.rdb.mommp.**=debug其中 com.datayes.mdi ...

  8. #威佐夫博弈#洛谷 2252 [SHOI2002]取石子游戏

    题目 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子. 游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子: 二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完 ...

  9. OpenHarmony技术日探讨教育发展,聚焦开源人才培养

    4 月 25 日,OpenAtom OpenHarmony (以下简称"OpenHarmony")技术日在深圳成功举办.作为 OpenHarmony 开源项目的年度盛会,大会以&q ...

  10. CMake 常用命令大全:提高项目构建效率

    CMake是一个跨平台.开源的构建工具,它可以自动生成Makefile或者Visual Studio等IDE的工程文件.它能够帮助开发者更方便地管理项目的构建过程,提高项目构建的效率.在本文中,我们将 ...