dotnet sdk_dotnet sdk列表和dotnet sdk最新

dotnet sdk

dotnet sdk

dotnet sdk list

Can someone make .NET Core better with a simple global command? Fanie Reynders did and he did it in a simple and elegant way. I'm envious, in fact, because I spec'ed this exact thing out in a meeting a few months ago but I could have just done it like he did and I would have used fewer keystrokes!

有人可以通过简单的全局命令使.NET Core更好吗? Fanie Reynders做到了,他以一种简单而优雅的方式做到了。 实际上,我很羡慕,因为几个月前我在一次会议上明确了这件事,但我可以像他一样做到,而且我会减少击键次数!

Last year when .NET Core was just getting started, there was a "DNVM" helper command that you could use to simplify dealing with multiple versions of the .NET SDK on one machine. Later, rather than 'switching global SDK versions,' switching was simplified to be handled on a folder by folder basis. That meant that if you had a project in a folder with no global.json that pinned the SDK version, your project would use the latest installed version. If you liked, you could create a global.json file and pin your project's folder to a specific version. Great, but I would constantly have to google to remember the format for the global.json file, and I'd constantly go into c:\Program Files\dotnet in order to get a list of the currently installed SDKs. I proposed that Microsoft make a "dotnet sdk list" command and the ability to pin down versions like "dotnet sdk 1.0.4" and even maybe install new ones with "dotnet sdk install 2.1.0" or something.

去年.NET Core刚刚起步时,有一个“ DNVM”帮助程序命令,可用于简化在一台计算机上处​​理多个版本的.NET SDK的过程。 后来,不再进行“切换全局SDK版本”,而是将切换简化为逐个文件夹地进行处理。 这意味着,如果您的文件夹中没有一个固定了SDK版本的global.json项目,则您的项目将使用最新安装的版本。 如果愿意,可以创建一个global.json文件,然后将项目的文件夹固定到特定版本。 很好,但是我将不得不不断地用Google来记住global.json文件的格式,并且我将不断地进入c:\ Program Files \ dotnet以获得当前安装的SDK的列表。 我建议微软制作一个“ dotnet sdk list”命令,并能够固定诸如“ dotnet sdk 1.0.4”之类的版本,甚至可以使用“ dotnet sdk install 2.1.0”或类似的东西来安装新版本。

Fanie did all this for us except the installation part, and his implementation is clean and simple. It's so simple that I just dropped his commands into my Dropbox's Utils folder that I have in my PATH on all my machines. Now every machine I dev on has this extension.

除了安装部分外,Fanie还为我们完成了所有这些工作,并且其实现简洁明了。 非常简单,我只需将他的命令拖放到我所有机器上的PATH中的Dropbox的Utils文件夹中即可。 现在,我开发的每台计算机都具有此扩展名。

UPDATE: There is both a Windows version and a bash version here.

更新:这里有Windows版本bash版本

Note that if I type "dotnet foo" the dotnet.exe driver will look in the path for an executable command called dotnet-foo.* and run it.

请注意,如果键入“ dotnet foo”,则dotnet.exe驱动程序将在路径中查找名为dotnet-foo。*的可执行命令并运行它。

C:\Users\scott\Desktop>dotnet foo
No executable found matching command "dotnet-foo"

C:\Users\scott\Desktop>dotnet sdk
No executable found matching command "dotnet-sdk"

He created a dotnet-sdk.cmd you can get on his GitHub. Download his repo and put his command somewhere in your path. Now I can do this:

他创建了一个dotnet-sdk.cmd,您可以在他的GitHub上找到它。 下载他的仓库,并将他的命令放在您的路径中。 现在,我可以这样做:

C:\Users\scott\Desktop>dotnet sdk list
The installed .NET Core SDKs are:
1.0.0
1.0.0-preview2-003131
1.0.0-rc3-004530
1.0.2
1.0.4

Which is lovely, but the real use case is this:

这很可爱,但是真正的用例是这样的:

C:\Users\scott\Desktop\fancypants>dotnet --version
1.0.4

C:\Users\scott\Desktop\fancypants>dotnet sdk 1.0.0
Switching .NET Core SDK version to 1.0.0

C:\Users\scott\Desktop\fancypants>dotnet --version
1.0.0

C:\Users\scott\Desktop\fancypants>dir
Volume in drive C is Windows
Directory of C:\Users\scott\Desktop\fancypants

07/26/2017 04:53 PM 47 global.json
1 File(s) 47 bytes

Then if I go "dotnet sdk latest" it just deletes the global.json. Perhaps in a perfect world it should just remove the sdk JSON node in case global.json has been modified, but for now it's great. Without the global.json the dotnet.exe will just use your latest installed SDK.

然后,如果我转到“最新的dotnet sdk”,它将删除global.json。 也许在一个完美的世界中,如果global.json被修改了,它应该只删除sdk JSON节点,但是现在很好。 如果没有global.json,则dotnet.exe将仅使用您最新安装的SDK。

This works with .NET Core 2.0 as well. This should be built-in, but for now it's a very nice example of a clean extension to dotnet.exe.

这也适用于.NET Core 2.0。 这应该是内置的,但是现在这是一个非常不错的扩展dotnet.exe扩展的很好的例子。

Oh, and by the way, he also made a ".net.cmd" so you can do this with all your dotnet.exe commands.

哦,顺便说一句,他还创建了一个“ .net.cmd”,因此您可以使用所有dotnet.exe命令执行操作。

.NET run

Give these commands a try!

试试这些命令

翻译自: https://www.hanselman.com/blog/dotnet-sdk-list-and-dotnet-sdk-latest

dotnet sdk

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值