Bug 21111 - Forms addin should not use MSBuild:Compile generator
Summary: Forms addin should not use MSBuild:Compile generator
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Xamarin.Forms Add-in ()
Version: Trunk
Hardware: PC Mac OS
: High major
Target Milestone: master
Assignee: David Karlaš
: 21619 22018 22019 ()
Depends on:
Blocks: 22082
  Show dependency tree
Reported: 2014-07-03 15:50 UTC by Mikayla Hutchinson [MSFT]
Modified: 2017-07-30 11:55 UTC (History)
19 users (show)

Is this bug a regression?: ---
Last known good build:

ScreenShot (95.81 KB, image/png)
2014-08-08 05:51 UTC, David Karlaš

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Mikayla Hutchinson [MSFT] 2014-07-03 15:50:22 UTC
The Forms addin should *not* use MSBuild:Compile generator on XAML files.

This causes the project to compile whenever a XAML file is saved, now that XS respects the MSBuild:TARGET values in the <Generator> metadata.

Please use a custom target, and tie it to UseHostCompilerIfAvailable, e.g.

<Target Name="CompileFormsXaml" Condition="$(UseHostCompilerIfAvailable)=='True'" DependsOnTarget="Compile" />
Comment 1 Jason Smith [MSFT] 2014-08-07 02:15:30 UTC
We will look into making this transition. It's low on the priority list because it simply shouldn't cause any seriously negative behavior (no crashing/failures to work).
Comment 2 David Karlaš 2014-08-08 05:51:58 UTC
Created attachment 7631 [details]

Every time that I change and save .xaml file on Windows inside XS it displays this 2 errors:
c:\Users\Kabinet\Documents\Projects\safasf\safasf\MyPage.xaml.cs(7,23,7,29): error CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

c:\Users\Kabinet\Documents\Projects\safasf\safasf\MyPage.xaml.cs(7,23,7,29): error CS0012: The type 'System.ComponentModel.INotifyPropertyChanged' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ObjectModel, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Is my system corrupted or is anyone else also seeing this?

If I remove "MSBuild:Compile" from xaml file this errors stop. I'm seeing this errors on 5.2 and master.
Comment 3 Mikayla Hutchinson [MSFT] 2014-08-11 17:36:40 UTC
*** Bug 22018 has been marked as a duplicate of this bug. ***
Comment 4 William 2014-08-29 08:17:00 UTC
I hope to increase the priority. Everytime I build with just a change to Xaml, I have to build twice. 

Already the build process is slow because of the emulator. And the current Xamarin Studio .Forms is still in its nascent stages so the Xaml parser isn't great on auto-completion so it's easier to have typos and that sort - missing curly brace, missing double-quote, etc.

Though, I *am* loving being able to share my Silverlight/Wpf skills - but this assumes that the tool is working!

Up the priority please!!
Comment 5 Lluis Sanchez 2014-10-27 07:32:21 UTC
*** Bug 22019 has been marked as a duplicate of this bug. ***
Comment 6 Mohit Kheterpal 2014-10-31 05:47:45 UTC
*** Bug 21619 has been marked as a duplicate of this bug. ***
Comment 7 Howard 2014-12-30 21:02:11 UTC
Is this the same bug as the XS compiler throwing an Xamarin.Forms.XamlParseException being thrown (No embeddedresources found for ...) every time a xaml page is updated?

If so it seems a bit ridiculous that after 7 months this has no resolution. Seems like I read somewhere, when I was spending hours trying to figure out what had went wrong in the first place, that the creators didn't see this problem as a high priority. Please reconsider.

Yippee Forms 1.3 is available and it convinced me to [try to] switch to doing pages in Xaml but if I don't run a Clean All every time I update a xaml page I get the exception and then have to clean and rebuild again. Agonizingly ineffective either way.

I saw in one post I could hack the csproj files to get the compiler to delete the files in the obj and bin directories every build but that would be even worse because then not only do I have to do a full build when updating xaml but every time.

Please fix :)

Comment 8 Rod Howarth 2015-01-05 23:30:23 UTC
To confirm with Howard - if I don't clean after making changes to XAML in Xamarin Forms 1.3 my application will crash. The workaround of saving your XAML before debugging the application no longer works. 

This is extremely frustrating.
Comment 9 Howard 2015-01-06 00:03:45 UTC
Don't know, gave up on XAML and trying to use XF 1.3 by coding in C#. That is not without frustration though. Not sure I won't end up back in Xamarin.Android or Java.
Comment 10 thomasvs 2015-01-07 06:08:50 UTC
I'm experiencing the same problems: making changes in XAML files causes the app to crash unless we do a Clean All on every change.
Comment 11 Tim 2015-01-07 14:39:39 UTC
Every time I make a change to my XAML forms and debug, I get this message - No embeddedresources found for xxx.Page.  I have to Clean All then run again which is frustrating and time consuming.   Even if I clean before I debug, it still occurs.

I am using Xamarin Studio.  Just Subscribed.

Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for xxx.Page
  at at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject,System.Type) <IL 0x0002a, 0x00103>
  at at Xamarin.Forms.Xaml.Extensions.LoadFromXaml<xxxx.Page> (xxxx.Page,System.Type) <0x0002f>
  at xxxx.Page.InitializeComponent () [0x00001] in c:\Users\xxxx\Desktop\xxxx\xxxx\obj\Debug\Page.xaml.g.cs:36
  at xxxx.Page..ctor () [0x0000a] in c:\Users\xxxx\Desktop\xxx\xxx\Page.xaml.cs:22
  at xxx.App.getPage () [0x00bc6] in c:\Users\xxx\Desktop\xxx\xxx\App.cs:255
  at xxx.App..ctor () [0x00008] in c:\Users\xxx\Desktop\xxx\xxx\App.cs:22
  at xxx.Android.MainActivity.OnCreate (Android.OS.Bundle) [0x00011] in c:\Users\xxx\Desktop\xxx\Android\MainActivity.cs:40
  at at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <IL 0x00013, 0x0008b>
  at at (wrapper dynamic-method) object.6d6f9785-7057-4321-9130-36a8cb9d3918 (intptr,intptr,intptr) <IL 0x00017, 0x0001f>
Comment 12 Matt Butler 2015-01-22 09:21:31 UTC
I too and having this issue after the switch to 1.3.  I am using a template file to bind properties to controls, in the attempt to make a template.  So, this embedded resource is in EVERY one of my Xaml files.  This issue has me dead in the water and I'm up against the 2/1/15 requirement for 64bit compliance from Apple.  

This is what I have done as part of the update to 1.3.

-  I have removed all references to previous Xamarin version from csproj files.
-  I have changed, I'm using Visual Studio BTW, each Xaml's Custom Tool Property to: MSBuild:UpdateDesignTimeXaml  from MSBuild:Compile
-  I have insured that all of my Android SDKs are updated to latest version

Example of a Xaml file header that references the template file


<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             BackgroundColor="{x:Static Template:Resources.PageBackgroundColor}"
             Icon="{x:Static Template:Resources.PageIcon}"
             Title="{Binding Title}">


is the relavant line of code...

In each Xaml file on each control there is something like...

<Label Text="{Binding Project}" IsVisible="{Binding bProject}"
                             Font="{x:Static Template:Resources.MemorizedEntrySize}"
                             TextColor="{x:Static Template:Resources.MemorizedEntryTextColor}" />


The template file


namespace Journyx.PCL.X3.Template
    public class Resources
        // Memorized Entry Screen
        public static readonly Color MemorizedEntryBackgroundColor = Color.FromRgb(1, 84, 136);
        public static readonly Color MemorizedEntryTextColor = Color.White;
        public static readonly string MemorizedEntrySize = "Small";

Doing a clean of the project does NOT work for me.  This is the exception thrown:

"  at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.XamlTypeResolver.Resolve (System.String qualifiedTypeName) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.StaticExtension.ProvideValue (IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.MarkupExtensionParser.Parse (System.String match, System.String& remaining, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.MarkupExpressionParser.ParseExpression (System.String& expression, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.ParseMarkupsVisitor.Visit (Xamarin.Forms.Xaml.MarkupNode node, INode parentNode) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.MarkupNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0 \n  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[ViewMainNavigation] (Journyx.PCL.X3.View.ViewMainNavigation view, System.Type callingType) [0x00000] in <filename unknown>:0 \n  at Journyx.PCL.X3.View.ViewMainNavigation.InitializeComponent () [0x00001] in c:\\Code\\Journyx\\Mobile\\Mobile 3.0\\UnifiedAPI\\Journyx.Mobile.X3\\Journyx.Mobile.X3\\obj\\Debug\\ViewMainNavigation.xaml.g.cs:20 \n  at Journyx.PCL.X3.View.ViewMainNavigation..ctor () [0x00008] in c:\\Code\\Journyx\\Mobile\\Mobile 3.0\\UnifiedAPI\\Journyx.Mobile.X3\\Journyx.Mobile.X3\\View\\ViewMainNavigation.xaml.cs:23 \n  at Journyx.PCL.X3.Controller.AppController.StartApp () [0x00014] in c:\\Code\\Journyx\\Mobile\\Mobile 3.0\\UnifiedAPI\\Journyx.Mobile.X3\\Journyx.Mobile.X3\\Controller\\AppController.cs:336 "

The project will work on iOS, but on Droid it fails.  I see this is a confirmed bug.  There hasn't been a status update or a work around given for this bug.  Can Xamarin please give some feedback?
Comment 13 goneale 2015-01-29 05:28:41 UTC
Come on Xamarin, we really need some feedback on this issue, it's a major pain point for a lot of customers.
Comment 14 Matt Butler 2015-01-29 10:46:59 UTC
I've emailed our Rep Laura Lundy to help light a fire about this.  :)
Comment 19 Magnus Johansson 2015-02-10 17:51:36 UTC
=== Xamarin Studio ===

Version 5.7.1 (build 17)
Installation UUID: 9428fc90-fb5b-413b-abd8-1f6daca5faf3
	Mono 3.12.0 ((detached/de2f33f)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000076

=== Apple Developer Tools ===

Xcode 6.1.1 (6611)
Build 6A2008a

=== Xamarin.iOS ===

Version: (Indie Edition)
Hash: 3b3ef43
Build date: 2015-01-24 09:42:21-0500

=== Xamarin.Android ===

Version: (Indie Edition)
Android SDK: /Users/magnusjohansson/Projects/android-sdk-macosx
	Supported Android versions:
		4.4 (API level 19)
		5.0 (API level 21)
Java SDK: /usr
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 507010017
Git revision: 0bc7d3550b6b088ac25b08dcf7bbe73bcc8658b3
Build date: 2015-02-03 19:43:29-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0

=== Operating System ===

Mac OS X 10.10.3
Darwin Magnuss-MacBook-Pro-2.local 14.3.0 Darwin Kernel Version 14.3.0
    Thu Jan 22 23:54:42 PST 2015
    root:xnu-2782.20.26~5/RELEASE_X86_64 x86_64

I am still seeing this.
Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for MyApp.Views.NowPlayingView
  at at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject,System.Type) <IL 0x0002a, 0x00103>
  at at Xamarin.Forms.Xaml.Extensions.LoadFromXaml<MyApp.Views.NowPlayingView> (MyApp.Views.NowPlayingView,System.Type) <0x0002f>
  at MyApp.Views.NowPlayingView.InitializeComponent () [0x0000c] in /Users/magnusjohansson/Projects/MyApp/MyApp/obj/Debug/NowPlayingView.xaml.g.cs:24
  at MyApp.Views.NowPlayingView..ctor () [0x00008] in /Users/magnusjohansson/Projects/MyApp/MyApp/Views/NowPlayingView.xaml.cs:14
  at MyApp.Views.HomeMasterView..ctor (MyApp.ViewModels.HomeViewModel) [0x0013d] in /Users/magnusjohansson/Projects/MyApp/MyApp/Views/HomeView.cs:182
  at MyApp.Views.HomeView..ctor () [0x00030] in /Users/magnusjohansson/Projects/MyApp/MyApp/Views/HomeView.cs:34
  at MyApp.App.GetMainPage () [0x0006d] in /Users/magnusjohansson/Projects/MyApp/MyApp/App.cs:77
  at MyApp.Android.MainActivity.OnCreate (Android.OS.Bundle) [0x0004e] in /Users/magnusjohansson/Projects/MyApp/Android/MainActivity.cs:71
  at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Android.App.Activity.cs:2380
  at at (wrapper dynamic-method) object.ae9a4989-650d-4edf-a5ab-8aedb301f5a1 (intptr,intptr,intptr) <IL 0x00017, 0x0001f>

Please re-open.
Comment 20 Howard 2015-02-10 17:58:18 UTC
I finally solved my Xamarin issues (compiler problems and runtime memory leaks).
I switched to Java. It was no more difficult than learning C#.
Actually sorry to say that. I really think what Xamarin hopes to do would make a great product. It just does not seem ready to do what we need our app to do. Unfortunately, I wasted a lot of time figuring that out.
Comment 21 Leon 2015-03-14 05:10:24 UTC
Please can we get this fixed Xamarin??  Still having to rebuild twice or do a rebuild-all whenever an edit is made. Why has this been marked RESOLVED FIXED?  Its still an issue and its agonizing.
Comment 22 Tim 2015-03-14 07:39:00 UTC

Right click on the form you made the edits and go to properties.  For the Custom Tool entry put MSBuild:UpdateDesignTimeXaml

You have to make sure this entry is in for all your forms.
Comment 23 Mike Kostersitz 2015-03-14 16:32:00 UTC
This is still an issue on OS X XS. I have taken the ButtonXAML sample and modified the XAML page in it a bit, changed the Custom Tool Entry as mentioned above by Tim. Cleaned and Rebuilt the solution but when the app launches on the simulator in iOS the error is still thrown.

Xamarin.Forms.Xaml.XamlParseException: No embeddedresources found for ButtonXaml.ButtonXamlPage
  at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[ButtonXamlPage] (ButtonXaml.ButtonXamlPage view, System.Type callingType) [0x00000] in <filename unknown>:0
  at ButtonXaml.ButtonXamlPage.InitializeComponent () [0x0000c] in /Volumes/Seagate 3TB/mike/Downloads/xamarin-forms-samples-master/ButtonXaml/ButtonXaml/ButtonXaml/obj/Debug/ButtonXamlPage.xaml.g.cs:28
  at ButtonXaml.ButtonXamlPage..ctor () [0x00008] in /Volumes/Seagate 3TB/mike/Downloads/xamarin-forms-samples-master/ButtonXaml/ButtonXaml/ButtonXaml/ButtonXamlPage.xaml.cs:16
  at ButtonXaml.App..ctor () [0x00008] in /Volumes/Seagate 3TB/mike/Downloads/xamarin-forms-samples-master/ButtonXaml/ButtonXaml/ButtonXaml/App.cs:15
  at ButtonXaml.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0001c] in /Volumes/Seagate 3TB/mike/Downloads/xamarin-forms-samples-master/ButtonXaml/ButtonXaml/ButtonXaml.iOS/AppDelegate.cs:35
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:46
  at ButtonXaml.iOS.Application.Main (System.String[] args) [0x00008] in /Volumes/Seagate 3TB/mike/Downloads/xamarin-forms-samples-master/ButtonXaml/ButtonXaml/ButtonXaml.iOS/Main.cs:17
Comment 24 matt 2015-04-01 12:34:02 UTC
Still getting this issue on OS X, its quite painful.
Comment 25 tortexy 2015-04-13 22:09:36 UTC
This bug still exists.

Every time Clean & Build is needed.

Can you treat it as a priority??
Comment 26 Lluis Sanchez 2015-04-14 04:29:35 UTC
@tortexy@gmail.com  Did you follow Tim's instructions?
Comment 27 tortexy 2015-04-14 18:34:00 UTC
I did follow Tim's instructions.
For the form that fails, the property is set. I did not bother setting all of the forms..

I did set the property...than the problem did not happen for some time, than it started again... and keeps coming back.

Sometime it does not happen for a while, but than it comes back and happens.

The ideal solution would be simply I don't have to set anything anywhere and it just works as in the prior versions did.
Comment 29 tortexy 2015-05-17 09:31:33 UTC
I have to admin, that Tim's instructions if followed to the word will prevent the crashes.

If not all the xaml files are set as suggested, that project would crash after editing a xaml file.
But if the file - that was just edited - is set as Tim suggested, it would not crash again.
If  new / different xaml file is edited and set as "MSBuild:UpdateDesignTimeXaml" it would also not crash.

The only problem with this solution is, that it needs manual editing the properties of the xml files. So this can be considered only as a workaround.

The ideal behaviour would be not crash while leaving the xml properties intact.
Comment 30 David Karlaš 2015-06-01 13:27:45 UTC
Fixed in to change .xaml files in Xamarin.Forms projects from "MSBuild:Compile" to "MSBuild:UpdateDesignTimeXaml".
Comment 31 Andres G. Aragoneses 2017-07-30 11:49:05 UTC
I have this issue now with VS for Mac (with the F# Xamarin Forms pristine templates). Does the fix for this need to be applied to the F# world as well?
Comment 32 Andres G. Aragoneses 2017-07-30 11:55:09 UTC
David Karlas wrote:
> ... to change .xaml files in Xamarin.Forms projects from "MSBuild:Compile"

Mmm, when trying to grep for "MSBuild:Compile" in my solution, I don't find any result. (Grepping for UpdateDesignTimeXaml doesn't give anything either.) Any further hints of how exactly the fix for this looked like?