我只想为MacOS和Windows做一个项目,不需要Android或iOS.我try 从名为"platforms"的文件夹中删除平台,但它们似乎会重新生成每个编译.是否有官方方法仅针对必要的平台?我查看了多个项目文件,但到处都是Android和iOS标记.

谁能帮我一下吗?

推荐答案

Required Change
  • 在您的.csproj文件中,删除不为其构建的平台的目标,将其减少为以下内容:

    <TargetFrameworks>net6.0-maccatalyst</TargetFrameworks>
    <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
    
Optional Changes
  • 在您的.csproj文件中,删除不为其构建的平台的支持版本信息,将其减少为以下内容:

    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
    <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
    <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    
  • 删除Platforms文件夹下的所有子目录,这些子目录用于您不为其构建的平台.

Caveats
  • 只能在Windows计算机上为Windows平台生成.
  • 只能从Mac或已设置为Pair to Mac的Windows计算机为MacCatalyst构建.

.net相关问答推荐

EF核心类似功能T-SQL UPDATE FROM

实体框架核心:Azure容器应用程序的执行超时已过期

.NET最小API BadRequest响应不返回正文

MongoDB GridFs with C#,如何存储图片等文件?

为什么不能使用 null 作为 Dictionary 的键?

如何在 C# 中创建 Word 文档?

为什么递归调用会导致不同堆栈深度的 StackOverflow?

.Net 中的 Decimal.One、Decimal.Zero、Decimal.MinusOne 的用途是什么

如何判断一个类型是否是简单类型?即持有一个单一的价值

无法加载文件或程序集'System.ComponentModel.Annotations,版本 = 4.1.0.0

有没有办法只在 C# 中设置一次属性

为什么使用 ImmutableList 而不是 ReadOnlyCollection?

迭代器和枚举器的区别

没有 @Html.Button !

Visual Studio 2017 和 2019 突出显示滚动条中所选单词的出现

如何将 XPath 与 XElement 或 LINQ 一起使用?

覆盖 ASP.NET MVC 中的授权属性

找不到库 hostpolicy.dll

确定使用 ContextMenuStrip 的控件

将控制台输出镜像到文件