Bug 7644 - Overwriting file causes inability to compile
Summary: Overwriting file causes inability to compile
Status: RESOLVED NORESPONSE
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Add-in ()
Version: 3.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2012-10-04 09:17 UTC by Scott
Modified: 2013-12-05 18:34 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED NORESPONSE

Description Scott 2012-10-04 09:17:01 UTC
I get the following error [see below] after having overwritten a resource file instead of checking it out first.  MonoDevelop acts like the file is still open.  This error prevents me from compiling and deploying my Android app.

I have MonoDevelop 3.0.4.7 and Mono for Android 4.2.6


/Library/Frameworks/Mono.framework/External/xbuild/Novell/Novell.MonoDroid.Common.targets: Error: Access to the path "/Users/Cegedim/Documents/Android_MIPocket/WebForce/Mobile/MIAndroid/Resources/values/Attrs.xml" or "/Users/Cegedim/Documents/Android_MIPocket/WebForce/Mobile/MIAndroid/obj/Debug/res/values/attrs.xml" is denied.  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, Boolean overwrite) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.CopyFile (System.String source, System.String dest, Boolean create_dir) [0x00000] in <filename unknown>:0 
  at Microsoft.Build.Tasks.Copy.Execute () [0x00000] in <filename unknown>:0  (MIAndroid)
Comment 1 Alan McGovern 2012-11-19 05:56:28 UTC
The file is more than likely marked as readonly. We'd have to remove that flag from the file before attempting to overwrite it for this to succeed.

For now you can simply delete the "/Users/Cegedim/Documents/Android_MIPocket/WebForce/Mobile/MIAndroid/obj/Debug/res/values/attrs.xml" file from your disk. That should be enough to fix it.
Comment 2 Scott 2012-11-19 07:46:52 UTC
Alan,

Yes, that is a workaround for now but it is inconvenient.  
Hopefully, Xamarin can provide a fix to the IDE when time permits.
Comment 3 Jonathan Pryor 2012-11-19 15:34:05 UTC
Why is obj/Debug/res/values/attrs.xml read-only? Is it tracked by your version control system?
Comment 4 Scott 2012-11-19 15:40:05 UTC
Yes.  We are using TFS via Eclipse plugin.
If I don't check it out, make changes to overwrite it and then subsequently compile, then I get the problems originally described.
Comment 5 Jonathan Pryor 2012-11-19 22:25:50 UTC
The contents of the `obj` and `bin` directories SHOULD NOT be kept in version control. They are temporary build artifacts, and will be rebuilt when needed.

Do not store `bin` and `obj` in TFS, and this won't be a problem.
Comment 6 Scott 2012-11-20 11:55:48 UTC
Jon,

Sorry, I think there was some confusion in my last response.
I didn't realize that you were referring specifically to the bin/obj directories.
We do not keep these in TFS as these are transient and regenerated every time.
The only file transient file kept in TFS is Resource.Designer.cs.
If we make longterm changes to this, we typically check it out and check it back in.
Comment 7 Jonathan Pryor 2012-11-20 14:02:55 UTC
What confuses me is the original report:

> Error: Access to the path
> "/Users/Cegedim/Documents/Android_MIPocket/WebForce/Mobile/MIAndroid/Resources/values/Attrs.xml"
> or
> "/Users/Cegedim/Documents/Android_MIPocket/WebForce/Mobile/MIAndroid/obj/Debug/res/values/attrs.xml"
> is denied.

Resources\values\attrs.xml is the source, so it shouldn't matter if it's read-only (though you should check filesystem permissions to double-check that). obj\Debug is build output, and shouldn't be in TFS, and thus shouldn't be read-only (you might want to double-check that).

So given a "sane" environment (bin & obj aren't tracked by TFS), I don't understand why you would be getting this exception. Unless perhaps you removed Resources\values\Attrs.xml without removing it from your project (i.e. does it still exist?).

The real kicker is that the workaround of deleting `obj/Debug/res/values/attrs.xml` worked, implying that `obj/Debug/res/values/attrs.xml` was read-only. Again, if bin & obj aren't tracked by TFS, HOW could that file be read-only? (Some errant/bizarre backup program?) It doesn't make sense otherwise.
Comment 8 PJ 2013-11-19 17:04:41 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 9 PJ 2013-12-05 18:34:50 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.