.net core RC2 using own local Nuget Package: The folder netstandard1.5 contains an invalid version

谁都会走 提交于 2019-12-11 04:25:14

问题


I create a new .net core class library with the following project.json file:

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

With the "scripts" > "postcompile" I am exporting the nuget package for this library which outputs these files and folder:

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

After this step, I am copying these files into my local nuget folder which I set up before on Visual Studio.

And here is the other project's project.json file (.net core web application) which i want to add the nuget package above.

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

Everything looks fine but it says "Unable to resolve...". Here is the output:

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\

What might be the problem here? Why can not it resolve this nuget package?

If I add Solid.Common.Log project to web project as an existing project and reference it, everything works fine. But when I try to add it as a nuget package, I am getting this error.

Thanks.


回答1:


Instead of moving the files manually using this command handles the issue:

nuget.exe add <nupkg> -Source C:\PathToLocalNuget

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




回答2:


From the warning in your log file

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

It looks like you have copied the whole Solid.Common.Log directory in to D:\Projects\MyNuget folder.

You need to copy just the .nupkg files in to the MyNuget folder as described here.

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

Alternatively, if you would like you can use the new faster alternate layout for NuGet 3.3, but it requires a bit more work: http://blog.nuget.org/20150922/Accelerate-Package-Source.html.

Instead of copying the dll across, run the PowerShell cmdlet:

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

Which will produce a folder structure similar to

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


来源:https://stackoverflow.com/questions/37734618/net-core-rc2-using-own-local-nuget-package-the-folder-netstandard1-5-contains

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!