I get this error when I try to build the project in Visual Studio Online:
…\Frontend\Startup.cs(65,49): Error CS0518: Predefined type 'System.Void' is not defined or imported
…\Frontend\Startup.cs(65,49): DNXCore,Version=v5.0 error CS0518: Predefined type 'System.Void' is not defined or imported [C:\a\1\s\Frontend\src\Frontend\Frontend.xproj]
It seems that the error happens in the place where I reference another library (package class library).
P.S. I had some conversation about this here: Easy way to build and deploy (to Azure) ASP.NET 5 in Visual Studio Team Services, but there was no answer after all, so I still cannot build it...
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": { }
},
Library 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"
}
The problem was in the fact that my library reference was not in the same folder and the script by default does not run dnu-restore there, so I had to go one level up and start finding project.json recursively there
$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 }
Thanks Eddie - MSFT for help!
Restart visual studio it will resolve the problem. It was the case for me.
In my own issue, I rebuilt the entire solution and the errors just disappeared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With