Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When editing Resources.resx file, Resources.Designer.cs fails to update because TFS doesn't check it out

I'm using TFS source control.

When I add a new resource key to my resource file - Resources.resx - and hit save, TFS checks out Resources.resx but doesn't check out Resources.Designer.cs. This causes the update to Resources.Designer.cs to fail with error:

The command you are attempting cannot be completed because the file 'Resources.Designer.cs' that must be modified cannot be changed. If the file is under source control, you may want to check it out; if the file is read-only on disk, you may want to change its attributes.

enter image description here

The error is correct in that the file IS read only and the file IS NOT checked out. I don't want to have to manually check out the designer every time I add/edit a resource key. Does anybody know of a solution or work around to this issue?

Note that I have TFS set up to "check out on save" as opposed to "check out on edit". This is deliberate to reduce the amount of unedited checkouts.

EDIT:

This happens in other file types also. For example, I am using RazorGenerator to create compiled MVC views. The same problem occurs if I try to edit the .cshtml without checking out the .generated.cs first.

UPDATE:

This issue occurs on all (as far as I've seen) files that have an autogenerated code-behind: .resx, .edmx, .aspx, .cshtml (when using RazorGenerator for compiled views), etc. I've decided that it's not worth the pain just for having "on edit: do nothing" set. I've decided to reset this to "on edit: checkout automatically". Thanks to everybody for your input. No thanks to TFS team for this FAIL.

like image 282
Paul Fleming Avatar asked Jul 11 '12 08:07

Paul Fleming


3 Answers

Well, I did not think this counts as an answer so I wrote it in comment. Checkout on save is only triggering when you save file, it does not trigger when file is autogenerated (autogenerate is not trigger for save which does checkout, as this file is edited by custom tool assigned to resx).

I'm afraid you will not get proper answer (the one which will solve your problem) besides that it is by design, but it may be worth opening a case on connect and ask to change this behavior.

like image 95
Goran Obradovic Avatar answered Sep 28 '22 03:09

Goran Obradovic


Why do you want to reduce the amout of unedited checkouts? If a file is checked in without changes, TFS notices and it will not show in the checkin history of the file.

You can test this yourself by checking out a single file and immediately checking in. TFS will tell you there where no changes and the checkout is undone.

enter image description here

So maybe consider setting it back to checkout on edit? As mentioned in the other answer, this will solve your problems...

like image 31
Raf Avatar answered Sep 28 '22 05:09

Raf


I think this is the problem

Note that I have TFS set up to "check out on save" as opposed to "check out on edit". This is deliberate to reduce the amount of unedited checkouts.

To avoid above problem, revert back to default settings. Then download TFS power tools. Then use this command to revert changes which are checked out but contain no edits

tfpt uu /noget

Update: On changing above setting the issue no longer occurs. For details, refer below discussion in comments.

like image 24
Ankush Avatar answered Sep 28 '22 05:09

Ankush