我无法在模拟器上运行我的项目,出现以下错误
/usr/local/share/dotnet/sdk/8.0.302/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(5,5):错误NETSDK1047:资产文件'/Users/ragib.noor/ Repository/PMI_Service_Gateway/src/PMI.Service.Mobile.Maui/PMI.Service.Mobile.Maui.iOS/obj/project.assets.json' 没有 'net8.0-ios/iossimulator-x64' 的目标。确保恢复已运行并且您已将“net8.0-ios”包含在项目的 TargetFrameworks 中。您可能还需要在项目的 RuntimeIdentifiers 中包含“iossimulator-x64”。 (NETSDK1047) (PMI.Service.Mobile.Maui.iOS)
在我的项目中,我仅在运行时针对 ios,这是我的项目配置
<PropertyGroup>
<TargetFramework>net8.0-ios</TargetFramework>
<SupportedOSPlatformVersion>14.0</SupportedOSPlatformVersion>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseMaui>true</UseMaui>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
<BuildIpa>true</BuildIpa>
<IpaMetadata>info.plist</IpaMetadata>
<IpaPackageName>****</IpaPackageName>
<CodesignKey>*****</CodesignKey>
<CodesignProvision>****</CodesignProvision>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<UseNativeHttpHandler>false</UseNativeHttpHandler>
<MtouchExtraArgs>-v -v -v -v --dlsym:Microsoft.Win32.Registry.dll</MtouchExtraArgs>
<MtouchLink>SdkOnly</MtouchLink>
<OptimizePNGs>false</OptimizePNGs>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
<BuildIpa>true</BuildIpa>
<IpaMetadata>info.plist</IpaMetadata>
<CodesignProvision>******</CodesignProvision>
<CodesignKey></CodesignKey>
<IpaPackageName></IpaPackageName>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
</PropertyGroup>
我尝试清理我的 bin/obj 文件夹,恢复 nuget 包,重新启动 ide 多次,但仍然没有成功。
这是我的VS详细信息
Visual Studio Community 2022 for Mac
Version 17.6.12 (build 410)
Installation UUID: 77a4961a-16b0-4d71-867b-366b473d86b3
Runtime
.NET 7.0.3 (64-bit)
Architecture: Arm64
Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2
Roslyn (Language Service)
4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa
NuGet
Version: 6.4.0.117
.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/8.0.302/Sdks
SDK Versions:
8.0.302
7.0.316
6.0.422
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks
.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
8.0.6
7.0.19
6.0.30
Xamarin.Profiler
Version: 1.8.0.49
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
Updater
Version: 11
Apple Developer Tools
Xcode: 15.2 22503
Build: 15C500b
Xamarin.Mac
Version: 9.3.0.23 Visual Studio Community
Hash: 9defd91b3
Branch: xcode14.3
Build date: 2023-10-23 16:14:59-0400
Xamarin.iOS
Version: 16.4.0.23 Visual Studio Community
Hash: 9defd91b3
Branch: xcode14.3
Build date: 2023-10-23 16:15:00-0400
Xamarin Designer
Version: 17.6.3.9
Hash: 2648399ae8
Branch: remotes/origin/d17-6
Build date: 2024-05-09 04:36:07 UTC
Xamarin.Android
Version: 13.2.2.0 (Visual Studio Community)
Commit: xamarin-android/d17-5/45b0e14
Android SDK: /Users/ragib.noor/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
13.0 (API level 33)
SDK Command-line Tools Version: 7.0
SDK Platform Tools Version: 34.0.3
SDK Build Tools Version: 32.0.0
Build Information:
Mono: d9a6e87
Java.Interop: xamarin/java.interop/d17-5@149d70fe
SQLite: xamarin/sqlite/3.40.1@68c69d8
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.16.1
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
Android SDK Manager
Version: 17.6.0.50
Hash: a715dca
Branch: HEAD
Build date: 2024-05-09 04:36:12 UTC
Android Device Manager
Version: 0.0.0.1309
Hash: 06e3e77
Branch: HEAD
Build date: 2024-05-09 04:36:12 UTC
Build Information
Release ID: 1706120410
Git revision: 2f8e0518dd80a933901821bac53f7398d4b61c0f
Build date: 2024-05-09 04:34:23+00
Build branch: release-17.6
Build lane: release-17.6
Operating System
Mac OS X 14.5.0
Darwin 23.5.0 Darwin Kernel Version 23.5.0
Wed May 1 20:17:33 PDT 2024
root:xnu-10063.121.3~5/RELEASE_ARM64_T6031 arm64
请指导我运行这个项目需要检查什么。 注意:相同的项目配置在我的 intel mac 上运行,现在我尝试在 m3 mac 上运行
本文中的线索,在 iOS 设备上运行 MAUI 时出错 - Microsoft Learn https://learn.microsoft.com/en-us/answers/questions/902932/error-running-maui-on-ios-device 有帮助。
dotnet restore --runtime iossimulator-x64 mySolutionFile.sln
这使我能够从(现已弃用)Visual Studio 2022 启动模拟器,并在 .NET 8.0 上绕过此错误