Finding files that are not checked into repo - visual-studio

Is there an easy way to find files that are not checked into my repository in my Visual Studio project?
In the past, there's been times when I get my code base from the repo only to realize that some files -- for some reason -- had not been checked into the repository.
I recently got a new laptop and downloaded the code for my app onto my new machine. I'm now getting an error when I run the app on the new laptop but on the old one it runs perfectly fine. My first thought was that there were configuration differences between two machines so I downloaded the code into a new folder on the old machine and started having the same error that I'm having on the new laptop. If I run the app from the original folder on the old machine, it runs fine.
This makes me think that I may have some differences in the code between what's on the repo and the original folder. As a result, if I get the code from the repo, I have the error. If I try to check in the code from the original folder on the old laptop, Visual Studio tells me that there's nothing to check in.
So, is there an easy way for me to see if there's any file that is not checked into the repo on my old laptop?
BTW, I'm running Visual Studio 2019 -- with the latest updates/patches -- and my repo is on Azure DevOps and uses TFVC.

Running tf vc status /format:detailed /recursive from a Visual Studio Developer Commandline in your workspace root should give you a good overview of files not checked in and files with pending changes.
C:\Users\JesseHouwing\source\Workspaces\xxx>tf vc status /format:detailed /recursive
-----------------------------------------------------------------------------------------------------------------------
Detected Changes:
-----------------------------------------------------------------------------------------------------------------------
$/xxx/test.txt
User : Jesse Houwing
Date : zaterdag 27 juli 2019 21:20:00
Lock : none
Change : add
Workspace : SHARKIE
Local item : [SHARKIE] C:\Users\JesseHouwing\Source\Workspaces\xxx\test.txt
0 change(s), 1 detected change(s)
It should auto-detect files unless you specify the /nodetectchanges flag.
Or, if your .tfignore file is well specified, you can run tf vc add * /recursive to automatically create a pending change for all files that are currently not under version control. If needed, edit your tfignore file before running the add command. Add /noignore to bypass the ignore file, but that may add bin and obj and packages folders as well, be careful.
tf.exe is hidden deep in the bowels of Visual Studio, easiest way to get access to it is to use the Developer Command Prompt:
My installation has put it here:
C:\Users\JesseHouwing\source\Workspaces\xxx>where tf
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe

Related

Visual Studio - Source Control Explorer for TFS - how to view which changeset is your local copy

I use Visual Studio 16.4.2 (2019) and TFS.
How to check "where" is my local copy of code (whick changeset I have locally)?
TFS workspace does not contain a property to track differences between local and server changeset versions. As workaround:
You can compare you local and server root folders:
Just periodically update your workspace
If you want to check the changeset number in your workspace, you can use the following history command from the root (top) of your workspace:
tf history . /r /noprompt /stopafter:1 /version:W
Check the follow blog for more information of this command:
https://blogs.msdn.microsoft.com/buckh/2009/01/26/how-to-determine-the-latest-changeset-in-your-workspace/

TFS Build Error Path already mapped to another workspace Occuring even after deleting cache file

Firstly I read through many existing threads and followed the instructions there
Here
Here
Here
Here
Here
Here
Almost all the above threads asked me to delete the cache file. I went into the machine and deleted the cache file. I even edited the cache file (XML file named version config) but still it gets overwritten
But still even after that I am seeing the same issue.
The build agent has got dynamic $SourceDir as value
What else can I do to fix this? Please Help.
I tried doing tf workspaces but it simply keeps saying that "Unable to determine the source control server"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets (838): Unable to create the workspace 'NVM1756PDV_105_7' due to a mapping conflict. You may need to manually delete an old workspace. You can get a list of workspaces on a computer with the command 'tf workspaces /computer:%COMPUTERNAME%'.
Details: The path C:\Builds\7\Common_Security\cloud\src is already mapped in workspace NVM1756PDV_104_7.
Run the tf workspace /delete NVM1756PDV_104_7 command to correct this error.
Try using TFS Sidekicks to delete the workspace using the Workspace Sidekick.

In TFS, is it possible to create local workspace from a script?

MS' pages talk about using the command-line tf.exe to create a local workspace prior to calling tf get but describe that even from the command-line, a TFS dialog box will be shown.
One of our build scripts, as we move from VSS to TFS, gets a repo into a working copy prior to building. It would be preferable if this script can be run on a 'clean' PC and it automatically creates the local workspaces, or can somehow get a copy without using a workspace (we really need something closer to svn export as no changes are being made). But a dialog box requires we manually set up each machine with local workspaces first.
Is what I want possible?
If you look at the full help tf help workspace, you see:
tf workspace /new [/noprompt] [/template:workspacename[;workspaceowner]]
[/computer:computername] [/comment:("comment"|#commentfile)]
[workspacename[;workspaceowner]]
[/collection:TeamProjectCollectionUrl]
[/permission:(Private|PublicLimited|Public)]
[/login:username,[password]]
As you can see, you can specify /noprompt and all of the parameters that the prompt would collect.
For setting the working folder, you'd use tf workfold:
tf workfold /map serverfolder localfolder
[/collection:TeamProjectCollectionUrl]
[/workspace:workspacename]
[/login:username,[password]]

How to connect to source control server using TF command line utility

I'm trying to run a commands using Tf Command-Line Utility I'm getting errors when trying to connect to TFS server. I'm not sure what tf tool is expecting as far as parameters.
It tells me to connect to workspaces by running tf /collection:TeamProjectCollectionUrl'
To get the TeamProjectCollectionUrl I went into Visual Studio Team Explorer, looked at properties of a project and copied URL property. The url starts with vstfs://
You want to use the standard HTTP or HTTPS URL to specify your project collection. (This is the same URL that's shown in the connection dialog in Visual Studio.) For example:
http://tfs.contoso.com:8080/tfs/DefaultCollection
TFS installs on port 8080 by default, and (beginning in TFS 2010), the name of your project collection is the suffix.
Alternately, you shouldn't need to specify the project collection - if you run the tf resolve command from one of your working folders, it will determine the server information automatically. That is, if you have the workspace mapping:
$/Project/Source -> C:\Work\Source
If your current working directory is C:\Work\Source and run the tf command line client, it should locate your TFS workspace automatically.
1- Add "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" path into Environment variable path.
2 - Create a batch file (simply copy and modify the below commands and save into file with ext .bat)
CLS
tf get $/Project/Source /recursive /force
Pause
exit
3- Copy .bat file and place into your local Mapped folder and run.

Delete TFS branch without downloading it

I am trying to delete a branch that has not been downloaded into my workspace via following command.
tf delete /lock:checkout /recursive $/TfsServerName/TfsFolder/Branch
I get following error message:
No matching items found in $/TfsServerName/TfsFolder/Branch in your workspace.
Is there a way to delete a TFS branch without actually downloading it?
you can do a non-recurisve get of only the folder with the "tf get" command. I am not aware that you can delete it when you don't have a local copy of the folder.
Make sure the folder above the branch is mapped to the filesystem, then:
Open up Visual Studio's "Developer Command Prompt"
cd (change directory) into the folder above the branch
and run the following:
tf get .
tf delete /recursive branch-folder
tf checkin
This will do a non-recursive get, mark the whole branch/folder for deletion, then prompt you to enter a message and check in the change.
Should work with VS2012-2015 & TFS 2010 to current. Also tested with Visual Studio Team Services hosted TFS (as of 25th Feb 2016)
With VS2012 / TFS server 2010, the delete command needs /recursive
In the Source Control Explorer you can get the latest version of a branch then cancel it as soon as it starts downloading. That will un-ghost the branch allowing you to delete it through the interface. You'll also have to delete the few files that were downloaded to your local work space. It's a total hack but it's really quick and easy.
In the Source Control Explorer, if you simply map the branch to a local path and hit OK, it will enable the "delete dropdown".

Resources