使用dnxcore50使用Kestrel进行dnu还原时的ArgumentOutOfRangeException

时间:2016-04-25 15:33:46

标签: asp.net-core dnx

我试图在Windows 7上使用dnx核心和Visual Studio代码为Asp.NET Core 1.0构建Web应用程序时遇到了问题。我使用Yeoman生成一个空应用程序,然后运行dnu restore。这给出了以下输出:

Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16609

  CACHE https://api.nuget.org/v3/index.json
Restoring packages for d:\development\asp.net core\yeoman_test\EmptyApplication\
project.json
Writing lock file d:\development\asp.net core\yeoman_test\EmptyApplication\proje
ct.lock.json
----------
System.ArgumentOutOfRangeException: Specified argument was out of the range of v
alid values.
Parameter name: supportedFrameworks
   at NuGet.NetPortableProfile..ctor(String frameworkDirectory, String name, IEn
umerable`1 supportedFrameworks)
   at NuGet.NetPortableProfileTable.LoadPortableProfile(String versionDirectory,
 String profileDirectory)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at NuGet.NetPortableProfileTable.BuildPortableProfileCollection()
   at NuGet.NetPortableProfileTable.GetProfileData()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at NuGet.NetPortableProfileTable.GetProfile(String profileName)
   at NuGet.NetPortableProfile.Parse(String profileValue)
   at NuGet.VersionUtility.IsPortableLibraryCompatible(FrameworkName frameworkNa
me, FrameworkName targetFrameworkName)
   at NuGet.VersionUtility.IsCompatible(FrameworkName frameworkName, FrameworkNa
me targetFrameworkName)
   at NuGet.ContentModel.ContentItemCollection.FindBestItemGroup(SelectionCriter
ia criteria, ContentPatternDefinition[] definitions)
   at Microsoft.Dnx.Tooling.Utils.LockFileUtils.CreateLockFileTargetLibrary(Lock
FilePackageLibrary library, IPackage package, RestoreContext context, String cor
rectedPackageName)
   at Microsoft.Dnx.Tooling.RestoreCommand.WriteLockFile(LockFile previousLockFi
le, String projectLockFilePath, Project project, List`1 graphItems, PackageRepos
itory repository, IProjectResolver projectResolver, IEnumerable`1 contexts)
   at Microsoft.Dnx.Tooling.RestoreCommand.<RestoreForProject>d__69.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<>c__DisplayClass68_0.<<Execute>b__2>
d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
   at Microsoft.Dnx.Tooling.RestoreCommand.<Execute>d__68.MoveNext()
----------
Restore failed
Specified argument was out of the range of valid values.
Parameter name: supportedFrameworks

NuGet Config files used:
    C:\Users\<user>\AppData\Roaming\NuGet\nuget.config

Feeds used:
    https://api.nuget.org/v3-flatcontainer/

我当前运行时的dnvm输出:

*    1.0.0-rc1-update2 coreclr x64          win             default

而project.json:

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

  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
  },

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

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

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

我可以使用以下project.json(并且目录中没有其他文件)以最小的形式复制该问题:

{
    "dependencies": {
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
    },

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

我已经挖掘了Kestrel的nuget包及其依赖项(对于DNXCore5.0):

  <group targetFramework="DNXCore5.0">
    <dependency id="Microsoft.AspNet.Hosting" version="1.0.0-rc1-final" />
    <dependency id="Microsoft.Extensions.Logging.Abstractions" version="1.0.0-rc1-final" />
    <dependency id="System.Numerics.Vectors" version="4.1.1-beta-23516" />
    <dependency id="System.Collections" version="4.0.11-beta-23516" />
    <dependency id="System.Diagnostics.Debug" version="4.0.11-beta-23516" />
    <dependency id="System.Diagnostics.TraceSource" version="4.0.0-beta-23516" />
    <dependency id="System.Diagnostics.Tracing" version="4.0.21-beta-23516" />
    <dependency id="System.Globalization" version="4.0.11-beta-23516" />
    <dependency id="System.IO" version="4.0.11-beta-23516" />
    <dependency id="System.Linq" version="4.0.1-beta-23516" />
    <dependency id="System.Net.Primitives" version="4.0.11-beta-23516" />
    <dependency id="System.Runtime.Extensions" version="4.0.11-beta-23516" />
    <dependency id="System.Runtime.InteropServices" version="4.0.21-beta-23516" />
    <dependency id="System.Text.Encoding" version="4.0.11-beta-23516" />
    <dependency id="System.Threading" version="4.0.11-beta-23516" />
    <dependency id="System.Threading.Tasks" version="4.0.11-beta-23516" />
    <dependency id="System.Threading.Thread" version="4.0.0-beta-23516" />
    <dependency id="System.Threading.ThreadPool" version="4.0.10-beta-23516" />
    <dependency id="System.Threading.Timer" version="4.0.1-beta-23516" />
  </group>

我完成了这些工作,发现将project.json依赖项更改为仅包含Microsoft.AspNet.HostingSystem.Numerics.Vectors会导致与supportedFrameworks相同的错误。可能还有其他人,但在Microsoft.Extensions.Logging.AbstractionsSystem.CollectionsSystem.Diagnostics.Debug工作之后,我决定在此之前提问。

我认为我当然会做一些愚蠢的事情,但似乎无法确切地解决这个问题。

1 个答案:

答案 0 :(得分:2)

删除(或重命名)C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable 文件夹。

<style name="ToolbarStyle" parent="@style/ThemeOverlay.AppCompat.Dark">
    <item name="android:textColorSecondary">@color/jd_white</item>
</style>

另请参阅:NuGet Fails to Install FluentValidation