Bug 1625 - MonoDevelop does not handle readonly files well
Summary: MonoDevelop does not handle readonly files well
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: Trunk
Hardware: PC Mac OS
: High normal
Target Milestone: ---
Assignee: Alan McGovern
Depends on:
Reported: 2011-10-21 05:16 UTC by Alan McGovern
Modified: 2011-12-29 04:49 UTC (History)
4 users (show)

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

Test project to reproduce the problem (5.79 KB, application/zip)
2011-11-13 21:45 UTC, Dominique NORMAND

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 Alan McGovern 2011-10-21 05:16:04 UTC
My development environment consists of Monodevelop with Monotouch on Mac. For source control managemnent I use Team Foundation Everywhere. The Team Foundation Server plugin for Eclipse by Microsoft. TFE set files to read-only if they are not checked out and to read-write if they are. Seems like this behavour is not configurable in the TFE product and I beleive that this is how other source control tools work as well. I think Monodevelop is not working very well together with TFE:

1. Since the files are read-only, Monodevelop give you two dialog boxes before saving over a readonly file. I have not found any way to configure another behavior here. I would like to be able to configure this. The workaround here is to checkout the file in TFE prior to the change of the file. I can live with that since I intend to change the file.

2. The other thing is more of a bug I think. Since my images and stuff are readonly on the disk, a build-clean is failing. The description is: "Build failed. Access to the path "…/Images/xxx.png" or ../bin/IPhoneSimulator/Debug/xxx.app/xxx.png is denied". This since the *.app file contains readonly files within it. If I set the image files to read-write its possible to build-clean. I have no intension to do a checkout in this situation since I'm not going to change the files. The solution is to delete the bin folder or to check out the image files. But this is not a working solution that I can live with (I think).
Comment 1 Alan McGovern 2011-10-21 05:22:12 UTC
For the first issue, I think this might be best left as 'as designed'. Having a global "ignore the readonly flag on files when editing/saving" would defeat the purpose of the readonly flag. Maybe we could have a temporary per-session value, but I'm not 100% convinced it's the correct approach. Files which are marked readonly are supposed to be readonly.

For the second issue, this is definitely a bug. In this scenario, MonoDevelop should definitely be able to delete the files with no prompting. This is something we should be able to fix pretty easily. I'll update this bug report with more info as we discuss how to better handle your first case.
Comment 3 Mikayla Hutchinson [MSFT] 2011-10-21 07:03:41 UTC
Are we preserving the readonly flag when copying files into the app bundle? Or is the bin folder committed in the repository? The former would be a MD bug, but if it's the latter then MD's behaviour is correct.
Comment 4 Dominique NORMAND 2011-11-01 17:05:12 UTC
The readonly flag is preserved which causes a build error whenever those files need to be updated, either because of a full build or because they were checked-out and modified
Comment 5 Dominique NORMAND 2011-11-01 17:36:34 UTC
Here's a workaround for build with readonly files.
Create a before build custom command like this
Command: find . -type f -exec chmod +w {} \;
WorkingDirectory: ${AppDirectory}
Comment 6 Alan McGovern 2011-11-10 11:23:18 UTC
I cannot reproduce the issue. Are you absolutely sure that readonly files are the cause of this? To test i created a read only image and added it to my project. I then built the project. I opened the bin folder and verified that the file was still set to be readonly to all users - it was not. I used chmod again to change the file to readonly. I then clicked 'Clean All' in the MonoDevelop build options and the file was correctly removed.

Is there any more information you can give us that will help us diagnose and fix the problem? Would you be able to generate a small test project which demonstrates the issue?
Comment 7 Dominique NORMAND 2011-11-10 11:34:04 UTC
Are you compiling for MonoTouch?

The read-only files that are causing problems are not in the bin folder itself, but in the bin subfolder that contains the application package. For example if the app name is TEST, the bin folder would contain a TEST.app subfolder. that's where the read-only files are problems.

So maybe the actual issue is in the MonoTouch plugin.
Comment 8 Alan McGovern 2011-11-10 11:40:26 UTC
I hadn't changed the readonly specifiers in the file in the .app subdirectory. I just tested that out now and things worked just fine. There are two possible answers, 1) Someone else has already fixed this and I didn't notice the commit or 2) I'm not doing the right thing when trying to reproduce the issue. I'm going to assume it's the latter because I can't see any relevant commits. So to help diagnose the issue, would you be able to create a simple project which throws the exception and zip it up and attach it to the bug report?

I have also tested 'locking' the files using the Get Info dialog of MacOS. However that still didn't pose a problem.
Comment 9 Dominique NORMAND 2011-11-10 12:47:29 UTC
I think clean works fine. It's the 2nd compile after one of the read-only file is modified that fails.
I'm using MonoTouch 5.0.2 and MonoDevelop 2.8.2 and the problem is still there. 

Try these simple steps:

1. Build with file A read-only and mark as build=Content
2. Checkout file A (not read only anymore), and modify it
3. Do a simple compile and you should get the error

If you still can't reproduce it, I'll try to create a project that reproduce it
Comment 10 Alan McGovern 2011-11-11 06:41:58 UTC
Ah, i reproduced the issue and am working on a fix now. Thanks for that additional information, it's what i needed.
Comment 11 Alan McGovern 2011-11-11 06:59:02 UTC
Actually I'm going to need a testcase. We do explicitly strip the readonly attribute from all files we copy over. I can only reproduce this issue if I make one of the files in the bin folder readonly and then do a regular build (not rebuild). However as this requires explicit user action to accomplish, i must not be hitting the same issue you describe.
Comment 12 Dominique NORMAND 2011-11-13 21:45:41 UTC
Created attachment 879 [details]
Test project to reproduce the problem
Comment 13 Dominique NORMAND 2011-11-13 21:49:18 UTC
I attached a sample project.

Here are the steps to reproduce the defect:
1. Make RO.txt read-only
2. Compile
3. Make RO.txt editable, open it, make some modifications and save
4. Compile ... it should fail with the error "Access to the path RO.txt is denied"
Comment 14 Alan McGovern 2011-11-22 07:27:33 UTC
Thanks for the testcase. I had missed a spot in the iPhone addin when I made the last round of changes to handle readonly files. All known cause of readonly files causing build errors should be fixed now. If you do come across it again let me know.
Comment 15 Atin 2011-12-29 04:49:41 UTC
 I have used the attached project and followed the steps provided by Dominique NORMAND  and did not get any error.

Please close this issue.

MAC 10.7
Mono Develop 2.8.5 Stable.
Mono Touch 5.0.4 Stable
Mono Framework 2.0.7