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 ...
随机推荐
- arch 安装xfce
参照 https://www.cnblogs.com/3V4NZ/p/15330275.html 1.安装linux显示服务器 pacman -S xorg Xorg是一个开源的X Window系统的 ...
- Vue入门笔记二
<Vue.js项目实战> 开发所需的包称为开发依赖,应该使用--save-dev标志进行安装 应用运行需要的直接依赖应该使用--save标志进行安装 模板 使用Pug Pug(以前称为Ja ...
- #贪心#CF840A Leha and Function
题目 设 \(f(n,k)\) 表示 区间 \([1,n]\) 选出 \(k\) 个元素的集合的期望最小值, 现在需要重排 \(a\) 数组,使得 \(\sum_{i=1}^mf(a_i,b_i)\) ...
- #线段树#LOJ 6029「雅礼集训 2017 Day1」市场
题目 在长度为\(n(n\leq 10^5)\)的数列中, 需要满足区间加,区间下取整的操作 以及能够查询区间和以及区间最小值 除数\(d\)满足\(2\leq d\leq 10^9\) 加数\(c\ ...
- #李超线段树,树链剖分#洛谷 4069 [SDOI2016]游戏
题目 分析 就是把线段扔到了树上,注意区间查询要比较两个端点的函数值, 把区间赋值转换成两部分,从起点到LCA的区间是斜率为负数的线段, 从终点到LCA的区间是斜率为正数的线段. 代码 #includ ...
- #容斥,莫比乌斯函数#洛谷 2231 [HNOI2002]跳蚤
题目 分析 考虑公约数为\(x\)很好做,就是\(\lfloor\frac{m}{x}\rfloor^n\), 这可以用枚举约数实现容斥当然也可以用莫比乌斯函数, 答案也就是\(\sum_{d|m}\ ...
- #状压dp,背包,贪心#洛谷 5997 [PA2014]Pakowanie
题目 你有 \(n\) 个物品和 \(m\) 个包.物品有重量,且不可被分割: 包也有各自的容量.要把所有物品装入包中,至少需要几个包? 分析 考虑物品的数量很小,首先优先选容量大的背包, 设\(f[ ...
- C++判断操作系统位数
//判断当前系统是否为64位 BOOL Is64BitSystem() { #ifdef _WIN64 return true; #elif _WIN32 HMODULE hModule = Load ...
- 微服务集成Spring Cloud Zipkin实现链路追踪并集成Dubbo
1.什么是ZipKin Zipkin 是一个根据 Google 发表的论文" Dapper" 进行开源实现的分布式跟踪系统. Dapper是Google 公司内部的分布式追踪系统, ...
- C++ 解引用与函数基础:内存地址、调用方法及声明
C++ 解引用 获取内存地址和值 在上一页的示例中,我们使用了指针变量来获取变量的内存地址(与引用运算符 & 一起使用).但是,你也可以使用指针来获取变量的值,这可以通过使用 * 运算符(解引 ...