Failed to resolve the following dependencies for t

2019-06-23 19:18发布

I'm using ASP.NET 5.0 and I wanted to run just on the new Core CLR, so I removed "dnx451": { } from dependencies in my project.json file. I now get the following error when I launch in IIS:

Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1': Microsoft.AspNet.Mvc 6.0.0-beta4 Microsoft.AspNet.Server.IIS 1.0.0-beta4 Microsoft.AspNet.Server.WebListener 1.0.0-beta4 Microsoft.AspNet.StaticFiles 1.0.0-beta4

My understanding was that AspNet.Mvc 6 would run on Core CLR? Why then do I have to include dnx451 as a dependency?

My project.json file:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Mvc": "6.0.0-beta4",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta4",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta4"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
  },

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

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ]
}

2条回答
一夜七次
2楼-- · 2019-06-23 19:42

I had this error when publishing my DNX web app. It turned out it was because I had upgraded from Beta5 to Beta6 but neglected to update my publish powershell script which looks like:

$thisFolder = (Get-Item -Path ".\" -Verbose).FullName
$webFolder = "$thisFolder\..\src\Web.UI"
dnu publish $webFolder `
 --out \\uatserver\uatshare ` 
 --configuration DEBUG ` 
 --no-source `
 --runtime dnx-clr-win-x64.1.0.0-beta5

So in the last parameter my publish was still telling it to target beta5 instead of beta6.

查看更多
甜甜的少女心
3楼-- · 2019-06-23 20:01

Specifying dnxcore50 as a dependency in project.json is not the same as telling the Solution to target that dnx. To fix this I had to modify the solution global.json file to use a specific version of the dnx (i.e. a specific .Net executable). I also had to change a few using statements to use new Core CLR libraries instead of .Net 4.5 libraries. You will get intellisense and error warnings about these.

The global.json file can be found under the Solution node. I had to add the sdk version part:

{
    "projects": [ "src", "test" ],
    "sdk": {
        "version": "1.0.0-beta4"
    }
}

Note that you can also edit this in a GUI:

enter image description here

Strongly recommend the recently uploaded ASP.NET Introduction and ASP.NET Deep Dive videos from Build 2015 available on Channel 9.

查看更多
登录 后发表回答