[英]How to fix DNX/DNVM in Visual Studio 2015?
今天我在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安装吗?
通过打开控制台并运行来安装最新版本 :
dnvm upgrade
如果你重新打开VS,你应该能够编译。
如果这不起作用,请尝试删除C:\\Users\\username\\.dnx
文件夹。 重新打开VS,它将在同一位置重新创建.dnx文件夹,只有2个脚本:bin \\ dnvm.cmd和bin \\ dnvm.ps1 注意:这将删除所有已安装的运行时 。
如果您使用的解决方案DNX SDK版本与已安装的解决方案相匹配,请重新运行dnvm upgrade
并检查项目属性。
我也有这个问题。 它似乎与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重新创建该文件夹。
我可以通过这种方式修复它:在2015年的Developer Command提示符中输入此命令
dnvm安装1.0.0-beta5
确保这种方式可以解决您的问题。
我的powershell版本是3.0,然后我:
https://www.microsoft.com/en-us/download/details.aspx?id=40855
这解决了我的问题。
我今天早些时候遇到过类似的问题,在阅读本页评论后,我设法解决这个问题非常简单。
首先,我必须说我已经安装了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.-重新构建您的解决方案,它现在应该都很好
好一个!
尝试
dnvm update-self
dnvm install -u -r clr -OS win -a x86 beta5 -ngen
重要的是-u
参数(不稳定)和beta5
版本字符串。
如果有人在Visual Studio 2015中看到dnx时出现问题,同时观看一些过时的教程(像我一样),请查看以下链接
.NET Core和ASP.NET Core 1.0的RC2版本从DNX迁移到.NET Core CLI。
在链接页面的表中,您将看到DNX / DNU命令与其CLI对应项之间的映射。 例如:
dnx run
成为dotnet run
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.