2016-06-09 54 views
1

我創建了一個新的.NET核心類庫與以下project.json文件:.NET核心RC2:文件夾netstandard1.5包含無效版本

{ 
    "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 

這一步後,我複製這些文件到我的本地的NuGet文件夾,這是我之前設立的Visual Studio 。

這裏是另一個項目的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%" ] 
    } 
} 

一切看起來不錯,但它說「無法解決...」。這裏是輸出:

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包時,我收到此錯誤。

謝謝。

+0

如果我把包直接放到MyNuget目錄中的文件夾結構,它的工作原理對於我來說足夠了。我不知道「無效版本」錯誤的含義。 – svick

+0

@svick,你的nuget包管理器版本是什麼? Mine是3.4.4 –

+0

爲什麼不使用Visual Studio並查看它如何生成引用? –

回答

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命令:

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