为.net核心类库安装nuget包时出现版本错误

时间:2016-11-14 11:32:21

标签: nuget nuget-package .net-core nuget-spec

我为.net核心类库创建了一个nuget包。

下面的

是我的nuget打包类库

的Project.json代码
{
  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1",
    "System.Collections.NonGeneric": "4.0.1",
    "System.Dynamic.Runtime": "4.0.11",
    "System.IO.FileSystem.Watcher": "4.0.0",
    "System.Runtime.Loader": "4.0.0",
    "System.Threading.Thread": "4.0.0"
  },

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  },
  "version": "1.0.0-*"
}

当我尝试在另一个类库中安装此nuget包时,我收到以下错误。

Retrieving package 'JsonConfig.Core 1.0.0' from 'Local Packages'.
Installing NuGet package JsonConfig.Core.1.0.0.
Successfully installed 'JsonConfig.Core 1.0.0' to ClassLibrary1
Executing nuget actions took 37.98 ms
========== Finished ==========
Time Elapsed: 00:00:02.8637585
PATH=.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Program Files\dotnet\dotnet.exe restore "C:\Users\sbonumaddi\Documents\Visual Studio 2015\Projects\TestNugetPackage\.vs\restore.dg"
log  : Restoring packages for C:\Users\sbonumaddi\Documents\Visual Studio 2015\Projects\TestNugetPackage\src\ClassLibrary1\project.json...
error: Package JsonConfig.Core 1.0.0 is not compatible with netstandard1.6 (.NETStandard,Version=v1.6). Package JsonConfig.Core 1.0.0 supports: net (.NETFramework,Version=v0.0)
error: One or more packages are incompatible with .NETStandard,Version=v1.6.
log  : Writing lock file to disk. Path: C:\Users\sbonumaddi\Documents\Visual Studio 2015\Projects\TestNugetPackage\src\ClassLibrary1\project.lock.json
log  : C:\Users\sbonumaddi\Documents\Visual Studio 2015\Projects\TestNugetPackage\src\ClassLibrary1\ClassLibrary1.xproj
log  : Restore failed in 387ms.
Errors in C:\Users\sbonumaddi\Documents\Visual Studio 2015\Projects\TestNugetPackage\src\ClassLibrary1\ClassLibrary1.xproj
    Package JsonConfig.Core 1.0.0 is not compatible with netstandard1.6 (.NETStandard,Version=v1.6). Package JsonConfig.Core 1.0.0 supports: net (.NETFramework,Version=v0.0)
    One or more packages are incompatible with .NETStandard,Version=v1.6.

以下是我的nuget spec文件

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata minClientVersion="3.2">
        <id>JsonConfig.Core</id>
        <version>1.0.0</version>
        <title>JsonConfig.Core</title>
        <authors>Satish Kumar B</authors>
        <owners>Satish Kumar B</owners>
        <licenseUrl>https://github.com/Dynalon/JsonConfig/blob/master/LICENSE.txt</licenseUrl>
        <projectUrl>https://github.com/satish049/JsonConfig</projectUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>JsonConfig.Core is ported from JsonConfig by Timo Dörr. JsonConfig.Core is a simple to use configuration library, allowing JSON based config files for your C#/.NET Core application instead of cumbersome web.config/application.config xml files.

It is based on Newtonsoft.Json.Net and C# 4.0 dynamic feature. Allows putting your programs config file into .json files, where a default config can be embedded as a resource or put in the (web-)application folder. Configuration can be accessed via dynamic types, no custom classes or any other stub code is necessary.

JsonConfig brings support for config inheritance, meaning a set of configuration files can be used to have a single, scoped configuration at runtime which is a merged version of all provided configuration files.</description>
        <summary>simple configuration library using JSON and C# 4.0 dynamic feature and .Net Core</summary>
        <copyright>Copyright (c) 2012-2016 Timo Dörr,2016 Satish Kumar B</copyright>
        <tags>json, config, configuration,json .net core</tags>
        <dependencies>
            <dependency id="NETStandard.Library" version="1.6.0" />
            <dependency id="Newtonsoft.Json" version="9.0.1" />
            <dependency id="System.Collections.NonGeneric" version="4.0.1" />
            <dependency id="System.Dynamic.Runtime" version="4.0.11" />
            <dependency id="System.IO.FileSystem.Watcher" version="4.0.0" />
            <dependency id="System.Runtime.Loader" version="4.0.0" />
            <dependency id="System.Threading.Thread" version="4.0.0" />
        </dependencies>
    </metadata>
    <files>
        <file src="bin\Debug\netstandard1.6\JsonConfig.Core.dll" target="lib\netstandard1.6\JsonConfig.Core.dll" />
        <file src="bin\Debug\netstandard1.6\JsonConfig.Core.pdb" target="lib\netstandard1.6\JsonConfig.Core.pdb" />
    </files>
</package>

编辑1 ---

下面是我正在尝试安装此软件包的类库的Project.json

{
  "version": "1.0.0-*",

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

  "frameworks": {
    "netstandard1.6": {
      "imports": "dnxcore50"
    }
  }
}

请有人帮我解决这个问题。

0 个答案:

没有答案