Bug 2258 - Resources.Designer.cs shouldn't be kept under source control
Summary: Resources.Designer.cs shouldn't be kept under source control
Alias: None
Product: Android
Classification: Xamarin
Component: Tools and Addins ()
Version: 2.0
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2011-11-29 18:10 UTC by Jonathan Pobst
Modified: 2015-03-11 14:56 UTC (History)
2 users (show)

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

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 Jonathan Pobst 2011-11-29 18:10:45 UTC
From https://bugzilla.novell.com/show_bug.cgi?id=680904.


Resources.Designer.cs is currently part of the project and (usually) part of
source control, which can be problematic with TFS users who have the file
marked as Read Only.

Possible fix: 

A file doesn't have to be statically in the project to provide
Intellisense...to satisfy yourself of this, you can create a WPF project,
reference App.Main() from somewhere, and see how Intellisense handles it. This
function is defined in obj\x86\Debug\App.g.cs, which is automatically generated
and added to the project at build time. This way, it never gets checked in, but
Intellisense still works just like any other file.

I was able to make this work with the following steps:

1) In the Android .csproj file, remove the <Compile
Include="Resource.designer.cs" /> element
2) Change the "AndroidResgenFile" property to
$(IntermediateOutputPath)\Resource.designer.cs (optional, but cleaner, since
build output shouldn't be intermixed in the same directory with source code)
3) Add an [Output] attribute to the AndroidResgen.ResgenOutputFile property (I
used ildasm\ilasm for this, for testing purposes)
4) In Program Files\MSBuild\Novell\Novell.MonoDroid.Common.targets, add the
following inside the <AndroidResgen /> element: 
    <Output TaskParameter="ResgenOutputFile" ItemName="Compile" />

Now if you build your project, you should end up with a Resource.designer.cs
that's exactly the same as what you have now, but is tucked away with the other
intermediate build files and doesn't show up in the Solution Explorer, which
therefore won't get checked into source control and cause problems. I tried
this and verified that Intellisense works exactly as it did before. I even
added a doc comment to one of my string resources and verified that it still
showed up correctly, in case you ever want to put the name of the file that
generated it there or something.

    -- Ryan Milligan

Reproducible: Always
Comment 1 Mikayla Hutchinson [MSFT] 2011-11-29 19:21:54 UTC
The .g.cs files are not comparable to .designer.cs files. Designer files are updated as the resources change, they are only generated at build time as a fallback in case something went wrong.
Comment 2 Jonathan Pobst 2012-04-25 11:30:13 UTC
I don't think we're going to move this.  If the user does not want it in source control, they can use their equivalent of .gitignore.