当我尝试在Visual Studio Online中构建项目时出现此错误:
前端\ src \前端\ Startup.cs(65,49):错误CS0518:未定义或导入预定义类型'System.Void'C:\ a\1\s\Frontend\src\Frontend\Startup.cs(65 ,49):DNXCore,Version = v5.0错误CS0518:未定义或导入预定义类型'System.Void'[C:\ a\1\s\Frontend\src\Frontend\Frontend.xproj]
似乎错误发生在我引用另一个库(包类库)的地方.
PS我在这里有一些关于此的讨论:在Visual Studio Team Services中构建和部署(到Azure)ASP.NET 5的简单方法,但毕竟没有答案,所以我仍然无法构建它...
Web project.json:
"dependencies": { "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final", "Microsoft.Extensions.Logging": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final", "Web.Common": "1.0.0-*" }, "frameworks": { "dnx451": { }, "dnxcore50": { } },
图书馆project.json
"frameworks": { "dnx451": { }, "dnxcore50": { "dependencies": { "Microsoft.CSharp": "4.0.1-beta-23516", "System.Collections": "4.0.11-beta-23516", "System.Linq": "4.0.1-beta-23516", "System.Runtime": "4.0.21-beta-23516", "System.Threading": "4.0.11-beta-23516" } } }, "dependencies": { "Microsoft.AspNet.Mvc": "6.0.0-rc1-final" }
问题在于我的库引用不在同一个文件夹中,并且默认情况下脚本没有在那里运行dnu-restore,所以我不得不向上升级并开始在那里递归地找到project.json
$SourceRoot = Split-Path -Path $PSScriptRoot -Parent # run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools Get-ChildItem -Path $SourceRoot -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }
感谢Eddie - MSFT的帮助!