.net core RC2使用自己的本地Nuget包:文件夹netstandard1.5包含无效版本

时间:2016-06-09 19:27:28

标签: .net nuget asp.net-core .net-core-rc2

我使用以下project.json文件创建一个新的.net核心类库:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": "dnxcore50"
    }
  },
  "scripts": {
    "postcompile": [
      "dotnet pack --no-build --configuration %compile:Configuration%"
    ]
  }
}

使用"脚本" > " postcompile"我正在导出这个库的nuget包,它输出这些文件和文件夹:

/netstandard1.5
Solid.Common.Log.1.0.0.nupkg
Solid.Common.Log.1.0.0.symbols.nupkg

完成此步骤后,我将这些文件复制到我之前在Visual Studio上设置的本地nuget文件夹中。

这是另一个项目的project.json文件(.net核心Web应用程序),我想在上面添加nuget包。

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Solid.Common.Log": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

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

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

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

一切看起来都很好,但它说'#34;无法解决......"。这是输出:

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 "D:\Projects\Playground\Solid.Disaster\.vs\restore.dg"
log  : Restoring packages for D:\Projects\Playground\Solid.Disaster\src\Solid.Disaster.Web\project.json...
info :   CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethostresolver/index.json
info :   CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.dotnethost/index.json
warn : The folder 'D:\Projects\MyNuget\Solid.Common.Log\netstandard1.5' contains an invalid version.
info :   GET https://api.nuget.org/v3-flatcontainer/solid.common.log/index.json
info :   NotFound https://api.nuget.org/v3-flatcontainer/solid.common.log/index.json 923ms
error: Unable to resolve 'Solid.Common.Log (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
log  : Restoring packages for tool 'Microsoft.AspNetCore.Server.IISIntegration.Tools' in D:\Projects\Playground\Solid.Disaster\src\Solid.Disaster.Web\project.json...
info : Committing restore...
log  : Writing lock file to disk. Path: D:\Projects\Playground\Solid.Disaster\src\Solid.Disaster.Web\project.lock.json
log  : D:\Projects\Playground\Solid.Disaster\src\Solid.Disaster.Web\Solid.Disaster.Web.xproj
log  : Restore failed in 1670ms.
Errors in D:\Projects\Playground\Solid.Disaster\src\Solid.Disaster.Web\Solid.Disaster.Web.xproj
    Unable to resolve 'Solid.Common.Log (>= 1.0.0)' for '.NETCoreApp,Version=v1.0'.
NuGet Config files used:
    C:\Users\SolidWrist\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
    https://api.nuget.org/v3/index.json
    D:\Projects\MyNuget
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

这可能是什么问题?为什么不能解决这个nuget包?

如果我将Solid.Common.Log项目作为现有项目添加到Web项目并引用它,一切正常。但是当我尝试将其添加为nuget包时,我收到此错误。

感谢。

2 个答案:

答案 0 :(得分:4)

使用此命令手动移动文件而不是处理问题:

System::Windows::Forms::ListBox::ObjectCollection ^

https://github.com/NuGet/Home/issues/2955

答案 1 :(得分:1)

来自日志文件中的警告

warn : The folder 'D:\Projects\MyNuget\Solid.Common.Log\netstandard1.5' contains an invalid version.

您似乎已将整个Solid.Common.Log目录复制到D:\Projects\MyNuget文件夹中。

您只需将.nupkg文件复制到MyNuget文件夹中,如here所述。

D:\Projects\MyNuget\Solid.Common.Log.1.0.0.nupkg

或者,如果您希望可以为NuGet 3.3使用新的更快的备用布局,但它需要更多工作:http://blog.nuget.org/20150922/Accelerate-Package-Source.html

不要复制dll,而是运行PowerShell cmdlet:

Publish-Package "c:\path\to\Solid.Common.Log.1.0.0.nupkg" -PackageSource "D:\Projects\MyNuget"

这将生成类似于

的文件夹结构
D:\Projects\MyNuget
    Solid.Common.Log\
        1.0.0\
            Solid.Common.Log.1.0.0.nupkg
            Solid.Common.Log.nuspec
            Solid.Common.Log.1.0.0.nupkg.sha512