如何从命令行发布 .Net Core ASP 可移植版本?

5

我需要为每个操作系统(win-32、win-64、Linux)构建一个版本。 从Visual Studio中,你可以选择何时发布:依赖框架和便携式。但是我需要在Jenkins上完成。

我尝试使用以下命令:

dotnet publish myapp.csproj --self-contained false --configuration Release --runtime ??? --output "С:\myapp"

但是运行时:"任何","便携式" 不起作用。

如何使用参数“framework dependent”和“portable”进行VS构建? 我没有使用MSBuild、dotnet build或dotnet MSBuild,因为发布命令会添加一些独特的文件(如web.config、资源),并删除无用的(dep *.json)。

1个回答

1
你可以在这里找到所有运行时的列表:runtime.json。取自.NET Core RID(运行时标识符目录)目录
例如:
dotnet publish myapp.csproj --self-contained false --configuration Release --runtime "alpine.3.7" --output "С:\myapp_alpine_3_7"

dotnet publish myapp.csproj --self-contained false --configuration Release --runtime "linuxmint.19.2-x64" --output "С:\myapp_linuxmint_19_2_x64"

当我在 RID 文章中使用 "any" 时出现错误:NETSDK1056。我想要一个构建。这可能吗? - AndreyMagnificent
2
不,这是不可能的。你可以尝试更改输出目录。我已经更新了答案。 - Daniel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接