我尝试在安装了ASP.NET Core RC2的Mac上编译ASP.NET Core RC2项目。这是我的project.json:
{
"userSecretsId": "aspnet-TestCoreRC2-6a20d1d3-f55a-4683-a8ca-5f5fbff19ab4",
"dependencies": {
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview1-final",
"type": "build"
}
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
"Microsoft.Extensions.SecretManager.Tools": {
"version": "1.0.0-preview1-final",
"imports": "portable-net45+win8+dnxcore50"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
},
"frameworks": {
"net451": {
"dependencies": {
"System.Runtime": "4.0.20"
}
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"tooling": {
"defaultNamespace": "TestCoreRC2"
}
}
这是错误:
编译所需资源时发生错误 处理此请求。请查看以下特定错误 详细说明并适当修改源代码。
生成代码
无法定义使用' dynamic'的类或成员。因为 编译所需的类型 ' System.Runtime.CompilerServices.DynamicAttribute'无法找到。 你错过了参考吗? public class _Views_Home_Index_cshtml:Microsoft.AspNetCore.Mvc.Razor.RazorPage预定义类型 ' System.Boolean'未定义或导入 public class _Views_Home_Index_cshtml:Microsoft.AspNetCore.Mvc.Razor.RazorPage类型'对象'是 在未引用的程序集中定义。你必须添加一个 参考汇编&#m; mscorlib,Version = 4.0.0.0,Culture = neutral, 公钥= b77a5c561934e089'
由于
答案 0 :(得分:2)
答案 1 :(得分:1)
我也面临着引用mscorlib的类似问题。通过添加"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027"
解决了这个问题。此程序包解决了仍然以mscorlib为目标的PCL的依赖关系。更多详细信息为here
修改强> 刚才我看到你的目标是Mac上的net451。您需要切换到" netcoreapp1.0":{}以支持跨平台。尝试对project.json进行以下更改:
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
//other dependencies
},
"frameworks": {
"netcoreapp1.0": {}
},
//Other configs