0

I am trying to implement options pattern as mentioned in this link - https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration#options-example

For this, started with adding below in my project.json

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

But I am getting error on restoring this package- ConfigurationExtensions Error

My complete project.json is like this-

{
  "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%" ]
  }
}

My environment is - VS2015 update3, .net core SDK 1.0.0 and preview2 tooling

My project template is - ASP.NET core application (.NET framework 4.6.1)

Can anyone please guide me on this?


If I create new project, I can see ConfigurationExtensions by default

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

But my when I add this in existing project which is created during RC1, it gives me error message-

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

Please help me on this.

439
  • 720
  • 2
  • 7
  • 14

1 Answers1

0

I was trying to restore packages from VS2015 by doing right click on references > Restore packages

But somehow, VS2015 was not restoring this particular package.

Then I tried dotnet restore command and it worked successfully.

Adding this as self answer so may be this will help someone in future.

439
  • 720
  • 2
  • 7
  • 14