恢复Options.ConfigurationExtensions包时出错

时间:2016-11-11 04:55:12

标签: asp.net-core asp.net-core-mvc asp.net-core-1.0 project.json

我正在尝试实现此链接中提到的选项模式 - https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration#options-example

为此,首先在我的project.json

中添加以下内容
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"

但是我在恢复这个包时遇到错误 - ConfigurationExtensions Error

我的完整project.json就像这样 -

{
  "dependencies": {
    "Glimpse": "2.0.0-beta1",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Identity": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Mvc.TagHelpers": "1.0.0",
    "Microsoft.AspNetCore.Mvc.WebApiCompatShim": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "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.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.0",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    }
  },

  "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"
      ]
    }
  },

  "frameworks": {
    "net461": { }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config",
      "Views",
      "Areas/**/Views",
      "appsettings.json"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

我的环境是 - VS2015 update3,.net核心SDK 1.0.0和预览2工具

我的项目模板是 - ASP.NET核心应用程序(.NET framework 4.6.1)

有人可以指导我吗?

如果我创建新项目,我可以默认看到ConfigurationExtensions

"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"

但是当我在RC1期间创建的现有项目中添加它时,它给出了错误消息 -

Error NU1001 The dependency Microsoft.Extensions.Options.ConfigurationExtensions >= 1.0.0 could not be resolved.

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我试图从VS2015恢复包 通过右键单击引用>恢复包

但不知何故,VS2015并没有恢复这个特定的包。

然后我尝试dotnet restore命令,它成功运作。

将此作为自我答案添加,这样可能会对将来有所帮助。