如何修复Visual Studio 2015中的DNX / DNVM?

今天,我在Windows 7 x64上安装了VS 2015。 主要是为了testing新的.Net核心function等。为了testing,我创build了新的C#“控制台应用程序(包)”解决scheme,并得到这样的消息:

DNX SDK版本“dnx-clr-win-x86.1.0.0-beta5”未能安装。 该解决scheme将使用此会话的DNX SDK版本“dnx-clr-win-x86.1.0.0-beta5”。

我无法编译和debugging项目。 另外,当我打开项目属性中的debugging选项卡,然后VS崩溃。

DNVM输出当我打开解决scheme:

Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, func tion, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1451 ????:27 + Invoke-Command <<<< ([ScriptBlock]::Create("dnvm-$cmd $cmdargs") ) + CategoryInfo : ObjectNotFound: (x86:String) [Invoke-Command], C ommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co mmands.InvokeCommandCommand Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, func tion, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1451 ????:27 + Invoke-Command <<<< ([ScriptBlock]::Create("dnvm-$cmd $cmdargs") ) + CategoryInfo : ObjectNotFound: (x86:String) [Invoke-Command], C ommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co mmands.InvokeCommandCommand Invoke-Command : The term 'x86' is not recognized as the name of a cmdlet, func tion, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1:1451 ????:27 + Invoke-Command <<<< ([ScriptBlock]::Create("dnvm-$cmd $cmdargs") ) + CategoryInfo : ObjectNotFound: (x86:String) [Invoke-Command], C ommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Co mmands.InvokeCommandCommand 

任何想法如何解决它?

另外,我之前已经分别安装了VS 2015 Preview和DNX / DNVM。 但是我想,在VS 2015安装之前,我完全删除了它。 这可能会影响当前的VS安装吗?

这是一个已知的问题 。

ASP.NET 5:在Windows 7 SP1上,如果没有Powershell 3.0,则无法安装DNX SDK。

症状

当您创build一个ASP.NET 5项目时,您会收到以下错误消息:

DNX SDK版本“dnx-clr-win-x86.1.0.0-beta5”未能安装。 该解决scheme将使用此会话的DNX SDK版本“dnx-clr-win-x86-1.0.0-beta5”

解决方法

要解决此问题,请安装Windows Powershell 3.0(或更高版本)并尝试再次创build该项目。 要查看您当前的PS版本,请运行$PsVersionTable命令( 详细信息 )。

链接:

  • 如何安装Windows PowerShell 4.0 。
  • 在Windows 7上安装PowerShell 3.0 。

打开控制台并运行以下命令安装最新版本 :

dnvm upgrade

如果你重新打开VS你应该能够编译。

如果这不起作用,请尝试删除C:\Users\username\.dnx文件夹。 重新打开VS,它将只用两个脚本在相同的位置重新创build.dnx文件夹:bin \ dnvm.cmd和bin \ dnvm.ps1 注意:这将删除所有已安装的运行时

如果解决schemeDNX SDK版本与已安装的DNX SDK版本匹配,请重新运行dnvm upgrade并在项目属性下进行检查。

我也有这个问题。 这似乎与dnvm.ps1脚本未引用安装path的问题有关。 从Visual Studio命令dnvm install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg"将被调用为dnvm-install C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg ,该path应该被引用。 更多信息可在我打开的拉取请求中find:

https://github.com/aspnet/dnvm/pull/357

解决方法是解决方法是在“C:\ Program Files \ Microsoft DNX \ Dnvm \ dnvm.ps1”中更改以下内容。 这循环通过参数,确保任何包含空格或括号引用。

replace以下行:

 $cmdargs = @($args[1..($args.Length-1)]) 

有:

 # Combine arguments, ensuring any containing whitespace or parenthesis are correctly quoted ForEach ($arg In $args[1..($args.Length-1)]) { if ($arg -match "[\s\(\)]") { $cmdargs += """$arg""" } else { $cmdargs += $arg } $cmdargs += " " } 

如果您在进行此更改后仍然遇到问题,请删除C:\Users\username\.dnx并重新打开Visual Studio以让Visual Studio重新创build该文件夹。

我可以通过这种方式修复它:在2015年的开发者命令提示符下input这个命令

dnvm安装1.0.0-beta5

肯定这样可以解决你的问题。

我的版本的PowerShell是3.0,然后我:

  1. 从以下位置安装powershell v.4:

https://www.microsoft.com/en-us/download/details.aspx?id=40855

  1. 重新启动窗口

这解决了我的问题。

今天早些时候我也遇到过类似的问题,阅读本页的评论后,我设法解决这个问题的方法非常简单。

首先,我不得不说,我已经安装了PowerShell 3.0(没有安装似乎是大多数人的这个问题的主要来源),但我仍然有这个问题。

因此,不必编辑和修改所涉及的PowerShell脚本,以使它们与空白path一起工作,等等,我只是简单地做了如下(更简单):

1.-进入Windows资源pipe理器中的“C:\ Program Files(x86)\ Microsoft Web Tools \ DNX”,并“复制”其所有内容(基本上所有的软件包及其子文件夹)

2.将所有内容“粘贴”到没有空格的path中。 我用“C:\ Temp \”

3.-在命令行上运行以下命令(请注意,在指示的path位置中现在没有空格)

 dnvm update-self dnvm install "C:\Temp\dnx-clr-win-x64.1.0.0-beta5.nupkg" dnvm install "C:\Temp\dnx-coreclr-win-x64.1.0.0-beta5.nupkg" dnvm list 

4.-现在打开您的Visual Studio解决scheme,在您的Project – > Properties – > Application选项卡上,现在您可以指定您想要使用的DNX SDK的版本,

5.-重新build立你的解决scheme,现在应该没问题

好一个!

尝试

 dnvm update-self dnvm install -u -r clr -OS win -a x86 beta5 -ngen 

重要的是-u参数(unstable)和beta5版本string。