我創建了一個新的.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包時,我收到此錯誤。
謝謝。
如果我把包直接放到MyNuget目錄中的文件夾結構,它的工作原理對於我來說足夠了。我不知道「無效版本」錯誤的含義。 – svick
@svick,你的nuget包管理器版本是什麼? Mine是3.4.4 –
爲什麼不使用Visual Studio並查看它如何生成引用? –