Xamarin.Forms
Xamarin.Forms copied to clipboard
Xamarin.Forms build for UWP fails in Release build configuration with .NET native toolchain
This issue has been moved from a ticket on Developer Community.
Building a Xamarin.Forms application for UWP fails in Release build configuration with the following error message:
C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\Microsoft.NetNative.targets(809,5): error : Error: NUTC301B:Internal Compiler Error: Assembly 'Xamarin.Forms.Core' not found while loading type 'Xamarin.Forms.Platform.UWP.WindowsBasePage'. while loading type 'Xamarin.Forms.Platform.UWP.WindowsPage'. while loading type 'TestApp.UWP.MainPage'. while computing compilation roots.
C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\Microsoft.NetNative.targets(809,5): error : ILT0005: 'C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x64.microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\x64\ilc\Tools\nutc_driver.exe @"C:\Work\TestApp\TestApp\TestApp.UWP\obj\x64\Release\ilc\intermediate\MDIL\TestApp.UWP.rsp"' returned exit code 1
The problem can be reproduced with a blank Xamarin.Forms application. Disabling the .NET native toolchain from the project's build options seems to resolve the error:

I have tested this on different machines and different versions of Visual Studio with the same outcome:
- Windows 10 Pro Version 21H1 and 21H2
- Visual Studio 2019 version 16.11.17 and Visual Studio 2022 Version 17.3.0 Preview 4.0
- Windows SDK version 2004 (build 19041) and Windows SDK version 2104 (build 20348)
- Xamarin.Forms version 5.0.0.2515
Strangely, this started to occur after a recent Windows update. The build was successful before the update, without having to disable the .NET native toolchain. Please, advise how to proceed, as this is impacting all the CI builds in my organization.
PS: Attached you can find the build output log with diagnostic verbosity level.
Original Comments
Feedback Bot on 7/25/2022, 07:33 PM:
(private comment, text removed)
Original Solutions
(no solutions)
@IvanTTodorov I would try downgrading the Microsoft.NETCore.UniversalWindowsPlatform package, to force it using an older compiler, perhaps? for whatever reason all the compiler builds since 2019 have been marked as pre-release and I have had occasional problems - downgrading that package was the way to fix it.
PS: (hope I have mentioned the right Ivan)
Thanks for the help Mitch! No response here though. Dear author, please let us know if this is still an issue.
Still an issue if the size of the executable gets too large, once it happens we move code from the client to the server to get this to compile again, a real pain
The problem is because there is a reference to java libraries in the shared project
I was able to reproduce it (the project is here attached):
- Create a new Xamarin Forms Project (only) with UWP
- Add for example the Microsoft.Graph NuGet package to the shared Xamarin Forms Project (in my case XamarinFormsTest)
- Right click on the UWP project => Publish => Create App Packages
- Select Sideloading => No, signing =>Select only x64 and Release (x64) => Click create
Then I got following output and error message:
Build started...
Restored C:\VS\XamarinFormsTest\XamarinFormsTest\XamarinFormsTest.UWP\XamarinFormsTest.UWP.csproj (in 366 ms).
1>------ Build started: Project: XamarinFormsTest, Configuration: Release Any CPU ------
1>XamarinFormsTest -> C:\VS\XamarinFormsTest\XamarinFormsTest\XamarinFormsTest\bin\Release\netstandard2.0\XamarinFormsTest.dll
2>------ Build started: Project: XamarinFormsTest.UWP, Configuration: Release x64 ------
2> XamarinFormsTest.UWP -> C:\VS\XamarinFormsTest\XamarinFormsTest\XamarinFormsTest.UWP\bin\x64\Release\XamarinFormsTest.UWP.exe
2> Processing application code
2> Computing application closure and generating interop code
2> Loading 131 modules...
2> Generating code...
2> Interop code generated.
2> Generating serialization code
2> Compiling interop code
2> Generating System.Reflection.DispatchProxy proxy code.
2> Cleaning up unreferenced code
2> Generating native code
2>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\Microsoft.NetNative.targets(809,5): error : Internal Compiler Error
2>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\Microsoft.NetNative.targets(809,5): error : ILT0005: 'C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x64.microsoft.net.native.compiler\2.2.12-rel-31116-00\tools\x64\ilc\Tools\nutc_driver.exe @"C:\VS\XamarinFormsTest\XamarinFormsTest\XamarinFormsTest.UWP\obj\x64\Release\ilc\intermediate\MDIL\XamarinFormsTest.UWP.rsp"' returned exit code 1
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 12:16 AM and took 28:58,544 minutes ==========
========== Package: 0 succeeded, 1 failed ===========
My minimal reproduction project:
Issue still appears in latest Visual Studio 17.7.2
And in older versions like VS 17.6.5
Strange: