[英]What happens of Program.Main when an ASP.NET Core application is run on IISIntegration?
[英]ASP.NET Core IISIntegration.Tools and .NET Framework
在ASP.NET Core 1.0中,我使用的是:
“ Microsoft.AspNetCore.Server.IISIntegration.Tools”:“ 1.0.0-preview2-final”
要運行dotnet發布命令,但是在ASP.NET Core 1.1中,我開始出現以下錯誤:
軟件包Microsoft.AspNetCore.Server.IISIntegration.Tools 1.1.0-preview4-final與net462不兼容(.NETFramework,Version = v4.6.2)。 軟件包Microsoft.AspNetCore.Server.IISIntegration.Tools 1.1.0-preview4-final支持:netcoreapp1.0(.NETCoreApp,Version = v1.0)
如何在ASP.NET Core和常規.NET框架中仍然使用“ dotnet-publish-iis”?
project.json:
{
"dependencies": {
"Dapper": "1.50.2",
"log4net": "2.0.5",
"Microsoft.AspNetCore.Authorization": "1.1.0",
"Microsoft.AspNetCore.Diagnostics": "1.1.0",
"Microsoft.AspNetCore.Routing": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
"Microsoft.AspNetCore.StaticFiles": "1.1.0",
"Microsoft.Extensions.Caching.Abstractions": "1.1.0",
"Microsoft.Extensions.Caching.Memory": "1.1.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Logging.Console": "1.1.0",
"Microsoft.Extensions.Logging.Debug": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
},
"frameworks": {
"net462": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"web.config",
"appsettings.json",
"log4net.xml",
]
},
"scripts": {
"prepublish": [ ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
},
"configurations": {
"Debug": {
"buildOptions": {
"define": [
"DEBUG",
"TRACE"
]
}
},
"Integration": {
"buildOptions": {
"define": [
"DEBUG",
"TRACE"
]
}
},
"Production": {
"buildOptions": {
"define": [ "RELEASE", "TRACE" ],
"optimize": true
}
}
}
}
1)將所有軟件包更新到1.1.0版(以及相應的工具預覽)
2)工具包應安裝在project.json
的tools
部分,而不是dependencies
。
因此,請確保已在project.json
工具”部分下添加了IISIntegration.Tools
,如下所示:
"tools": {
....
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
....
3)刪除舊的project.lock.json
並再次運行dotnet restore
。
4)現在您可以使用dotnet publish
看看是否有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.