AspNetCore“runtimes"是不受支持的框架

本文关键字:支持 框架 runtimes quot AspNetCore | 更新日期: 2023-09-27 18:15:32

当尝试从新的DotNetCore类库导入AspNetCore MVC站点(WebApplication1)以运行一些测试时,我得到以下内容。

有没有人可以照亮编译器是如何工作的,为什么这个runtimes is not supported error is coming ?希望能解决这个问题。

错误:

NU1008  "runtimes" is an unsupported framework. 
Taskily.Tests   
%src%'Taskily.Tests'project.json    19

% % ' Taskily.Tests ' src project.json

{
  "dependencies": {
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.AspNetCore.TestHost": "1.1.0-preview1-final",
    "WebApplication1": "1.0.0-preview2-003131",
    "xunit": "2.2.0-beta3-build3402",
    "xunit.runner.console": "2.2.0-beta3-build3402",
    "xunit.runner.visualstudio": "2.2.0-beta3-build1187"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": [ "dnxcore50", "portable-net45+win8" ]
    }
  },
  "testRunner": "xunit"
}

% % ' src global.json

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

% % ' WebApplication1 ' src project.json

{
  "userSecretsId": "aspnet-WebApplication1-19b75b8b-b10e-4fea-94e8-17c9f955732e",

  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.1"
        }
      },
      "imports": [ "dnxcore50", "portable-net45+win8" ]
    }
  },
  "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.2",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.1",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build",
      "imports": [ "portable-net45+win8+wp8+wpa81" ]
    },
    "Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.1",
    "Microsoft.AspNetCore.Authentication.OAuth": "1.0.0",
    "Newtonsoft.Json": "9.0.2-beta1"
  },
  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8"
      ]
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "copyToOutput": [
      "ssl/*"
    ],
    "define": [ "DEBUG" ]
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config",
      "ssl"
    ]
  },
  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }
}

AspNetCore“runtimes"是不受支持的框架

因为测试项目被认为是一个控制台应用程序(即使您从未直接运行它),所以您将需要对Microsoft.NETCore.App的引用:

"Microsoft.NETCore.App": {
  "type": "platform",
  "version": "1.0.0"
},

"不支持的框架"错误是一种相当无益的说法:"我不能弄清楚这是什么类型的项目!"

作为参考,这里有一个工作的Xunit测试项目。我最近用过的。您不需要引用xunit.runner.consolerunner.visualstudio来使用Test Explorer。

{
  "dependencies": {
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "xunit": "2.1.0"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },
  "testRunner": "xunit"
}