The dependency >= 1.0.0-rc1-update1 could not be resolved

杀马特。学长 韩版系。学妹 提交于 2019-12-21 20:57:31

问题


I want to update my C# web application to the next asp.net version.

I ran

dnvm use  1.0.0-rc1-update1 -r clr arch x64 -p

and dnvm list shows that the active version has been set to rc1-update1

Now I want to update my VS2015 solution to use rc1-update1

I edited project.json to update the version from rc1-final to rc1-update1

however VS now indicates "package restore failed". and I have error messages like this.

Severity    Code    Description Project File    Line    Suppression State
Error   CS0234  The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)    MyBootStrap.DNX 4.5.1    

Hovering my mouse over the edited dependencies in project.json shows

I must be missing a step. How do I upgrade my project to use the Active Version of the framework?

[Update] When I create a new web application from the template I notice that it is still using rc1-final.

There is also a message in the Solution Explorer window "Package restore failed" The Output shows the following

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\kirsten\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\dnx.exe "C:\Users\kirsten\.dnx\runtimes\dnx-clr-win-x86.1.0.0-rc1-update1\bin\lib\Microsoft.Dnx.Tooling\Microsoft.Dnx.Tooling.dll" 
restore "E:\EShared\Dev2016\MyBootStrap\src\MyBootStrap" -f "C:\Program Files (x86)\Microsoft Web Tools\DNU"
Microsoft .NET Development Utility Clr-x86-1.0.0-rc1-16231
  CACHE https://www.nuget.org/api/v2/
Restoring packages for E:\EShared\Dev2016\MyBootStrap\src\MyBootStrap\project.json
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.Diagnostics'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.IISPlatformHandler'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.Mvc'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.Mvc.TagHelpers'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.Server.Kestrel'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.StaticFiles'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.AspNet.Tooling.Razor'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Extensions.Configuration.FileProviderExtensions'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Extensions.Configuration.Json'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Extensions.Logging'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Extensions.Logging.Console'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.Extensions.Logging.Debug'
  CACHE https://www.nuget.org/api/v2/FindPackagesById()?id='Microsoft.VisualStudio.Web.BrowserLink.Loader'
Unable to locate Dependency Microsoft.AspNet.Diagnostics >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.IISPlatformHandler >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.Mvc >= 6.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.Mvc.TagHelpers >= 6.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.Server.Kestrel >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.StaticFiles >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.AspNet.Tooling.Razor >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.Extensions.Configuration.FileProviderExtensions >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.Extensions.Configuration.Json >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.Extensions.Logging >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.Extensions.Logging.Console >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.Extensions.Logging.Debug >= 1.0.0-rc1-update1
Unable to locate Dependency Microsoft.VisualStudio.Web.BrowserLink.Loader >= 14.0.0-rc1-update1
Writing lock file E:\EShared\Dev2016\MyBootStrap\src\MyBootStrap\project.lock.json
Restore complete, 413ms elapsed

from this I see it is trying to run the x86 version of dnx. Why would that be?

[Update] I am wondering why it would be using nuget.org/api/v2 so I reinstalled nuget using extension manager. It shows version 3.3.0.167 in Extension Manager, yet the output window for Package Manager still metions V2.

I am running Windows 7

[Update] project.json is

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-update1",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-update1",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-update1",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-update1",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-update1",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-update1",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-update1",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-update1",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-update1",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-update1",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-update1",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-update1",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-update1"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}

Here is my NuGet.Config file

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="SBD" value="E:\EShared\NuGet" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <activePackageSource>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </activePackageSource>
</configuration>

Here is my package sources

The SBD one is just a few we developed in house. I don't think it should affect things.


回答1:


It seems you have mixed the version of dnx (Microsoft .NET Execution environment), the version of dnvm (.NET Version Manager) with the version number of the assemblies.

ASP.NET has a modular structure. This has advantages and disadvantages. First of all you can examine your current dnvm (.NET Version Manager) by using:

dnvm version

You can use

dnvm update-self

to update it to the latest version.

In the same way you can use

dnvm list

to see all dnx (Microsoft .NET Execution environment) installed in your profile. %USERPROFILE%\.dnx\runtimes. You will have a folder for every installed version of dnx. By using dnvm use 1.0.0-rc1-update1 -r clr arch x64 -p you change the PATH. You can see the current versions dnx used by default

dnx --version

It uses the dnx.exe from the subdirectory of %USERPROFILE%\.dnx\runtimes, which you included in PATH by dnvm use ....

If you use Visual Studio Project then you create typically global.json which contains

{
  "projects": [
    "src"
  ],
  "sdk": {
    "version": "1.0.0-rc1-update1"
  }
}

Such a setting informs the version of dnx, which should be used during building of the solution/project.

All above steps have no relation to versions of a lot of existing packages currently released. You can go to the page https://www.nuget.org/packages/ and to search for the names of packages. The same packages will be found if you use https://www.nuget.org/api/v2/ or https://api.nuget.org/v3/index.json in NuGet configuration. You can examine http://myget.org/gallery/aspnetmaster to see the current version of ASP.NET 5 assemblies of the "master" builds (stable build) and you can examine http://myget.org/gallery/aspnetvnext to see the latest (unstable from GitHub dev). One can find a lot of other feeds under https://www.myget.org/gallery/, but in my opinion only https://api.nuget.org/v3/index.json and https://www.myget.org/F/aspnetmaster/api/v3/index.json should be used if you want use the latest stable release of ASP.NET 5.

You will see that the latest stable release from http://myget.org/gallery/aspnetmaster have the name "1.0.0-rc1-final", but there are still a lot of assemblies, which have another version as *-rc1-final. In the same way unstable build from http://myget.org/gallery/aspnetvnext have today the name "v1.0.0-rc2-16357", but there are a lot of assemblies, which have another version as *-rc2-16357.

In other words you should not just change the names of all dependencies to use version "*-rc1-update1". You can open "Manage NuGet Packages..." in context menu, check "Include prerelease" and choose "Updates" tab to see whether a new package, which you included in "dependencies" of package.json, is released. Only if you find some new package then you can update it, but the usage of-rc1-update1 for all packages will produce an error.




回答2:


Some tools choose the framework according to aliases. In command line, check if you have alias "default" assigned to 1.0.0-rc1-update1 clr x64 version. If not run the following command.

dnvm alias default 1.0.0-rc1-update1 -a x64 -r clr

This should fix the problem.



来源:https://stackoverflow.com/questions/34553386/the-dependency-1-0-0-rc1-update1-could-not-be-resolved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!