无法从Windows发布用于Mac OS的MAUI应用程序

huangapple go评论76阅读模式
英文:

Unable To Publish MAUI App for Mac OS from Windows

问题

我在我的PC上安装了Visual Studio Community(版本17.4.3)。

  • 我创建了一个MAUI应用程序,现在需要将其发布为'pkg'或'app'到Mac设备从Windows。
  • 我在VMWare Workstation上运行MacOS 12以测试该应用程序。
  • 我没有在VMWare中安装Visual Studio For Mac,因为我不打算在Mac上开发。
  • 我的意图是在Windows上开发和构建自包含的应用程序,然后将pkg文件传输到Mac以进行运行和测试。

问题是我无法从Windows发布到Mac。
我做错了什么?

这是我的简单应用程序(只是一个测试应用程序)
无法从Windows发布用于Mac OS的MAUI应用程序

这是我尝试发布到Mac的命令,但它给我报错。

dotnet publish -f net7.0-maccatalyst -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true

无法从Windows发布用于Mac OS的MAUI应用程序

当我尝试列出所有安装的工作负载时,我可以看到以下内容
无法从Windows发布用于Mac OS的MAUI应用程序

但是当我在Visual Studio Installer中检查个别组件时,我认为SDK已安装
无法从Windows发布用于Mac OS的MAUI应用程序

这是我的csproj文件

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
        <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
        <!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
        <OutputType>Exe</OutputType>
        <RootNamespace>MacTest</RootNamespace>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>

        <!-- Display name -->
        <ApplicationTitle>MacTest</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.companyname.mactest</ApplicationId>
        <ApplicationIdGuid>13c5b601-4ac2-49be-a1e0-86c80ce0f8b0</ApplicationIdGuid>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
        <GenerateAppInstallerFile>False</GenerateAppInstallerFile>
        <AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
        <AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
        <GenerateTestArtifacts>True</GenerateTestArtifacts>
        <HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

        <!-- Splash Screen -->
        <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

        <!-- Images -->
        <MauiImage Include="Resources\Images\*" />
        <MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

        <!-- Custom Fonts -->
        <MauiFont Include="Resources\Fonts\*" />

        <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
        <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
    </ItemGroup>

</Project>
英文:

I have Visual Studio Community (Version 17.4.3) in my PC.

  • I created a MAUI app and now need to publish it as a 'pkg' or 'app'
    to a Mac device from Windows
    .
  • I have MacOS 12 running in VMWare Workstation to test the app.
  • I've not installed Visual Studio For Mac in VMWare because I'm not planning to develop in Mac.
  • My intension is to develop and build on Windows as self-contained & then transfer pkg file to Mac for just running and testing

The issue is I was unable to publish for Mac from Windows.
What am I doing wrong?

This is my simple app (It's just a test app)
无法从Windows发布用于Mac OS的MAUI应用程序

This is the command I'm using to try publishing for Mac but it gives me errors.

dotnet publish -f net7.0-maccatalyst -r osx-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true

无法从Windows发布用于Mac OS的MAUI应用程序

When I try to list all workloads installed, This is what I can see
无法从Windows发布用于Mac OS的MAUI应用程序

But when I checked Individual Components in Visual Studio Installer, I'm assuming SDKs are installed
无法从Windows发布用于Mac OS的MAUI应用程序

This is my csproj file

&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;

	&lt;PropertyGroup&gt;
		&lt;TargetFrameworks&gt;net7.0-android;net7.0-ios;net7.0-maccatalyst&lt;/TargetFrameworks&gt;
		&lt;TargetFrameworks Condition=&quot;$([MSBuild]::IsOSPlatform(&#39;windows&#39;))&quot;&gt;$(TargetFrameworks);net7.0-windows10.0.19041.0&lt;/TargetFrameworks&gt;
		&lt;!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --&gt;
		&lt;!-- &lt;TargetFrameworks&gt;$(TargetFrameworks);net7.0-tizen&lt;/TargetFrameworks&gt; --&gt;
		&lt;OutputType&gt;Exe&lt;/OutputType&gt;
		&lt;RootNamespace&gt;MacTest&lt;/RootNamespace&gt;
		&lt;UseMaui&gt;true&lt;/UseMaui&gt;
		&lt;SingleProject&gt;true&lt;/SingleProject&gt;
		&lt;ImplicitUsings&gt;enable&lt;/ImplicitUsings&gt;

		&lt;!-- Display name --&gt;
		&lt;ApplicationTitle&gt;MacTest&lt;/ApplicationTitle&gt;

		&lt;!-- App Identifier --&gt;
		&lt;ApplicationId&gt;com.companyname.mactest&lt;/ApplicationId&gt;
		&lt;ApplicationIdGuid&gt;13c5b601-4ac2-49be-a1e0-86c80ce0f8b0&lt;/ApplicationIdGuid&gt;

		&lt;!-- Versions --&gt;
		&lt;ApplicationDisplayVersion&gt;1.0&lt;/ApplicationDisplayVersion&gt;
		&lt;ApplicationVersion&gt;1&lt;/ApplicationVersion&gt;

		&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;ios&#39;&quot;&gt;11.0&lt;/SupportedOSPlatformVersion&gt;
		&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;maccatalyst&#39;&quot;&gt;13.1&lt;/SupportedOSPlatformVersion&gt;
		&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;android&#39;&quot;&gt;21.0&lt;/SupportedOSPlatformVersion&gt;
		&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;windows&#39;&quot;&gt;10.0.17763.0&lt;/SupportedOSPlatformVersion&gt;
		&lt;TargetPlatformMinVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;windows&#39;&quot;&gt;10.0.17763.0&lt;/TargetPlatformMinVersion&gt;
		&lt;SupportedOSPlatformVersion Condition=&quot;$([MSBuild]::GetTargetPlatformIdentifier(&#39;$(TargetFramework)&#39;)) == &#39;tizen&#39;&quot;&gt;6.5&lt;/SupportedOSPlatformVersion&gt;
		&lt;GenerateAppInstallerFile&gt;False&lt;/GenerateAppInstallerFile&gt;
		&lt;AppxAutoIncrementPackageRevision&gt;True&lt;/AppxAutoIncrementPackageRevision&gt;
		&lt;AppxSymbolPackageEnabled&gt;False&lt;/AppxSymbolPackageEnabled&gt;
		&lt;GenerateTestArtifacts&gt;True&lt;/GenerateTestArtifacts&gt;
		&lt;HoursBetweenUpdateChecks&gt;0&lt;/HoursBetweenUpdateChecks&gt;
	&lt;/PropertyGroup&gt;

	&lt;ItemGroup&gt;
		&lt;!-- App Icon --&gt;
		&lt;MauiIcon Include=&quot;Resources\AppIcon\appicon.svg&quot; ForegroundFile=&quot;Resources\AppIcon\appiconfg.svg&quot; Color=&quot;#512BD4&quot; /&gt;

		&lt;!-- Splash Screen --&gt;
		&lt;MauiSplashScreen Include=&quot;Resources\Splash\splash.svg&quot; Color=&quot;#512BD4&quot; BaseSize=&quot;128,128&quot; /&gt;

		&lt;!-- Images --&gt;
		&lt;MauiImage Include=&quot;Resources\Images\*&quot; /&gt;
		&lt;MauiImage Update=&quot;Resources\Images\dotnet_bot.svg&quot; BaseSize=&quot;168,208&quot; /&gt;

		&lt;!-- Custom Fonts --&gt;
		&lt;MauiFont Include=&quot;Resources\Fonts\*&quot; /&gt;

		&lt;!-- Raw Assets (also remove the &quot;Resources\Raw&quot; prefix) --&gt;
		&lt;MauiAsset Include=&quot;Resources\Raw\**&quot; LogicalName=&quot;%(RecursiveDir)%(Filename)%(Extension)&quot; /&gt;
	&lt;/ItemGroup&gt;

	&lt;ItemGroup&gt;
		&lt;PackageReference Include=&quot;Microsoft.Extensions.Logging.Debug&quot; Version=&quot;7.0.0&quot; /&gt;
	&lt;/ItemGroup&gt;

&lt;/Project&gt;

答案1

得分: 1

.NET MAUI应用程序只能在使用Visual Studio 2022 for Mac时才能启动和调试,以针对Mac Catalyst进行定位。请参阅构建您的第一个应用程序。此外,归档和发布.NET MAUI macOS应通过命令行完成,不支持从Windows远程构建/归档/发布,详情请参阅:发布.NET MAUI应用程序用于macOS.NET MAUI macOS目标发布/归档#5399

英文:

.NET MAUI apps that target Mac Catalyst can only be launched and debugged using Visual Studio 2022 for Mac. Please see Build your first app. In addition, archiving and publishing a .NET MAUI macOS should be through the command-line, remote building/archiving/publishing from Windows are nor supported, please see: Publish a .NET MAUI app for macOS and
.NET MAUI macOS target publishing/archiving. #5399

huangapple
  • 本文由 发表于 2023年2月19日 15:05:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定