移除特定NuGet包导致F# Xamarin.iOS项目构建失败
Hey there, let's work through this issue you're hitting. When you remove the outdated FsEssentials_jhbertra package, your Xamarin.iOS F# library starts throwing errors like missing float or List types—this is almost always tied to how FSharp.Core is referenced in your project, since that package was probably handling some platform-specific configuration for you.
Here are the steps to resolve this:
1. Verify and Fix FSharp.Core References
- First, check if your
FsGame.iOSproject has a validFSharp.Corereference. The outdated package likely included a properly configured reference tailored for Xamarin.iOS, so removing it left a gap. - Uninstall any existing
FSharp.CoreNuGet package from the project, then reinstall a version compatible with your Xamarin.iOS and F# toolchain. For most Xamarin.iOS setups, stick to stableFSharp.Coreversions (e.g., 4.7.2 or newer, matching your F# language version). - Open your
.fsprojfile directly and make sure there are no conflicting or stale references. Look for<PackageReference>entries forFSharp.Core—ensure they point to the correct version, and there are no old-style<Reference>entries pointing to local DLLs that might be broken.
2. Add Platform-Specific Configuration for FSharp.Core
Xamarin.iOS has unique requirements for framework assemblies, so add this configuration to your .fsproj to ensure FSharp.Core is fully included:
<PropertyGroup> <UseFullFSharpCore>True</UseFullFSharpCore> </PropertyGroup>
This prevents the Xamarin linker from stripping critical parts of FSharp.Core that contain basic types like float and List.
3. Check F# Language Version Matching
- Go to your project properties (right-click the project → Properties → Build → F# Options) and confirm the F# language version matches the version of
FSharp.Coreyou're using. For example,FSharp.Core 4.7.2pairs well with F# 5.0 or later. - Mismatched versions can cause the compiler to fail resolving core types even if the reference is present.
4. Clean and Rebuild from Scratch
Cached build artifacts often cause weird reference issues:
- Clean the project (right-click → Clean).
- Delete the
binandobjfolders from your project directory. - Clear your NuGet cache with the command:
dotnet nuget locals all --clear - Restore packages and rebuild the project.
5. Compare with the Working Master Branch
Since your master branch builds correctly, compare its configuration to your modified branch:
- Check the
.fsprojfile and NuGet package references in master to see howFSharp.Corewas configured whenFsEssentials_jhbertrawas present. - Copy any relevant configuration (like version numbers or additional properties) to your current project to replicate the working setup without the outdated package.
Give these steps a shot, and you should get your project building smoothly again. If you run into specific version conflicts or project file issues, feel free to share more details about your toolchain version!
内容的提问来源于stack exchange,提问作者Jamie Bertram

