当前位置:  开发笔记 > 编程语言 > 正文

在ASP.NET 5的Visual Studio Online构建期间未定义或导入预定义类型"System.Void"

如何解决《在ASP.NET5的VisualStudioOnline构建期间未定义或导入预定义类型"System.Void"》经验,为你挑选了0个好方法。

当我尝试在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的帮助!

推荐阅读
雯颜哥_135
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有