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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31546274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:41:23  来源:igfitidea点击:

How to fix DNX/DNVM in Visual Studio 2015?

.netvisual-studiovisual-studio-2015dnxdnvm

提问by Omich

Today I installed VS 2015 on Windows 7 x64. Mainly to test new .Net Core features and etc. And for test I created new C# "Console Application (Package)" solution and got this message:

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

DNX SDK version 'dnx-clr-win-x86.1.0.0-beta5' failed to install. The solution will use DNX SDK version ‘dnx-clr-win-x86.1.0.0-beta5' for this session.

DNX SDK 版本“dnx-clr-win-x86.1.0.0-beta5”安装失败。该解决方案将在此会话中使用 DNX SDK 版本“dnx-clr-win-x86.1.0.0-beta5”。

I can't compile and debug project. Also, when I have opened debug tab in project properties then VS crashed.

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

DNVM output when I opened solution:

打开解决方案时的 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

Any ideas how to fix it?

任何想法如何解决它?

Also, I have previously installed VS 2015 Preview and DNX/DNVM separately. But I think, I completely removed it before VS 2015 installation. Could this somehow affects current VS installation?

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

采纳答案by Vincent

This is a known issue.

这是一个已知问题

ASP.NET 5: On Windows 7 SP1, DNX SDK cannot be installed without Powershell 3.0.

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

Symptoms

症状

When you create an ASP.NET 5 project, you receive the following error message:

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

DNX SDK version 'dnx-clr-win-x86.1.0.0-beta5' failed to install. The solution will use DNX SDK version 'dnx-clr-win-x86-1.0.0-beta5' for this session

DNX SDK 版本“dnx-clr-win-x86.1.0.0-beta5”安装失败。该解决方案将在此会话中使用 DNX SDK 版本“dnx-clr-win-x86-1.0.0-beta5”

Workaround

解决方法

To work around this issue, install Windows Powershell 3.0 (or higher) and try to create the project again. To see your current PS version, run $PsVersionTablecommand (details).

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

Links:

链接:

回答by despuestambien

Install the latest versionby opening a console and running:

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

dnvm upgrade

dnvm upgrade

If you reopen VS you should be able to compile.

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

If this doesn't work, try deleting the C:\Users\username\.dnxfolder. Reopen VS and it will recreate the .dnx folder in the same location with only 2 scripts: bin\dnvm.cmd and bin\dnvm.ps1 Note: This would delete all already installed runtimes.

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

Rerun dnvm upgradeand check under the project properties if the Solution DNX SDK Versionyou have matches an installed one.

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

回答by ph1ll

I am also having this problem. It appears to be related to an issue where the dnvm.ps1 script does not quote the install path. The command dnvm install "C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg"from Visual Studio gets recalled as dnvm-install C:\Program Files (x86)\Microsoft Web Tools\DNX\dnx-clr-win-x86.1.0.0-beta5.nupkg, which breaks as the path should be quoted. More information is available on the pull request I opened at:

我也有这个问题。它似乎与 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

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

As a workaround, the solution for me was to change the following in "C:\Program Files\Microsoft DNX\Dnvm\dnvm.ps1". This loops through the arguments, ensuring that any containing whitespace or parenthesis are quoted.

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

Replace the following line:

替换以下行:

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

with:

和:

# 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 += " "
}

If you are still having issues following making this change, delete C:\Users\username\.dnxand reopen Visual Studio to let Visual Studio recreate the folder.

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

回答by Jalil Faalkhah

I could fix it by this way: In Developer Command prompt for 2015 enter this command

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

dnvm install 1.0.0-beta5

dnvm 安装 1.0.0-beta5

sure this way will can fix your issue.!

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

回答by Jesus Campon

I had a similar problem earlier today, and the way in which I managed to solve it after reading the comments in this page was very straight forward.

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

First of all I have to say that I already had PowerShell 3.0 installed (not having it installed seems to be the main source of this problem for most people) and yet I still was having this same issue.

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

So instead of having to edit and modifying the powershell scripts involved in order to make them work with paths with whitespaces, etc as suggested, I just simply did as follows (much simpler):

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

1.- Go to "C:\Program Files (x86)\Microsoft Web Tools\DNX" in Windows explorer and "copy" all its content (basically all the packages and their sub-folders)

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

2.- "Paste" all that content into a path with no blank spaces. I used "C:\Temp\"

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

3.- Run the following commands on the command line (notice there are no blank spaces now in the path locations indicated)

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.- Open your Visual Studio solution now and on your Project -> Properties -> Application tab, in there you can now specify the version of the DNX SDK that you want to use from those of which you have now available

4.- 现在打开您的 Visual Studio 解决方案,在您的项目 -> 属性 -> 应用程序选项卡上,您现在可以在其中指定要使用的 DNX SDK 版本,其中您现在可用

5.- Re-build your solution and it should now be all fine

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

Nice one!

好一个!

回答by MovGP0

try

尝试

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

important are the -uparameter (unstable) and the beta5version string.

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

回答by scx

If anyone have problems with dnx not available in Visual Studio 2015 while watching some bit outdated tutorials ( like me ) check below link

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

The RC2 release of .NET Core and ASP.NET Core 1.0 moved from DNX to the .NET Core CLI.

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

In the table on the linked page you will the mapping between the DNX/DNU commands and their CLI counterparts. for example:

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

dnx runbecomes dotnet run

dnx run变成 dotnet run

回答by Lev K.

My version of powershell was 3.0, then I:

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

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

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

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

  1. Reboot windows
  1. 重新启动窗口

This solve my problem.

这解决了我的问题。