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

Omi*_*ich 58 .net visual-studio visual-studio-2015 dnx dnvm

今天我在Windows 7 x64上安装了VS 2015.主要是为了测试新的.Net Core功能等.为了测试,我创建了新的C#"控制台应用程序(包)"解决方案并获得了以下消息:

DNX SDK版本'dnx-clr-win-x86.1.0.0-beta5'无法安装.该解决方案将使用DNX SDK版本'dnx-clr-win-x86.1.0.0-beta5'进行此会话.

我无法编译和调试项目.此外,当我在项目属性中打开调试选项卡时,VS崩溃了.

打开解决方案时的DNVM输出:

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
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决它?

此外,我之前已经分别安装了VS 2015 Preview和DNX/DNVM.但我想,我在VS 2015安装之前完全删除了它.这会以某种方式影响当前的VS安装吗?

Vin*_*ent 55

这是一个已知问题.

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

症状

创建ASP.NET 5项目时,您收到以下错误消息:

DNX SDK版本'dnx-clr-win-x86.1.0.0-beta5'无法安装.该解决方案将使用DNX SDK版本'dnx-clr-win-x86-1.0.0-beta5'进行此会话

解决方法

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

链接:

  • 安装Powershell 3.0为我完成了这项工作!谢谢! (2认同)

des*_*ien 14

通过打开控制台并运行来安装最新版本:

dnvm upgrade

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

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

dnvm upgrade如果您使用的解决方案DNX SDK版本与已安装的解决方案相匹配,请在项目属性下重新运行并检查.


ph1*_*1ll 10

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

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

作为一种解决方法,我的解决方案是在"C:\ Program Files\Microsoft DNX\Dnvm\dnvm.ps1"中更改以下内容.这循环遍历参数,确保引用包含空格或括号的任何参数.

替换以下行:

$cmdargs = @($args[1..($args.Length-1)])
Run Code Online (Sandbox Code Playgroud)

有:

# 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 += " "
}
Run Code Online (Sandbox Code Playgroud)

如果在进行此更改后仍有问题,请删除C:\Users\username\.dnx并重新打开Visual Studio以使Visual Studio重新创建该文件夹.


小智 7

我可以通过这种方式修复它:在2015年的Developer Command提示符中输入此命令

dnvm安装1.0.0-beta5

确保这种方式可以解决您的问题.