【问题标题】:How to fix DNX/DNVM in Visual Studio 2015?如何在 Visual Studio 2015 中修复 DNX/DNVM?
【发布时间】:2015-10-11 08:00:05
【问题描述】:

今天我在 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

有什么解决办法吗?

另外,我之前已经分别安装了 VS 2015 Preview 和 DNX/DNVM。但我认为,我在安装 VS 2015 之前将其完全删除。这会以某种方式影响当前的 VS 安装吗?

【问题讨论】:

    标签: .net visual-studio visual-studio-2015 dnx dnvm


    【解决方案1】:

    这是known issue

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

    症状

    当您创建 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 命令 (details)。

    链接:

    【讨论】:

    • 安装 Powershell 3.0 为我完成了这项工作!谢谢!
    • 我安装了 Powershell 4(Windows 7 操作系统)并且运行良好。我想我会跳过 3。:)
    • 我收到此错误消息。我已经安装了一段时间的 PowerShell,但我在上周二刚刚安装了 VS2015 开始学习 MVC。这是否意味着我必须放弃过去几天在 MVC 上所做的所有工作,然后重新创建我的项目?怎么说这不会一次又一次地发生?
    • 可能是我安装的 PowerShell 版本,但除了这一步之外,我还必须按照下面 ph1ll 中的步骤(即编辑 dnvm.ps1 文件)来让一切正常工作。
    • 除了下面这个答案和 ph1ll 的答案之外,当我尝试构建我的项目时,我必须确保 VS 在管理员模式下运行。然后就成功了!
    【解决方案2】:

    Install the latest version 打开控制台并运行:

    dnvm upgrade

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

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

    重新运行dnvm upgrade 并在项目属性下检查您的Solution DNX SDK 版本是否与已安装的版本匹配。

    【讨论】:

      【解决方案3】:

      我也遇到了这个问题。它似乎与 dnvm.ps1 脚本未引用安装路径的问题有关。 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,因为路径应该被引用而中断。有关我在以下位置打开的拉取请求的更多信息:

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

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

      替换以下行:

      $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 重新创建该文件夹。

      【讨论】:

      • 这应该是公认的答案!只需在Package Manager Console 中执行dnvm install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg"
      • @SerjSagan 您建议的命令不起作用。它给出了同样的错误。 (它实际上与原始脚本尝试执行的命令相同,但失败了。)
      • 感谢@ph1ll.. 现在我只是好奇为什么它认为 beta5 是我重新启动 VS 时应该安装的东西
      【解决方案4】:

      我可以通过这种方式修复它: 在 2015 的开发人员命令提示符中输入此命令

      dnvm 安装 1.0.0-beta5

      相信这样可以解决你的问题!

      【讨论】:

        【解决方案5】:

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

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

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

        1. 重启窗口

        这解决了我的问题。

        【讨论】:

          【解决方案6】:

          我今天早些时候遇到了类似的问题,在阅读了此页面中的 cmets 后我设法解决的方法非常简单。

          首先,我必须说我已经安装了 PowerShell 3.0(对于大多数人来说,没有安装它似乎是这个问题的主要来源),但我仍然遇到同样的问题。

          因此,我不必像建议的那样编辑和修改所涉及的 powershell 脚本以使它们与带有空格等的路径一起工作,我只是简单地执行了以下操作(更简单):

          1.- 在 Windows 资源管理器中转到“C:\Program Files (x86)\Microsoft Web Tools\DNX”并“复制”其所有内容(基本上是所有包及其子文件夹)

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

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

          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 解决方案,在您的项目 -> 属性 -> 应用程序选项卡上,您现在可以在其中指定您想要使用的 DNX SDK 版本,您现在可以使用这些版本

          5.- 重新构建您的解决方案,现在应该一切正常

          不错!

          【讨论】:

            【解决方案7】:

            试试

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

            重要的是-u 参数(不稳定)和beta5 版本字符串。

            【讨论】:

              【解决方案8】:

              如果有人在观看一些有点过时的教程(比如我)时遇到 Visual Studio 2015 中不可用的 dnx 问题,请查看下面的link

              .NET Core 的 RC2 版本和 ASP.NET Core 1.0 从 DNX 移出 到 .NET Core CLI。

              在链接页面上的表格中,您将看到 DNX/DNU 命令与其 CLI 对应项之间的映射。 例如:

              dnx run 变为 dotnet run

              【讨论】:

                猜你喜欢
                • 2016-01-24
                • 2015-12-27
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多