TFS messing with my workflow coding style. - c#

I recently converted from Vault to TFS for C# coding (language probably doesn't matter) in VS2010. My workflow used to be as follows:
If I don't want to check a file out or the file is already checked out by someone else, I simply remove the read-only attribute and start editing. At that point, Vault would stay out of my way. Later on, I would just merge my changes.
With TFS, by default, it wouldn't let me edit the file at all (because it checked out by someone else), even though I removed its read-only attribute. So I went into Tools/Options/Source Control/Environment and checked the Allow checked-in items to be edited.
This setting does allow me to edit the file, however, every time I press Ctrl-S to save it, it complains that the file is locked for check-out.
How can I get TFS to edit my files in peace?

You should have no issues unless the other person who is working on the file is locking it when they check it out.
My settings are as follows and work well for your situation:
Options -> Source Control -> Environment
Team Foundation
[] Get everything when a solution or project is opened
[] Check in everything when closing a solution or project
[] Display silent checkout command in menus
[] Keep items checked out when checking in
Checked-in items
Saving: Check out automatically
Editing: Check out automatically
[] Allow checked-in items to be edited
In the "Team Explorer" window right-click on your {Team Project} -> Team Project Settings -> Source Control
Make sure that "Check-out Settings" has [x] Enable multiple check-out
Also when checking out files make sure "unchanged" is selected such as in this screen shot:
from
http://social.msdn.microsoft.com/Forums/pl-PL/tfsversioncontrol/thread/4353d676-1794-4db0-9d9d-f2a231315980

There is nothing wrong with multiple people checking out the same file at the same time. That is a large part of why source control was created in the first place, so that this could be done. By checking out the file, and not just editing it locally outside of TFS's knowledge, you are also telling others that you are working on the file (useful information to have).
As stated earlier, unless the file(s) are checked out and locked nobody will be prevented from accessing or modifying the file.

There is a setting available for each project that will explicitly disable multiple check-outs if it is not selected.
If you have appropriate permission, in the Team Explorer... right-click on your project and choose "Team Project Settings -> Source Control...". On the "Check-out Settings" tab, there is a checkbox for "Enable multiple check-out". Verify that the option is checked.

If you're used to git (or are willing to give it a try) then I highly recommend git tfs. It gets rid of the whole annoying paradigm of having to clear readonly flags on files, as every file is effectively cloned from the TFS source tree into a git repository. Then when you push your changes back into TFS it marshals the changes back into a format TFS approves of.
For example
git tfs quick-clone http:tfs-server/tfs/yourCollection $/YourCode/YourBranch YourDirectory
checks out all your files from TFS into YourDirectory, you can then modify these files as you would any other files on your computer, then to send them back to tfs you can issue the commands
git commit -a
To check the files into git, then
git tfs ct
To push the files into the TFS repository. More details can be found here: https://github.com/git-tfs/git-tfs

Related

Supress Merge/Conflict for a few files in a project on Get Latest Version, or, have in Project but not in TFS

I would like to Supress the Merge/Conflict checking for a few source files in a project on Get Latest Version. This is because these source files are autogenerated by a pre-build step. I just want them to be either left with 'local copy' or overwritten by the server version, because they're replace before building anyway and it doesn't matter.
When somebody on my team does a Get Latest Version, of course, these they get merge conflict errors, which isn't a big deal, but since the team changes from time to time, I get emails for a few weeks from new team members saying 'Am I going to lose my changes if I overwrite', until they finally remember to look at the filename.
Which of course caused a dev to get lazy once and ignore a merge warning, on a real source file ... and lose his changes!
Is there any way to tell TFS not to worry about this ... or, better yet, since the pre-build step always creates new versions of these files, just have them in the project (they're needed for building) but not in TFS?
You can always remove the binding of that file, so that it's not added to SourceControl.
Select the file in your solution.
In Visual Studio, File -> Source Control -> Exclude file from source control
The file will be part of your project but wont be under sourcecontrol. Basically it adds an entry to the ".vspscc" file to ignore the particular file.
Example from Vs2008 solution file.
Edit by O.P.
Note, as stated, this is not on the right-click of the file in project explorer!
Visual Studio 2012 has it hidden a bit better then vs 2008:

Add registry file (*.reg) to setup project

I see how to update the registry manually, by right-clicking on the project, select View, then Registry, but I have alot of registry changes that I need to incorporate into my setup project, and I've already exported each of them to a *.reg file. I don't want to have to go through and add each of them for the setup project manually again.
How can I add my *.reg registry files into the setup project?
As noted in the comment, right-click the "Registry on Target Machine" root node and click Import. It will ask for a .reg file. And will populate the tree with what it found in the .reg file. Just repeat this if you have more than one .reg file.
The Setup project designer doesn't exactly have the most discoverable user interface. It uses right-click context menus a lot and commands are scattered between context menus, regular menus and buttons. So if you are looking for a feature that you think ought to be there then some wishful left and right-clicking on UI widgets can help you get lucky. Spending ten Friday afternoon minutes clicking away is advisable. Note that it was removed from VS2012 and won't come back, it is still available in the gallery.
Just right click the project and add the file to your setup project. Have your application go through the .reg file on first run to make sure the registry is properly set up.
You may add or update your .reg files programatically. Let's say, for example, that you may want to merge a given file.reg to your registry:
Process _re = Process.Start("regedit.exe", "/s file.reg");
_re.WaitForExit();
(Just keep in mind that newer Windows versions use Unicode instead of ANSI when creating/consuming .reg files.)

TFS in visual studio 2012 Forcing a check-in

This question is NOT answered at the link above...
I had some problems with TFS where visual studio builds on the local machine no problem, but when I try to build on the server I get build errors. The errors are not relevant to this question.
The issue I have is that in order to fix the errors I had to manually edit some of the files on my local machine, and since they were manually edited, TFS doesn't detect the change so it wont let me upload my change set to the server which would have fixed the problems there.
My first, and main question is:
How can I force TFS to copy all my local files to the server. Sort of like the reverse of the whole:
Goto View / Other Windows / Source Control Explorer / Right click on the relevant project / Advanced / Get specific version / Check "Overwrite all files..." / Press ok.
Which (arguably, cause it doesn't always get everything in my experience) gets a full file set from the server to the local machine.
I am so tired of TFS uploading partial file sets and then when the solution is removed locally, and then re downloaded from the server, I have to pull in the missing files and references from some backup. If it was uploaded fully, and correctly at the start, I would probably have less of these problems. So this is my main question. How do I force TFS to upload all my files regardless if they have changed or not according to it.
To explain further a problem I am having in particular with nuget package manager. I disabled the option "Allow NuGet to download missing packages during build". So locally I got actual build errors. Yes that's right, Build errors. like this...
Project XXX: Package restore is disabled by default. To give consent,
open the Visual Studio Options dialog, click on Package Manager node
and check 'Allow NuGet to download missing packages during build.' You
can also give consent by setting the environment variable
'EnableNuGetPackageRestore' to 'true'.
Which now forces me to re-enable this option to get rid of the errors. I am annoyed at this because such errors should be presented as warnings so as not to prevent a build. This is seriously disappointing and as a result I have a very poor opinion of NuGet.
Anyways enough ranting, I re-enabled this, not like I had a choice. But the version where this was disabled went up to the server. Now I get this error on the server. I tried re-enabling it and doing a check in, but TFS wont let me. (Warning...No pending changes). Of course not, its just a silly check box. What could possibly have changed. But now I get an error on the server that I cannot fix all because someone at NuGet didn't put some taught into properly designing their warnings (as opposed to preventing a build by causing errors).
So, once again, how can I force TFS to take all my files, changed or unchanged, verbatim, to the server. This way, when I fix a problem locally, it "should" fix it also on the server. Or at least, when I next download it, I am assured to have the whole file set.
Apologies if this sounds like I am being negative, but I am at this for 5 solid days and it has completely stopped development costing me and the company a lot of money. Any help would be very much appreciated.
There is no way to tell TFS to take everything in my file system. What you need to do is a multistep process. First Check Out the entire directory, this will not overwrite your manual changes but will allow you to check back in and have it detect those changes. Second, if any new files were created you need to add at the root directory and get all new adds. Lastly check in all of your changes. It really should be that simple.
If you are using TFS 2012, then Local Workspaces would be a good solution for you.
Just to be clear - Local Workspaces does not mean that your developers are working locally. All code is still under Source Control in exactly the same way with Server Workspaces.
Local Workspaces are new to TFS 2012 and would resolve your issue. The main advantage for you is that files are no longer marked read-only. This allows you to be able to edit them from anywhere (notepad, any other IDE, Visual Studio) without first doing a checkout. Visual Studio will then automatically detect that the file has changed and list it in the Pending Changes window.
Good article comparing the different types of workspaces: http://blogs.msdn.com/b/willy-peter_schaub/archive/2011/11/30/team-foundation-server-trying-to-understand-server-versus-local-workspaces.aspx
I like to use the Source Control Explorer window, then right click on a folder and choose Compare. You can choose to see what is different in the target folder, or what is a new file. The files that are different appear in red. You can then right click on them and check out and check in files, or use control-click to select more than one file at time.
Yes i know before the flames start to arise, this is not conventional....but working in unity I encounter this problem quite often. Literally dealing with it now as i updated to unity 5.5 and it fubared a lot of stuff in my current project. After the resolutions from unity, my project is completely out of sync... and for whatever reason vis stu refuses to monitor these changes... It is rather annoying to be sure, but not to worry as I have resolved it successfully every time over the iterations by doing the following:
create a backup folder in a separate location and copy the entire thing over.
It doesn't matter where you back up to as long as its in a unique separate folder. Be sure to copy FOLDERS not individual FILES as some files may be hidden.
do a full get of the latest version (according to TFS).
This can take some time and is why you back it up in a separate location. Be sure to KEEP VS OPEN AT THIS POINT!!!
overwrite ALL the files you "got" with the backup that you made in step 1.
The local work-space will monitor the changes to the files as you overwrite them with the backed up copy into your local space, and mark them as having pending changes accordingly if the new one has any difference.
update your pending changes to the TFS server in source control explorer. Any change detected during the overwrite will be added to the included changes section.
Voila you have forced your files, work, and will onto the TFS server!

TFS Check-in Unavailable

I have a C# project that is booked into TFS. However, for some reason one of the forms within the project has not booked in. I can’t work out how to force this to book in, as right-clicking on the source file doesn’t give me the option to check-in.
All the other files in the project are booked in, and I can see them using the Source Control Explorer, however, this file isn’t in there. Can anyone tell me how this could have happened, and how to force this file to check-in?
Right click in the source control explorer directory where the files live and select the Add Items to Folder Option.
This typically happens if you create the files outside of visual studio. That being said, TFS is flaky at best.

how do I view all of my pending changes in VSTS Source Control Explorer?

I'm relatively new to TFS and perhaps because I'm a novice,
I'm not too thrilled with its behaviour.
Scenario:
I copy a source tree from the TFS server to my local hard drive.
I open a solution from my local hard drive by browsing to the .sln file.
From the vs Solution Explorer I double-click a .cs file.
Even though I'm just looking at it, that file is often marked as checked out to me. This happens for example if I accidentally insert a blank line, even if I undo the accidental insert and even though the vs tabs imply that the .cs file is locked.
Even though I've changed nothing, Source Control Explorer acts as if there are pending changes.
I am able to right-click the file and "Undo Pending Changes...".
QUESTION: how can I get a list or report from TFS that shows ALL of the files tagged with my Windows user id?
You just right click the folder in Source Control Explorer or the solution tree...whichever you want to see under, and view pending changes.
Alternatively, if you're against a single TFS server, go to View -> Other Windows -> Pending Changes
Also, Attrice TFS Sidekicks has some handy tools for this you might want to check out.
Menu: View -> Other Windows -> Pending Changes
If you open more than one VS instance, the window content might be out-dated, so hit "Refresh" button on top of Pending Changes tool window to be sure.
You may also want VS to prompt you upon check-out, to make your life easier.
Go to Tools -> Options -> Source Control -> Environment -> Checked-in items
and change the values to "Prompt for Checkout"

Categories