linux - VS 代码 + 开发(Linux) + 目标(.net Framework) + 主机(Windows)

标签 linux asp.net-core visual-studio-code web-deployment asp.net-core-2.0

我正在 Linux 上的 Visual Studio Code 上使用 ASPNET Core 2.0 开发 Web 应用程序。但是我尝试部署应用程序的主机是 Windows Server,唯一可用的目标选项是 .Net Framework 4.6。

所以,当我尝试运行 dotnet publish -o/folder -f net461 时,它显示了我 this error .

是否可以在 linux 上开发一个 aspnet core 应用程序并使用 .Net Framework 将其部署到 windows 上?

错误正文如下:

/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(1122,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/home/maransatto/Projects/FATEC/EraDoConhecimento/web/BDAg.csproj]

最佳答案

有两种场景:ASP.Net Core with .Net framework 和 ASP.Net Core with .Net Core。您不能在 Linux 上使用 .net 框架开发 asp.net 核心,因此您的应用程序的目标可能是“netcoreapp2.0”(假设您下载了最新版本)。您可以仅使用 .net core runtime 2.0 在 Windows 服务器上部署您的应用程序。

你的命令应该是

dotnet publish -c Release -f netcoreapp2.0

您可以部署依赖于框架或自包含的版本。参见 ( https://learn.microsoft.com/en-us/dotnet/core/deploying/index)。

您还需要在带有 IIS 集成的 Windows 上使用 Asp.Net Core 模块。 https://learn.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x

当发布自包含时,您不需要在服务器上安装 .net 核心。

关于linux - VS 代码 + 开发(Linux) + 目标(.net Framework) + 主机(Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46934883/

相关文章:

linux - 指定 Telnet 窗口大小

c++ - 读取/写入同一设备时 Portaudio 挂起

java - JSP - 文件上传、设置类路径以及在 Linux 中应该使用哪个 JAR?

c - Fork Process/Read Write through pipe 慢

asp.net-core - 如何从 Controller 中解析 A​​SP NET 5 中的 EF7 当前数据库上下文?

c# - 数字到 bool 值的自动转换 - 从 Newtonsoft 迁移到 System.Text.Json

javascript - 使用部分 View 从多个位置引用相同的 js 文件

visual-studio-code - 从 Visual Studio 代码中一次性删除/替换相同的(代码)字

typescript - eslint 未检测到 TS 错误

ubuntu - 如何在 Ubuntu -2021 上更新 VSCode