Visual Studio 2015無法進行Package Restore的原因和解決方案


這篇文章是記錄在我的當前電腦上面,安裝Visual Studio 2015 Community Edition出現的無法進行Package Restore的問題,很可能在你的電腦上面無法重現。我的環境是

1.Windows 7  x64

2.已經安裝了Visual Studio 2013

3.已經手工地安裝過dnvm 和dnx

 

問題現象:

為了更好地了解和學習一下最新的ASP.NET 5 , MVC 6等一些特性,在當前電腦上面安裝了Visual Studio 2015 Community Edition。安裝之前,確認過它是可以與當前的Visual Studio 2013並行(Side by side)運行的。

image

按照默認的設置安裝完成后,啟動Visual Studio 2015,創建了一個最簡單的應用程序,但是無法編譯通過,查看輸出窗口,得到如下的錯誤消息

PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git
C:\Users\chenxizhang\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7\bin\dnx.exe "C:\Users\chenxizhang\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7\bin\lib\Microsoft.DNX.PackageManager\Microsoft.DNX.PackageManager.dll" restore "c:\users\chenxizhang\documents\visual studio 2015\Projects\ConsoleApp1\src\ConsoleApp1" -s "C:\Program Files (x86)\Microsoft Web Tools\DNU"
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DNX.PackageManager' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.DNX.PackageManager'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at Microsoft.Dnx.Runtime.Loader.LoadContext.Load(AssemblyName assemblyName)
   at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
   at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

 

看這個錯誤提示,是因為找不到對應的dnx(運行時)中的Package Manager這個組件。果然如此嗎?當前我的電腦上面,已經安裝了好幾個runtime(注意,這是我自己手工安裝的,前期做其他的實驗。Visual Studio 2015在安裝的過程中也會自己安裝dnvm和對應的dnx)

image

Visual Studio 2015默認會調用最新版本的runtime(目前是1.0.0-beta 7),並且嘗試用它進行Package Restore。我找到對應的目錄中去看,確實沒有Microsoft.DNX.PackageManager這個文件夾。

image

但是奇怪的是,稍早的版本(例如1.0.0-beta 5)確是存在這個目錄和對應的DLL

image

 

解決方案

目前尚不清楚為什么beta7反而有這個問題,但要解決這個問題,暫時先用beta 5我覺得也是可以接受的

image

image

 

為了簡便起見,我們也可以將其他的runtime先刪除掉,只留下beta5。這樣就不需要每個項目都去設置了。

image

當然,相信以后1.0.0正式發布之后,這些問題是可以解決掉的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM