How do I permanently exclude the bin and obj folders from TFS 2012 checkin? - visual-studio-2012

I mucked around with TFS settings and I accidentally included the bin and obj folders for TFS 2012 checkin, and even checked them in already. I don't want this because these files change often and aren't meant for inclusion.
I've checked What happened to "Exclude from Source Control" in VS2012. The accepted answer doesn't work because the bin & obj folders and the DLLs inside those folders don't appear in the "Promote Candidate Changes" list, even after excluding them. The second most popular answer also doesn't work permanently. I press yes to all and it removes them from the included changes list, but when I do any action involving rebuilding, they're added to include list again.
I'm looking for a permanent solution which will permanently exclude these folders and the files inside from checkin, and if possible also removes them from the TFS server.

TFS 2012 has the option to drop a .tfIgnore file in your workspace.
Visual studio has a UI to create the file for you:
While you can manually create a .tfignore text file using the above rules, you can also automatically generate one when the Pending Changes page has detected a change.
To automatically generate a .tfignore file
In the Pending Changes page, in the Excluded Changes section, choose the Detected changes link.
The Promote Candidate Changes dialogue box appears.
Select a file, open its context menu, and choose Ignore this local item, Ignore by extension, or Ignore by file name.
Choose OK or Cancel to close the Promote Candidate Changes dialog box.
A .tfignore file appears in the Included Changes section of the Pending Changes page. You can open this file and modify it to meet your needs.
The .tfignore file is automatically added as an included pending change so that the rules you have created will apply to each team member who gets the file.
Or create it from the command line using echo . > .tfIgnore and then open it using notepad.
Another trick is to name the file .tfIgnore. in explorer and save it. You'll probably be prompted if you want to change the extension, the answer, in this case, is: yes.

For Excluding Bin folders ,Tick "Show Solution Changes" Under View options in "Included Changes"

I called in the help of our TFS admin.
We couldn't make a .tfignore file, but what did work was the following:
Check in both folders in TFS;
Delete the dlls and pdbs which are unique to the project from the source control explorer and check in this change.
Rebuild the project locally, try to check in and confirm that there are no pending changes.
the dependent assemblies remain in TFS, but since these rarely change, this isn't a big issue.

Related

Visual Studio 2012- How do you delete a new file?

I have Visual Studio 2012 with TFS. I created a new file (call it "x.h") and before I checked it in I decided I didn't need it.
MSDN makes it sound so simple:
In either Solution Explorer or Source Control Explorer, browse to the folder or file that you want to delete.
Select the items that you want to delete, open their shortcut menu, and choose Delete.
When you are ready, check in your changes.
So I went to Source Control Explorer, right-clicked the file, and chose Delete. It was removed from source control and my pending changes but is still on disk and in the Solution Explorer. When I right-click the file in Solution Explorer, Delete is not an option and Exclude From Project is disabled.
I might have more luck if I check it in first then delete it but that seems very unnecessary. Hopefully I'm just missing something obvious!
How do I delete this new file ("x.h") from my solution?
Yep. It was something obvious.
You can't delete files from the Solution while it is building.
I just tried again and the Delete option magically reappeared. I realized that it has stopped a build since I last tried.
In short, there are three different angles that a user can try to delete a file while a build is occurring and the behavior is different for each.
Undo the file add from Pending Changes -> Nice error messages are given.
Delete the file from Source Control Explorer -> It lets you remove the file as I described in the question but leaves it on disk and in Solution Explorer (same behavior regardless of whether or not a build happening).
Delete the file from Solution Explorer -> It quietly prevents you from shooting yourself in the foot and doesn't explain why.
The right way to do this is to cancel the build (or let it complete), then delete from Source Control AND from Solution Explorer.

What happened to "Exclude from Source Control" in VS2012

I want to exclude some of the files in code folders from TFS 2012 source control.
Before VS2012 this was done by the "Exclude from source control" command available in "Source Control Explorer"s right-click menu. But in VS2012 I can not find it.
Does anybody know where it is ?
(I am using a "Local" workspace by the way.)
When you click on "Detected Changes" in the Team Explorer pane, "Promote Candidate Changes" window opens. This window allows you to select among detected changes and promote them to a source controlled item.
In this "Promote Candidate Changes" window, you select a file (or multi select files with Shift), right-click on it and a context menu pops up which contains an "ignore this local item" option. If you you click on it, selected files are excluded from source control.
Visual Studio adds a file named ".tfignore" to the source control mapping root, which contains names of all files to be ignored by source control. (Previous TFS versions did not produce this file but they were all server workspaces. Since this is a "Local" workspace, filenames to be ignores need to be kept in the workspace)
I have the real solution.
In the "team explorer" pane, in the "pending changes" tab, right click a new file you don't want in source control, and click "undo".
It will leave the file in the project, and exclude it from TFS. In the project window, the file will never have a "lock" icon on the left of its name.
This is the easiest solution:
1. Select the file(s) in Solution Explorer
2. Go to File -> Source Control -> Advanced
and here it is
Keep in mind:
If you right click a file in Solution Explorer you only find "the most important options" not all :)
In VS2013 this is back but has been moved to the file menu: -
Select the file in the Solution Explorer
File > Source Control > Advanced > Exclude xxx.xxx from Source Control
I know that this is slightly off topic but thought it may help someone.
I have Visual Studio 2017 Enterprise, and the option to exclude does not exist under File->Source Control. My solution to this problem was to open the Source Control Explorer, and remove the item I wanted to exclude.
It's in the Pending Changes pane separated to Excluded Changes and Included Changes sections. It allows filtering and excluding or promoting items between sections.
!

Add an already existing directory to a directory in Solution Explorer

I want to add an already existing directory to a directory in Solution Explorer, but whenever I right-click on the directory and select Add => Existing Item, I can only add individual files, but not directories.
How do I add an already existing directory to a directory inside a Project inside Solution Explorer?
Click the 'Show all files' button at the top of the Solution Explorer and right click the folder desired and select 'include in project'.
Drag and drop the folder from Windows Explorer onto your Visual Studio solution window :)
Source here
or simply copy & paste into solution explorer.
VS 2012 seems to distinguish between 'Solution Folders', which are only folders containing either other solution folders, or containing project folders. The drag-and-drop works (with my settings) only for the project folders, and no for the solution folders.
If I add a new solution folder, nothing happens on the machine. If I drag-and-drop a machine folder to the main Solution, it refuses to accept it. If I drag-and-drop the folder to a Solution Folder, I get an error message saying this cannot be done.
Some other answers are missing an important point: if the folder is not in a project in the solution it is impossible to add the folder
This is the solution:
1) Add a new folder to the sln - it does not care that the folder already exists on the disk because this a virtual folder in the sln
2) Add the file to the folder using "add existing files"
When dealing with a solution level folder that has been removed for some reason, and now needs to be added back, open the .sln file in a text editor like notepad++.
Find your "FolderName" in the section that looks like this...
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NewFolder1", "NewFolder1", "{73ED84FC-F250-4CCC-B267-34CEB67F2883}"
EndProject
Delete from "Project" to "EndProject" ONLY for the specific Project/Folder you're having trouble with.
You may get a message in VS2012 that says your solution has been modified by an external source. Choose the option to "Discard" your changes for the external changes. Lastly, add your solution level folder, and add your project(s) to that folder as existing items, drag/drop them, or copy and paste them, according to your preference.
For those who had a hunch it could be done but weren't able to do it, NOTE: Drag Folder or Files ONTO the name of the Project Name in Solution Explorer in the least
Expand the "Project" item in the menu bar and select "Show All Files". Then locate the folder you wish to add in the Solution Explorer (folders that are not currently included will be light grey with a dotted outline instead of the usual solid icon) right click the desired folder and select "Include in project"
Once finished select "Show All Files" from the Project menu again to return to the regular view.
(This is very similar to Radenko Zec's answer, but does not require the "Show All Files" button to already be present in a toolbar. I would just leave this as a response to his answer, but I don't currently have the reputation to leave comments.)

How to open the actual file from changeset details in Visual Studio 2012, and not some hashed read-only server copy?

This is the first time I've tried this in a VS, much less VS 2012, so if the answer is common knowledge, I guess I'm just not that common. (Yeap, Google failed me as well --- or my Google-fu just needs some oiling.)
I'm looking through my TFS code repo history, and from the list of changesets, I opt to view changeset details. Up on the VS 2012 right sidebar, I get a list of all changed files for this particular changeset.
However, I want to open up one of these files and modify them directly (basically for purposes of light code review and housekeeping), so I right-click on one, and select Open.
Unfortunately, this doesn't open up my local copy of the file, but instead (seemingly) downloads the file from the server and gives me the server copy, with a modified filename (suffixed with a short hash). I can't modify this at all.
Is there a way to open my local file copy from the changeset details?
What you could do is right click the file.
Then choose open in source control explorer.
Double click the file there.
Bob should be your uncle now.
If you right click and compare it to your workspace version, that will open a diff between the workspace version and the changeset version. I don't believe there is a way to open the local version of the changeset file directly, as that version doesn't really exist in your local workspace. What you are opening when you open it from the changeset is the specific version associated with that changeset. The file may not even exist in the current solution, so opening the workspace version in same cases wouldn't even be feasible (or you may have never gotten the file).
To the best of my knowledge there is no good way to do this (I wish there was). It's a bit time consuming, but you can get the same effect with a bit of manual effort:
Open the changeset, rollback changes, go to pending changes, and open all of the files. After the last file has opened, go back to pending changes and undo changes (i.e. your rollback). All of the files from that changeset should now be current and open in visual studio.

What sort of resharper specific files does resharper generate in your vs.net project?

What sort of resharper specific files does resharper generate in your vs.net project?
(BTW, did you guys get the full version or just the C# version?)
The "_Resharper.[Solution Name]" folder stores the Resharper specific cache. You can go to Resahrper > Options dialog and select "Store caches in: system TEMP folder" so that your solution folder is not cluttered.
I personally prefer to use the TEMP folder so that the cache does not accidentally get added to the version control. Also, in case you want to clean the cache you can use the "Clear Caches" button on the Resharper Options dialog.
Couple of different things:
A folder called "_ReSharper.[Solution Name]" which then contains a collection of files and folder beneath that
A file called "[Solution Name].[ReSharper Version].resharper.user"
Both are created in the root of solution next to the .sln file. You can delete them if necessary and ReSharper will just recreate them on next load. Keep them out of your source control management system - they serve no purpose under verison control.

Resources