c# - .NET Core 全局到和自包含 exe
问题描述
我正在创建一个我想要作为“dotnetcore 全局工具”和独立 exe 的 exe。这就是我的 csproj 的样子:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.1</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<PackAsTool>true</PackAsTool>
<IsPackable>true</IsPackable>
<ToolCommandName>HostRunner</ToolCommandName>
<PackageOutputPath>./nupkg</PackageOutputPath>
<AssemblyName>HostRunner</AssemblyName>
</PropertyGroup>
我可以跑dotnet pack
没问题,但是当我跑的时候
dotnet publish my.csproj -r=win10-x64 -c=Debug --self-contained
我收到一条错误消息error NETSDK1053: Pack as tool does not support self contained.
我究竟做错了什么?!
解决方案
你需要两个 csprojs。一个用于 nuget 包,一个用于 exe。使 exe 使用 nuget 包之一。
推荐阅读
- python - 范围未正确定义
- html - 切换显示/隐藏菜单,带有弹性框和列表项
- java - 使用 AWS SSO 时 AWS Java SDK 未找到配置文件
- python - Python 在打印时结果不一致,想知道可能是什么原因?
- ssl - 在 AWS EKS 和 Istio Ingress 上使用 GRPC 的 SSL 提供 StatusCode.UNAVAILABLE
- javascript - React Testing with Enzyme and Jest ReferenceError: fetch is not defined
- javascript - 为什么没有使用 javascript 中的拼接方法删除数组(在猫鼬模式中)元素?
- r - 将一系列测量标准化为 R 中的单个时间线
- android-studio - Android Studio 和 Flutter - 可以在一个项目中启用网络但在其他项目中不启用?
- java - Java 正则表达式匹配精确的 SSN 模式