locked
Can TFS make files writable when getting RRS feed

  • Question

  • Is it possible to make certain file or mark them within TFS as writable when you sync them to your file system?  We're doing a big change over to TFS and are wanting the same functionality our existing SCM tool has and this is one features you can set at the file level. 

     

    These files would those that are MIDL generated, etc.  Yes these are generated, but not all usages will be compiling that file just consuming them.  A capable SCM tool should give you the ability to manage your files as needed in your own place.

     

    Thanks in advance.

     

    Tuesday, April 29, 2008 12:23 PM

Answers

  • Hello,

    I'm pretty sure that TFS does not allow this out of the box. I don't think you can get any client side events to hook up to them and transparently to the user make files writable. I see 2 solutions:

    • wrap tf.exe and make file writable after get,checkin, undo (and a few others probably). However TFS requires you to pend edit on the file before you started working on it. That's why they are read-only. If you make file writable, you will need to pend edit anyway before checking in this file to the server - you may use "tfpt online" to do this in more automatic manner.
    • I would think that the best would be to change the build process to pend edit on any automatically generated file as part of it. The other question is - should the generated file be checked into SCM if it's regenerated every time?

    Hope this helps

    Tuesday, April 29, 2008 1:56 PM
  • The eventing works only inside one process so you would need to implement "tf get" on your own. Then it could check every downloaded file against some external file and pend edit on it.

    Thursday, May 1, 2008 10:13 PM

All replies

  • Hello,

    I'm pretty sure that TFS does not allow this out of the box. I don't think you can get any client side events to hook up to them and transparently to the user make files writable. I see 2 solutions:

    • wrap tf.exe and make file writable after get,checkin, undo (and a few others probably). However TFS requires you to pend edit on the file before you started working on it. That's why they are read-only. If you make file writable, you will need to pend edit anyway before checking in this file to the server - you may use "tfpt online" to do this in more automatic manner.
    • I would think that the best would be to change the build process to pend edit on any automatically generated file as part of it. The other question is - should the generated file be checked into SCM if it's regenerated every time?

    Hope this helps

    Tuesday, April 29, 2008 1:56 PM
  • One way is to add event listeners and store the filename being gotten and then set the file attributes to normal after the get operation is done.

             m_vcs.Getting += YourClass.OnGetting;
             m_vcs.OperationFinished += YourClass.OnOperationFinished;


          internal static void OnGetting(Object sender, GettingEventArgs e)
          {
             if (e.ItemType == ItemType.File)
             {
                m_filename = e.TargetLocalItem);
             }
          }

          internal static void OnOperationFinished(Object sender, OperationEventArgs e)
          {
             if (e.Type == OperationEventType.Get)
             {
                File.SetAttributes(m_filename, FileAttributes.Normal);
             }
          }

    Hope this helps!
    Thursday, May 1, 2008 6:22 PM
  • The eventing works only inside one process so you would need to implement "tf get" on your own. Then it could check every downloaded file against some external file and pend edit on it.

    Thursday, May 1, 2008 10:13 PM