【发布时间】:2018-01-06 18:52:54
【问题描述】:
我目前正在尝试从 VS2015 发布 Web 应用程序。解决方案正在构建,但是当我想发布时,我不断收到错误消息: “您的项目未引用“.NETFrameworkVersion=v2.0”框架。在project.json的“frameworks”部分添加对“.NETFramewor, Version=v2.0”的引用,然后重新运行NuGet restore .
我已经尝试以 StackOverflow 分析器中建议的几种方式更改 project.json,但这不起作用。
有人可以帮帮我吗?
作为参考,我将添加我的 project.json 文件和问题的屏幕截图。
问题截图:https://imgur.com/l9a4Eru
`{
"userSecretsId": "aspnet-KrisnaldoApp-009a51e2-478c-4020-ac03-0a98477155a1",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.1",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"System.Xml.XmlSerializer": "4.0.11",
"System.Xml.XmlDocument": "4.0.1"
},
"tools": {
"BundlerMinifier.Core": "2.0.238",
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"imports": [
"portable-net45+win8"
],
"version": "1.0.0-preview2-final"
}
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"System.ServiceModel.Duplex": "4.0.1",
"System.ServiceModel.Http": "4.1.0",
"System.ServiceModel.NetTcp": "4.1.0",
"System.ServiceModel.Security": "4.0.1"
},
"imports": [
"dotnet2.0",
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
"prepublish": [
"bower install",
"dotnet bundle"
],
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
}
}`
【问题讨论】:
-
您要发布到本地文件系统吗?如果是这样,请尝试更改位置,以便发布到一个干净的目录。
-
我尝试在 smarterasp.net 中发布到我的主机帐户。我过去用我以前的电脑成功地做到了(结果:www.krisnaldos.be)
-
尝试本文中概述的建议解决方案之一 (stackoverflow.com/questions/36190601/…)。删除您的 bin、obj 和 .vs 目录。然后,重建并发布。