Building Xamarin.Forms iOS project from command line with msbuild


I’m trying to build a Xamarin.Forms iOS project via command line for CI/CD purposes directly on macOS:

msbuild C4S_MobileApp.iOS/C4S_MobileApp.iOS.csproj /restore /p:Platform=iPhone /p:ArchiveOnBuild=true /p:Configuration="Release" /p:BuildProjectReferences="false"

The problem is the shared app project which I avoid rebuilding with /p:BuildProjectReferences="false" and whose .dll can’t be found:

CSC : error CS0006: Metadata file '/Users/c4s/Projects/c4s_refactored/c4s-refactored-mobile-app/C4S_MobileApp/bin/iPhone/Release/netstandard2.1/C4S.MobileApp.dll' could not be found [/Users/c4s/Projects/c4s_refactored/c4s-refactored-mobile-app/C4S_MobileApp.iOS/C4S_MobileApp.iOS.csproj]

MSBuild assumes the .dll in C4S_MobileApp/bin/iPhone/Release/netstandard2.1/ but it’s in C4S_MobileApp/bin/Release/netstandard2.1. An ugly solution would be to copy the C4S.MobileApp.dll to that location. Building without /p:BuildProjectReferences="false" works because msbuild then creates C4S_MobileApp/bin/iPhone/Release/netstandard2.1/C4S.MobileApp.dll

I added the parameter /p:AssemblySearchPaths="C4S_MobileApp/bin/Release/netstandard2.1" to msbuild command and also added <AssemblySearchPaths>C4S_MobileApp/bin/Release/netstandard2.1;$(AssemblySearchPaths)</AssemblySearchPaths> to the C4S_MobileApp.iOS.csproj file under Release|iPhone configuration but it seems to be ignored by msbuild.

Folder structure:
-> C4S_MobileApp/
-> C4S_MobileApp.iOS/

Thanks for your help and suggestions.

Source: Xamarin.ios Questions

Categorised as Uncategorised Tagged , , ,


A round of applause for your post. Really thank you! Cool. Barbey Obidiah Shirberg

Leave a Reply

Your email address will not be published. Required fields are marked *

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us