New file in folder gets automatically added to TFS (TFVC) pending changes? - visual-studio

Team Foundation Server 2018 / Visual Studio Professional 2017 - Version 15.9.5
When i manually create a new file in Windows Explorer in a certain directory that is part of the TFVC source controlled tree, that file gets automatically added to TFVC pending changes (as "add"). Note that the file is not part of any project.
(The solution was opened in Visual Studio at the time the file was created).
This does not happen in other directories. I can add files to windows directories and they will NOT automatically be added to TFS and need to be manually added to TFS within VS Source Explorer. This is the expected behavior for me.
So it seems it is some configuration of a specific folder?, but i can't find it.
Didn't even know this was possible.
Can you tell me where to look?
FYI, this is a local workspace.
Edit: I have the TFS Explorer extension installed.
Edit: The new file is only added to pending changes when VS is open when creating the file in the folder. I did a test with VS closed, then create new file. Then reopen VS with solution and the file does NOT appear as a pending add.

When your workspace is configured as a Local workspace, files and folders are automatically detected and added (unless excluded by a .tfignore file).
Generally Local Workspaces are way more convenient, and are the default for workspaces with fewer than 100000 files (and with a fast system can exceed that number). It can be beneficial to configure a good tfIgnore file to control what is added automatically and what is ignored.
When there are no explicitly Included changes in your Team Explorer and you're in a local workspace, Visual Studio(2017+ from the to of my head) assumes you want to add all new changes and will auto-include them.
When your workspace is configured as a Server workspace, files and folders need to be manually added/removed, unless the changer are made through an IDE that is aware of the repository (Visual Studio will auto-add changes made in the solution explorer).
You can check the type of your workspace from the commandline:
tf workspaces /format:detailed /collection:https://dev.azure.com/jessehouwing
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise>tf workspaces /format:detailed /collection:https://dev.azure.com/jessehouwing
=======================================================================================================================
Workspace : JACKIE
Owner : Jesse Houwing
Computer : JACKIE
Comment :
Collection : https://dev.azure.com/jessehouwing
Permissions: Private
Location : Local
File Time : Current
Working folders:
Or from Visual Studio:

Related

Working with multiple copies of Visual Studio, each connected to a different solution and maintaining separate sets of included changes

I have two copies of Visual Studio 2017 open and each window is working with a separate solution. Both solutions are checked into Team Foundation Server source control in separate folders. For example, \Projects\Project1 and \Projects\Project2. There are no files common between these two projects.
When I add a new file into \Projects\Project1 using Windows Explorer, it appears as an entry in both copies of Visual Studio under "excluded changes". If I add the file through Visual Studio, it appears to get added as a file that's referenced by that solution (or project) and appears in the included changes for that project.
How do I configure Visual Studio to not add arbitrary files that exist outside of the solution folder into the detected files list?
In Visual Studio, under Excluded Changes, there is a View Options link with a Show Solution Changes option as well as a filter. However, neither of these options stops the inclusion of files that belong to other projects. It is as if the root of the detected code has been set to the parent folder of both solutions.
Since you are using a local workspace, first please go through below mechanism of detecting files:
While edits in a local workspace can be pended implicitly just by
editing the file, adds and deletes still must be explicitly pended.
However, TFS version control’s workspace scanner also detects new
files which are ‘candidates’ for addition, and missing files and
folders which are candidates for deletion. The Team Explorer’s Pending
Changes Page has a link which shows the number of detected adds and
deletes, and provides a link to the Promote Candidate Changes dialog
which can be used to pend ‘real’ adds or deletes on these items.
This is called “promoting” the candidate adds and/or deletes – because
they become real pending changes.
Source Link: Server workspaces vs. local workspaces
In your case, since you are adding files using Windows Explorer, TFS will add the files in excluded changes, you need to manually promote the files as real add in pending changes list. However, TFS could not judge the exclude list should belong to which Visual Studio. That's why it appears as an entry in both copies of Visual Studio under "excluded changes".
How do I configure Visual Studio to not add arbitrary files that exist
outside of the solution folder into the detected files list?
There is no way to do this for local workspace, unless you are using server workspace, but there are also many limitations.
Another workaround is configuring multiple projects which have multiple TFS workspaces. You could have several branches for different projects under the main or dev branch, and create a different workspace for each branch. Each branch is a 'project' in itself.
It is as if the root of the detected code has been set to the parent
folder of both solutions.
Correct. It sounds as though you have a single TFVC workspace mapped to a single root folder. If you have a single workspace mapped to a root folder, all changes in that folder will be reflected in the team explorer.
The solution: Use multiple workspaces, one for each project. If you're not familiar with the concept of workspaces in TFVC, there is extensive documentation available on the subject.

Visual Studio 2015. Files not added to TFS

I'm using Visual Studio 2015 update 3 with TFS hosted at visualstudio.com.
When I add a C# class file to one of my projects in Visual Studio, it's not automatically added to source control. For other projects in the same solution, C# class files are added automatically, as expected.
When I then add the file, manually, in the project with this problem, I get the following question;
I have to confirm to add the file to source control.
There is a similar question (Visual Studio 2015 new files not being added to source control automatically), associated with a "release" branch, which is not the case here (at least I think so - our TFS-project has never been branched)
We've never configured any .tfignore manually.
This started to happen recently and occurs on all development machines, so it's probably not a client machine issue.
I'm clueless, so any help is highly appreciated.
UPDATE
I've discovered that the problem occurs in projects with names ending with ".Lib"
Projects:
Core (ok)
Core.Lib (files not added automatically)
Communication (Ok)
Communication.Lib (files not added automatically)
I tried to add a test project Test.Lib to my solution. This project was not added to TFS either, but project Test was.
The "lib" extension is the problem. Try renaming the project folder to something else, eg. "CoreLib".
To reproduce this behavior / bug, try the following:
Create a Test directory in a directory controlled by TFS
Create a Test.Lib subdirectory in this directory.
Add a file, test.cs, to Test.Lib. (Test\Test.Lib\test.cs)
In Visual Studio's Source Control Explorer, try adding the new Test directory to source control. You'll see test.cs on the "Excluded items" tab.
The "lib" extension is used by binary files, and these are ignored by Team Explorer by default. I haven't found an official list of filetypes anywhere, but other affected file types are dll, exe, obj and possibly others. You can include these files manually by right-clicking them and selecting "Include".

Repair TFS Server Workspace

I use a server workspace for my Visual Studio / TFS setup because our project far exceeds the 100,000 file recommended limit for local workspaces.
One of the drawbacks of a server workspace is that Visual Studio cannot automatically detect changes to files in the workspace if these changes have been made outside of Visual Studio.
If I believe there may be undetected changes lurking in my workspace, how can I tell Visual Studio to actively/explicitly check the integrity of the workspace. I.E. I need a "get" operation that assumes that zero pending changes may actually be incorrect.
There is a PowerTools command tfpt online which looks for files which have had their read-only attribute removed (if you were messing with them on the train home for example) but I guess you might have new files and need something like detected changes in local workspaces.
If you go into Source Control explorer you can right click your folder, select compare and then play around with what you need to compare the server to your local copy (file types, new files, different files etc)
TFPT Online:
http://blogs.msdn.com/b/buckh/archive/2005/11/16/power-toy-tfpt-exe.aspx
If you are using TFS 2013+ and Visual Studio 2013+ then you can use the "tf reconcile" command to analyse the differences.
https://msdn.microsoft.com/en-us/library/bb385984.aspx
The power tools "tfpt online" command has been depricated for some time.

How to ignore .dll files from checkin in team explorer

I have a project on visualstudio.com and I am connecting to it from VisualStudio 2013, In the team explorer, how to ignore .dll files from checkin?
I was doing the same in svn like this How do I ignore files in Subversion?
If you're using Team Foundation Version Control, you can create .tfignore files in folders in your workspace to ignore any files that VS is not ignoring by default.
If you're using Git version control, you can create a .gitignore file. You can get a .gitignore for your project type here, or go into Settings in Visual Studio Team Explorer to add one automatically.
You can check-in/commit tfignore and gitignore files into source control so that the specified files are ignored for everyone. Any files that were already added to the repository will not be affected, however; those have to be removed manually.

Visual Studio and TortoiseHg: folder not visible in VS

I created a C# project and added it to source control (mercurial). I can edit files in VS, commit it and push it using TortoiseHg. It goes to the server. When some one pulls they get the files.
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
However, now someone pulled the latest code from the server - and they got the new file (it is visible through windows explorer), but when they open the solution in VS, they don't see the file.
Does someone have an idea what is wrong here? or things I should check? Thank you for the help.
P.S. I have visual studio 2010 express (so I can't use the VisualHg plugin).
Visual Studio caches changes to the solution and project until an explicit save or a build. In your comment:
In my visual studio I added a folder and a file inside that folder. I used TortoiseHg and it saw the new file in the new folder. I committed it and pushed it.
I see that an updated .sln or .vcproj file was not mentioned and checked in. Did you see an update to either of these files via TortoiseHg? If not, make sure to build or save your project after a change like this.
Did you make sure that the Visual Studio Project File or Solution file is being updated and committed?
VS solution contains projects and each project select managed files by metadata(***.vcproj file). It's not the way include all files from root directory.
So, your co-workers can see new added files by in following two ways.
1) share project file(***.vcproj)
2) manually add files in each person's VS instance.

Resources