It has been a while since I created a "net new" .NET MAUI project so I thought it would be good to start with the clean template from within Visual Studio and then expand that project to meet my needs, so that I could make sure I was using the latest and greatest with my project as I was confident there was new stuff in there that we really wanted to take advantage of. All was well, local development was totally fine, and then it came time to set up the CI/CD processes with signing and distribution to the stores, it all came to a screeching halt!
My Process
Before I get into the specifics, I want to outline the initial steps that I had in my workflow!
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Ensure .NET Installed
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: 10.0.x
- name: Force X-Code Version
uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1
with:
xcode-version: '26.3.0'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@e0d584e657c606912e8fd522aeed29025975705f # v4.4.2
with:
versionSpec: '6.4.0'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@e0d584e657c606912e8fd522aeed29025975705f # v4.4.2
- name: Install Workloads (Macos)
run: |
dotnet workload install maui
dotnet workload restore "${{ env.mauiproject-path }}"
- name: Restore Packages
run: dotnet restore "${{ env.mauiproject-path }}"
- name: Build/Package iOS
run: |
dotnet publish '${{ env.mauiproject-path }}' \
-c Release -f net10.0-ios \
--no-restore \
-p:version='${{ steps.gitversion.outputs.majorMinorPatch }}' \
-p:ApplicationVersion='${{ steps.gitversion.outputs.commitsSinceVersionSource }}' \
-p:ApplicationDisplayVersion='${{ steps.gitversion.outputs.majorMinorPatch }}' \
-p:ArchiveOnBuild=true \
-p:CodesignProvision='${{ secrets.APPLE_PROVISION_PROFILE_NAME}}' \
-p:RuntimeIdentifier=ios-arm64 \
-p:CodesignKey="\"$APPLE_CERTIFICATE_NAME\"" \
-bl:ios.binlog
As you can see here, pretty common setup. Get the code, ensure that we have .NET installed, force our proper Xcode version, do our own versioning, and then install workloads, do a restore, and go from there.
The Error
No matter what I tried, I always got the same error "NETSDK1047: Assets file '/Users/runner/work/copd-ntm-website/copd-ntm-website/src/Copd.Ntm.Social.Mobile/obj/project.assets.json' doesn't have a target for 'net10.0-ios/ios-arm64'. Ensure that restore has run and that you have included 'net10.0-ios' in the TargetFrameworks for your project. You may also need to include 'ios-arm64' in your project's RuntimeIdentifiers"
Now, I compared my solution project to that of another project, which worked, and I didn't have any issues, so it was a true head-scratcher.
The Fix
At the end of the day, it appears that making a small addition as outlined by the above comment fixed it, such as the following.
<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>
Which is great, my build works! But why/what was different with this project than others?
Restore & Build vs Build/Publish Directly
Ultimately, when I went back to look at my other projects rather than doing a "dotnet restore" and then using the "-- no-restore" parameter on the build, it results in a different dependency chain requirement.
If I allow the project to build/restore on its own, I don't need to add the Target Framework hint! If I want to split restore & build out, I have to add the parameter!
I hope this was helpful for someone!