使用 Powershell 2.0 安装 ASP.net DNX

Installing ASP.net DNX with Powershell 2.0

我正在尝试在 Windows 上安装 ASP.Net DNX。我按照以下说明进行操作:https://github.com/aspnet/home#cmd

问题是。当我 运行 这个时,我收到一条错误消息:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\parsonsjm0818\Desktop>@powershell -NoProfile -ExecutionPolicy unrestric
ted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('ht
tps://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Using temporary directory: C:\Users\PARSON~1\AppData\Local\Temp\dnvminstall
Downloading DNVM.ps1 to
Downloading DNVM.cmd to
Installing DNVM
The script 'dnvm.ps1' cannot be run because it contained a "#requires" statemen
t at line 2 for Windows PowerShell version 3.0. The version required by the scr
ipt does not match the currently running version of Windows PowerShell version
2.0.
At line:1 char:191
+ [System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threadi
ng.Thread]::CurrentThread.CurrentUICulture = '';$CmdPathFile='C:\Users\parsonsj
m0818\.dnx\temp-set-envvars.cmd';& <<<<  'C:\Users\PARSON~1\AppData\Local\Temp\
dnvminstall\dnvm.ps1' setup
    + CategoryInfo          : ResourceUnavailable: (dnvm.ps1:String) [], Scrip
   tRequiresException
    + FullyQualifiedErrorId : ScriptRequiresUnmatchedPSVersion


C:\Users\parsonsjm0818\Desktop>

我可以只使用 Powershell 2.0 安装 DNX 还是必须升级到 3.0?

The script 'dnvm.ps1' cannot be run because it contained a "#requires" statemen t at line 2 for Windows PowerShell version 3.0.

如果您想确保脚本能够正常工作,则必须使用 Powershell v3.0。当然可以修改脚本以删除该要求,但将其放在那里可能是有充分理由的。如果删除了要求,它真的可以工作,那将只是掷骰子。