当前位置:网站首页>dotnet-exec 0.5.0 released
dotnet-exec 0.5.0 released
2022-06-30 03:34:00 【dotNET跨平台】
dotnet-exec 0.5.0 released
Intro
dotnet-exec 是一个 C# 程序的小工具,可以用来运行一些简单的 C# 程序而无需创建项目文件,而且可以自定义项目的入口方法,支持但不限于 Main 方法
Install/Update
dotnet-exec 是一个 dotnet tool,可以使用安装 dotnet tool 的命令来安装
安装/更新最新稳定版本:
dotnet tool update -g dotnet-execute安装最新的 preview 版本:
dotnet tool update -g dotnet-execute --prereleaseUpdates
Features
Custom references
在 0.5.0 版本中用户可以自定义 reference,你可以使用 -r/--reference 选项来自定义引用的本地的 dll 或者 nuget 包
比如说下面这个引用 nuget 包的示例
dotnet-exec "code:typeof(CsvHelper).Assembly.Location.Dump()" -r "nuget:WeihanLi.Npoi" -u "WeihanLi.Npoi"这里引用了 WeihanLi.Npoi 这个 nuget 包,没有指定版本的时候默认使用最新的稳定版本,目前是 2.3.0 所以我们看到的输出结果会是 2.3.0

我们也可以指定具体的 NuGet 包版本,比如:
dotnet-exec "code:typeof(CsvHelper).Assembly.Location.Dump()" -r "nuget:WeihanLi.Npoi,2.1.0" -u "WeihanLi.Npoi"
我们也可以直接引用本地的 dll,比如我们引用上面 nuget 包中的本地 dll
dotnet-exec "code:typeof(CsvHelper).FullName.Dump()" -r "C:\Users\Weiha\.nuget\packages\weihanli.npoi\2.3.0\lib/net6.0/WeihanLi.Npoi.dll" -u "WeihanLi.Npoi"
Docker support enhancements
如果你不是 dotnet 开发者,或者不想安装 dotnet 环境,你也可以使用 docker 来尝试它
docker run --rm weihanli/dotnet-exec:0.5.0 dotnet-exec "code:(1+1).Dump()"之前 docker 镜像是基于 SDK 的镜像来打包的,镜像比较大,0.5.0 版本开始使用 runtime 镜像来打包,比原来的镜像小了很多,对比 dockerhub 上镜像大小,可以发现比原来的镜像大小减少了大概 70%,可以参考:https://hub.docker.com/r/weihanli/dotnet-exec/tags

runtime 包中只包含了 runtime 程序集,不包含引用程序集,在编译的时候会使用引用程序集,没有 SDK 本地也就没有了引用程序集,会 fallback 到 nuget 包,为了减少第一次运行时的等待时间,这里有一个比较 tricky 的做法在 Dockerfile 的最后运行了一个 dotnet-exec 'code:"Hello .NET".Dump()' 来下载 .NET 框架的引用程序集,这样相同的 .NET 版本,就不需要再下载了,可以减少一些下载 NuGet 包和与 NuGet 服务器交互的时间,从而减少一些启动时间

References
https://github.com/WeihanLi/dotnet-exec
https://www.nuget.org/packages/dotnet-execute/
https://hub.docker.com/r/weihanli/dotnet-exec
边栏推荐
- [punch in - Blue Bridge Cup] day 4--------- split ('') cannot be used. There is a space after the last number of test cases. Split ()
- [punch in - Blue Bridge Cup] day 1 --% 7F format output
- I have published a book, "changing life against the sky - the way for programmers to become gods", which is open source. I have been working for ten years. There are 100 life suggestions from technica
- 51 single chip microcomputer indoor environment monitoring system, mq-2 smoke sensor and DHT11 temperature and humidity sensor, schematic diagram, C programming and simulation
- Hudi record
- 产品思维 | 无人机快递的未来值得期待吗?
- X Book 6.89 shield unidbg calling method
- [punch in - Blue Bridge Cup] day 2 --- format output format, ASCII
- [personal summary] learning plan
- C#【高级篇】 C# 接口(Interface)
猜你喜欢

Use of foreach in QT

【笔记】2022.5.27 通过pycharm操作MySQL

51 single chip microcomputer indoor environment monitoring system, mq-2 smoke sensor and DHT11 temperature and humidity sensor, schematic diagram, C programming and simulation

unity input system 使用记录(实例版)

On the optimization and use of idea

X Book 6.97 shield unidbg calling method

Reasons for MySQL master-slave database synchronization failure

Buffer pool of MySQL notes

Use common fileUpload to upload files

云原生——Web实时通信技术之Websocket
随机推荐
QT中foreach的使用
【云原生】AI云开发平台——AI Model Foundry介绍(开发者可免费体验AI训练模型)
A minimalist way to integrate databinding into activity/fragment
【作业】2022.5.24 MySQL 查操作
Linked list: insert a node in the head
[personal summary] learning plan
利用反射整合ViewBinding和ViewHolder
专升本高数(三)
4-5 count words and spaces (15 points)
UML diagrams and list collections
Number of students from junior college to Senior College (III)
On the optimization and use of idea
Redis is used in Windows system
【常见问题】浏览器环境、node环境的模块化问题
[punch in - Blue Bridge Cup] day 5 --- lower() small
TiDB 6.0:让 TSO 更高效丨TiDB Book Rush
dbt产品初体验
[punch in - Blue Bridge Cup] day 2 --- format output format, ASCII
Global and Chinese market of bronze valves 2022-2028: Research Report on technology, participants, trends, market size and share
数据库的下一个变革方向——云原生数据库