Bug 8664 - Resource Designer Not Updating
Summary: Resource Designer Not Updating
Status: REOPENED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2012-11-29 12:48 UTC by Allie Miller
Modified: 2016-05-02 07:34 UTC (History)
24 users (show)

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


Attachments
Windows App Build Log (17.44 KB, text/plain)
2013-06-24 11:28 UTC, Allie Miller
Details


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 for Bug 8664 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
REOPENED

Description Allie Miller 2012-11-29 12:48:36 UTC
The Resource Designer does not update.

Attempted fixes include cleaning and re-building a project, Opening and closing the project, even deleting the resource designer.

If the resource designer is deleted, it never re-creates, causing a reversion back to the previous version of the project.

All resources have been checked and are "AndroidResources". 

The designer has previously worked, but the bug has appered randomly before. The (flakey) workaround in the past has been to:
-Use a different computer with the same project file, allow this project  to build the resources.
-Open up a new project, build it and then return to the project.

Also noticed, mis-references were included in a project and were not picked up on and attempts to build anyway.


Visual Studio information:
Microsoft Visual Studio 2010
Version 10.0.40219.1 SP1Rel
Microsoft .NET Framework
Version 4.0.30319 SP1Rel

Installed Version: Professional
Comment 1 Lluis Sanchez 2012-12-03 05:53:16 UTC
> The Resource Designer does not update

What does that mean? I don't understand the bug report.
Comment 2 Alan Pogrebinschi 2013-03-13 19:28:21 UTC
Lluis,
It means that the file Resource.designer.cs is not being rebuilt at all, even after Resource changes, and even after cleaning and rebuilding the project. I think the original report was very clear. I'm having the exact same problem (it also started as on-off and now is permanent), tried all the potential fixes listed above.

I have a very different environment, Xamarin Studio 4.0.1 (build 9) running on a Mac.

A quick google of this issue shows that there are several other recent reports similar to this:

- http://stackoverflow.com/questions/14491706/resource-designer-cs-is-not-updating-in-monodevelop-what-do-i-do

- http://forums.xamarin.com/discussion/1312/resource-designer-cs-doesnt-always-update

- http://forums.xamarin.com/discussion/486/resource-designer-cs-not-refreshing

...to list a few examples.
Comment 4 Allie Miller 2013-06-24 11:28:30 UTC
Created attachment 4184 [details]
Windows App Build Log

From Case #38834 and Forums: http://forums.xamarin.com/discussion/comment/18566/#Comment_18566
Comment 5 pascal 2013-06-26 16:22:20 UTC
Any updates on this? This is a bit of a show-stopper.
Comment 6 Dmitry 2013-07-04 14:27:52 UTC
Have the same bug. It's really bothering, can't use xamarin at all.
Comment 7 Lluis Sanchez 2013-07-09 09:00:07 UTC
Reassigning.
Comment 8 Cameron Fulford 2013-07-25 13:48:58 UTC
I'm not sure if this is the case for others, but I have been having the same issue and found the solution in my case. I'm using Xamarin Studio 4.0.10 on Mac and found at one point yesterday my Resource.designer.cs file stopped updating and when I tried deleting it or removing it from the project it didn't get regenerated. After lots of googling and trial and error I was no closer to resolving it.

Then, I noticed that for some reason, at some point the Resource.designer.cs file had mysteriously been moved in my project to the Properties directory instead of the Resources directory. I didn't realize that wasn't where it belonged until today. In fact, the correct Resource.designer.cs was being generated and updated under the Resources directory, but it just wasn't included in my project since for some reason my project was choosing an old copy of the same file in Properties. Once I removed the file from my project under Properties, I then added it to my project under Resources it worked again.

I think I have also seen something similar before where this or another file was mysteriously moved to the Assets directory. I'm not sure what could be causing that to happen in the first place, but from now on I will check the file location in my project if I ever get this error.
Comment 9 Michael Ahern 2013-08-14 06:04:07 UTC
I am hitting this issue as well and - at least for me - I can see a causal issue as well as a workaround.

=========== CAUSE =========

For whatever reason, the resource files are being incorrectly added to the the .csproj file (http://docs.xamarin.com/guides/android/advanced_topics/build_process).  When I look inside of my .csproj I see:

  <ItemGroup>
    <None Include="Resources\AboutResources.txt" />
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Resources\drawable\cog_02.png" />
    <None Include="Resources\drawable\cog_01.png" />
    <None Include="Resources\values\MvxBindingAttributes.xml" />
    <None Include="Resources\values\Page_Home.xml" />
    <None Include="Resources\values\Strings_Common.xml" />
    <None Include="Resources\values\Styles.xml" />
    <None Include="Properties\AndroidManifest.xml" />
    <None Include="Resources\layout\Home.axml" />
    <None Include="Resources\layout\ListItem_LogWorkout.axml" />
    <None Include="Resources\layout\Page_Home.axml" />
    <None Include="Resources\layout\Util_Horizontal_Line_Section.xml" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\drawable\Icon.png" />
    <AndroidResource Include="Resources\layout\Foo.axml" />
  </ItemGroup>

As you can see, stuff going int the "Resources" directory is NOT being treated as an Android resource. 

**Assumed Cause** Some piece of code is the latest Copy of Xamarin is incorrectly determining the item group for files located under the resource directory.

================== WORKAROUND ======================

To understand what is happening in the background check out this document:
http://docs.xamarin.com/guides/android/advanced_topics/build_process

-------

To fix the problem, open the .csproj and change the above example to:

  <ItemGroup>
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Properties\AndroidManifest.xml" />  
    <None Include="Resources\AboutResources.txt" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\drawable\cog_02.png" />
    <AndroidResource Include="Resources\drawable\cog_01.png" />
    <AndroidResource Include="Resources\values\MvxBindingAttributes.xml" />
    <AndroidResource Include="Resources\values\Page_Home.xml" />
    <AndroidResource Include="Resources\values\Strings_Common.xml" />
    <AndroidResource Include="Resources\values\Styles.xml" />
    <AndroidResource Include="Resources\layout\Home.axml" />
    <AndroidResource Include="Resources\layout\ListItem_LogWorkout.axml" />
    <AndroidResource Include="Resources\layout\Page_Home.axml" />
    <AndroidResource Include="Resources\layout\Util_Horizontal_Line_Section.xml" />
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\drawable\Icon.png" />
  </ItemGroup>

-------

If you have other things that need to be compiled as resources in the future, just refer back to the .csproj and check that they are correctly labeled as 'AndroidResource' in the itemgroup.
Comment 10 Aleksandr Motsjonov 2014-03-04 05:05:12 UTC
Maybe this will helps.
Steps to reproduce for me were:
I deleted Resources.designer.cs inside mono, by choosing "delete" button in popup.
It never created by itself after that, whatever I did (rm -r */{obj,bin}/, restarts).

I 'touch'ed it and it was filled after I tried to build the project.
Comment 11 sothy.chan 2014-06-09 21:10:45 UTC
Comment 9 resolved my issue.  Thanks, Michael Ahern.
Comment 13 chen yuechuan 2014-07-08 12:12:19 UTC
Same problem still occur in version 5.1(build 479) , problem fixed by restarting the IDE.
Comment 14 j.aumard 2014-07-10 08:44:43 UTC
Same problem still occur in version 5.1(build 479) , can't fixed the problem with above solutions... I create another android project and drag and drop resources again...
Comment 15 sothy.chan 2014-07-10 16:17:09 UTC
What I found was that when you add a new layout file, it's labeled as "BundleResource" by default.  You have to change it to AndroidResources and then it will work.
Comment 16 Jon Goldberger [MSFT] 2014-07-10 17:39:04 UTC
Reopening as more information has been provided.
Comment 17 Ed 2014-07-11 08:51:10 UTC
This problem has stopped me from Xamarin development for a week now. I tried all suggestions here and in http://stackoverflow.com/questions/18346430/xamarin-android-how-to-rebuild-resource-designer-cs, but no luck.

I use xamarin.android with now Xamarin Studio 5.1.2. It happend also with 5.1.0

A few days ago I was able to make Resource.designer.cs updating itself again by creating a new project, and adding the files to that. However, after a few hours of work, it stopped again. I'm stuck since then.

I'd be happy to share my little project to support to look at the problem.
Comment 18 Tyson 2014-07-21 17:50:32 UTC
This problem has halted my project as well. 

Changes made to layout.axml files are not being registered by the rest of the application.  I can't make any GUI changes to my applications.

Whenever I attempt to reference new entries in the layout file, I get the following errors in my .cs class:

"______.Resource.ID does not contain a definition for _________________"

Whenever I try to FindViewByID.

Using version 5.1.4

I just spent the whole day re-installing EVERYTHING and the problem still persists..
Comment 19 Michael Ahern 2014-07-21 18:02:58 UTC
I have not been using Xamarin recently, however - if the issue is the same as it was in the past you can resolve manually.

1. Stop Xamarin

2. Using a text editor, find your *.csproj look for something like this:

  <ItemGroup>
    <None Include="Resources\AboutResources.txt" />
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Resources\drawable\cog_02.png" />
    <None Include="Resources\drawable\cog_01.png" />
    <None Include="Resources\values\MvxBindingAttributes.xml" />
    <None Include="Resources\values\Page_Home.xml" />
    <None Include="Resources\values\Strings_Common.xml" />
    <None Include="Resources\values\Styles.xml" />
    <None Include="Properties\AndroidManifest.xml" />
    <None Include="Resources\layout\Home.axml" />
    <None Include="Resources\layout\ListItem_LogWorkout.axml" />
    <None Include="Resources\layout\Page_Home.axml" />
    <None Include="Resources\layout\Util_Horizontal_Line_Section.xml" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\drawable\Icon.png" />
    <AndroidResource Include="Resources\layout\Foo.axml" />
  </ItemGroup>

3. Manually change all of the <None>'s of interest to <AndroidResource>'s. Like so:

  <ItemGroup>
    <None Include="Assets\AboutAssets.txt" />
    <None Include="Properties\AndroidManifest.xml" />  
    <None Include="Resources\AboutResources.txt" />
  </ItemGroup>
  <ItemGroup>
    <AndroidResource Include="Resources\drawable\cog_02.png" />
    <AndroidResource Include="Resources\drawable\cog_01.png" />
    <AndroidResource Include="Resources\values\MvxBindingAttributes.xml" />
    <AndroidResource Include="Resources\values\Page_Home.xml" />
    <AndroidResource Include="Resources\values\Strings_Common.xml" />
    <AndroidResource Include="Resources\values\Styles.xml" />
    <AndroidResource Include="Resources\layout\Home.axml" />
    <AndroidResource Include="Resources\layout\ListItem_LogWorkout.axml" />
    <AndroidResource Include="Resources\layout\Page_Home.axml" />
    <AndroidResource
Include="Resources\layout\Util_Horizontal_Line_Section.xml" />
    <AndroidResource Include="Resources\values\Strings.xml" />
    <AndroidResource Include="Resources\drawable\Icon.png" />
  </ItemGroup>

4. Save the *.csproj file.

5. Restart Xamarin

6. Refresh the project to be safe.

In the past (no guarantees for the present), that would do the trick.
Comment 20 Tyson 2014-07-22 17:56:17 UTC
My solution (as recommended by Xamarin's android support team) was to just create a new project and import all the files from the old project.  It took just over an hour (its a big project) but after than it all worked fine.  

According the tech support people:

The problem stems from corruption of the .csproj file.  A previous version of XS caused the corruption and as of 5.1.x that problem has gone away.  So once you rebuild, you shouldn't ever have this problem again.
Comment 21 fabiocozzolino 2014-08-20 05:01:50 UTC
To solve the problem, you can also edit the .csproj file and add the following entries in the top PropertyGroup:

<RootNamespace>**Your_Root_Namespace**</RootNamespace>
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
<AndroidApplication>True</AndroidApplication>
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
<TargetFrameworkVersion>*your value here*</TargetFrameworkVersion>

source: http://stackoverflow.com/questions/18346430/xamarin-android-how-to-rebuild-resource-designer-cs
Comment 22 Tomasz Cielecki 2014-08-29 10:11:35 UTC
I am encountering this problem with Xamarin 4.0.8.0 (alpha channel), which is super annoying.

I suggest that you either add a checkbox or some sort of mechanism to force the rebuild of the Resource.Designer.cs file, or make some kind of tool to validate the csproj file hasn't been corrupted and notify the user or fix it.

I've checked my csproj file and it seems to be OK, what would make it not build?
Comment 23 Jonathan Pryor 2014-08-29 11:14:03 UTC
@Lluis: As per Comment #19 (and others), the Designer bug is that the Resources aren't getting the appropriate Build action. They need a Build action of @(AndroidResource), not @(None).
Comment 24 nicusorvasilescu 2015-01-13 09:40:20 UTC
I have the same problem with build 5.7 (661) . Changed xml file name in resources/menu . Closed project and the previous name is still there. Tried refresh / clean etc.
Comment 25 Tommy Ovesen 2015-01-31 11:53:50 UTC
I experience this bug now. XS 5.7 (build 661). What I did (I think) was that I renamed an existing layout (axml) and an activity.cs file. After that, resources.designer.cs never gets regenerated. Another, more serious bug: After closing XS and reopening the project, all the controls that is not added to resources.designer.cs is gone. Removed from the axml :-(
Comment 26 tavrox 2015-06-12 05:28:28 UTC
Still have this bug, tried pretty much everything. Made everything minorcase but didnt solve. Any insights after years of this bug being here ?
Comment 27 Mike Rowley 2015-09-23 16:07:57 UTC
After 12 hours of fighting images not loading in an Android XF project a stack overflow article lead me to find a missing item in my .csproj file.

If someone else runs across this bug be sure to open your csproj file and verify that the following entry exists.

    <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>

It should be in the first property group and in the first dozen or so lines.

Adding this line to my csproj file, reloading, cleaning then rebuilding the project regenerated my Resource.Designer.cs file.

For Xamarin, I would highly suggest verifying this entry exists for an android project and create an error in the compiler if it doesn't as this is a nightmare to track down.
Comment 28 Jérémie Laval 2015-09-23 16:16:41 UTC
Reassigning with respect to Mike last comment.

@Mike: while your comment is valid it should really be put in a new bug report cause it's different from this outdated entry.
Comment 29 Mike Rowley 2015-09-23 16:46:33 UTC
No problem, I have created a new bug available at:
https://bugzilla.xamarin.com/show_bug.cgi?id=34218
Comment 30 scotch83 2016-02-29 15:12:06 UTC
Hello, I have the same problem here.
Any update? I cannot work with .axml resources if this is not fixed!
I checked the build action and is AndroidResource. I tried to delete the resource file, to close and open again the IDE. Nothing seems to work.
How is it possible that we are now almost in March 2016 and this critical bug is not fixed yet?
Comment 31 Phil D. 2016-03-01 12:48:32 UTC
Hi,

I confirm that I can reproduce the same issue. I also checked the different workarounds proposed in this thread, but none helped.
In my case, the Android project I am working on is a project created almost a year ago, that I didn't modify since several months. Yesterday, I started adding new resources like images and new sets of dimensions to use in the app, and I rapidly noticed that even though the Resource.designer.cs and the .csproj files were up-to-date, the references to these resources were not spread across the project.
Comment 32 dean.ellis 2016-03-01 13:05:06 UTC
Is anyone able to provide a sample project which demonstrates the issue? I have tried to reproduce and it always works as expected for me.
Comment 34 scotch83 2016-03-04 09:42:18 UTC
I cannot provide you the project I work on, 
and I cannot reproduce it in a new project.
It might be my project settings, but I think it is at least odd to do not regenerate Designer files with a certain configuration, whichever it might be.
Comment 35 dean.ellis 2016-03-04 09:50:24 UTC
Can you post a gist of the csproj with the problem? We can probably spot the issue if its in there.
Comment 36 Mike 2016-04-30 22:28:11 UTC
I have this same issue after upgrading to the latest Xamarin Forms (2.2.0.31).

People keep saying that they have the "Resource.Designer.cs" marked as "AndroidResource".  I think it's supposed to be marked as "compile".

If I empty the contents of my Resource.Designer.cs files in the hopes that they rebuild, now one of the 2 of these files stays empty and does not get rebuilt.

I've had far too many problems with this file.  It would be my biggest wish for Xamarin to fix this.
Comment 37 Mike 2016-04-30 22:32:25 UTC
If anyone at Xamarin wants to take a look at my project, I can send it in its entirety.  If it's a misconfiguration on my part, then I would hope for an error message of some sort to help point me to a problem instead of a result of a problem.  Maybe it's just not possible though...  I can only hope for this because I've wasted countless hours on this issue.
Comment 38 Mike 2016-04-30 23:54:08 UTC
I see this warning:

Warning	255	Found conflicts between different versions of the same dependent assembly that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.

Double clicking on it brings me to this file:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets

Could this have something to do with the Resource.Designer.cs file?  I don't understand this error.