0

I am struggling to figure out how to force the npm (Nuget Package Manager) to resolve a specific version of the NetStandard1.X platform.

I am trying to use Serilog but the version of .NetStandard it supports is v1.3. Is there any way to force this behavior in the project.json file via some command or switch or option.

        {
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Serilog": "2.2.1"
  },

  "frameworks": {
    "netstandard1.3": {
      "imports": "dnxcore50",
      "dependencies": {
      }
    }
  }
}

When you specify v1.3, you end up with v1.6. Surely there must be a way of doing this? I am trying to upgrade an old .net framework 4.6 class library that was using log4net and I am struggling with the basics here.

Error Dump:

Package Serilog 2.2.1 is not compatible with netstandard1.6 (.NETStandard,Version=v1.6). Package Serilog 2.2.1 supports:
  - net45 (.NETFramework,Version=v4.5)
  - net46 (.NETFramework,Version=v4.6)
  - netstandard1.0 (.NETStandard,Version=v1.0)
  - netstandard1.3 (.NETStandard,Version=v1.3)
One or more packages are incompatible with .NETStandard,Version=v1.6.

DotNet Core Version Info:

Product Information:

Version: 1.0.0-preview2-003131

Commit SHA-1 hash: 635cf40e58

IbrarMumtaz
  • 4,235
  • 7
  • 44
  • 63
  • You can use `nLog` instead of `log4net`, it has an extension package for .Net Core. – Ignas Oct 03 '16 at 11:16
  • Which version of .Net Core do you have installed? Your project.json restores on my machine with no problems. – Ignas Oct 03 '16 at 12:57
  • Thanks but I think that's the SDK version. I am using .Net Core 1.0.1. You can run `dotnet` in your command prompt to get the framework's version. – Ignas Oct 03 '16 at 13:07
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124800/discussion-between-ibrarmumtaz-and-ignas). – IbrarMumtaz Oct 03 '16 at 13:13
  • Log4net is being ported to .net core. GitHub: https://github.com/apache/log4net – IbrarMumtaz Oct 03 '16 at 14:27
  • I think that error could be caused by an outdated version of NuGet. Try updating that. – svick Oct 03 '16 at 14:33
  • Is there a command for that and whats the easiest way to check that? I have version: 3.5.0.1484 installed. – IbrarMumtaz Oct 03 '16 at 14:53

2 Answers2

1

Your project.json restores on my machine correctly, so I would guess there is something wrong with packages/versioning.

Please try to change Serilog dependency version:

"Serilog": "2.3.0-dev-00711"

Or as you suggested yourself during our chat, move the decency into framework tag:

"frameworks": { 
    "netstandard1.6": { 
        "imports": "dotnet5.6", 
        "dependencies": { 
            "Serilog": "2.3.0-dev-00711" 
        } 
    } 
} 
Ignas
  • 4,092
  • 17
  • 28
  • Not sure why i was getting so many type compatibility problems but upgrading to a new package helped. =). Hopefully this is not an issue for other devs as it looks like v1.6 is backwards compatible. – IbrarMumtaz Oct 03 '16 at 14:00
0

I'm not quite sure I understand what the question is or what exactly is the problem you're having.

But one thing that jumps at me about your project.json is that the version of NETStandard.Library should be 1.6.0, even if you're targeting netstandard1.3. (Yes, it's confusing.)

svick
  • 236,525
  • 50
  • 385
  • 514
  • yes i understand and it is very confusing but the package from Serilog is only compatible with netstandard 1.3.0 . The compiler throws up an error about this and is very specific about this compatibility issue. – IbrarMumtaz Oct 03 '16 at 12:39
  • 1
    netstandard.library is a nuget package (https://www.nuget.org/packages/NETStandard.Library/1.6.0) which contains a set of modules/dlls. This library support many .net standard versions: 1.0, 1.1, 1.2 and 1.3. The nuget version doesn't match the version numbers of the .net standard release. – Jaime Jan 21 '17 at 22:59