Need to reattach solution that has been reorganised - tfs

I have reorganised a solution that was created by someone else. The .sln file was in the directory of a website project (the old one without a .csproj file). I unbound the entire solution from TFS and then saved the .sln to a directory one level above.
What is the best way of getting this back into TFS so that other developers can pick up the changes in the .sln and folder locations?

Right click .sln file in Source Control Explorer and select Move, move the .sln to a directory one level above and check in the changes.

Related

Best practice regarding whether to check bin and obj into TFS

I always understood that best practice was never to check into TFS binary (e.g., bin and obj) files.
A while ago, someone in our implementation of TFS did not adhere to this, and checked in the bin and obj folders.
Thereafter, when I try to GLV code to a new machine, TFS downloaded all the project folders including items such as bin, obj, Debug etc and temp files like .dll, .cache, pdb. Then, when I run Clean Solution, TFS removes such files inside these folders, but then, when I Build, I get errors that there are dll files missing in obj\Debug folder.
To fix this, I then took the following steps:
I undid current changes so that TFS had nothing checked out.
I deleted the bin and obj folders from Source Control Explorer within TFS.
I checked it.
Such folders seemed to disappear from TFS, and I thought the problem was solved.
However, after that, when I GLV on the same machine, then Clean, then Build, then check-in recursively from the root of the TFS workspace, TFS automatically adds the dll’s and other extension like .cache files in those folders back into TFS! And we are back to square one.
So, should I try to prevent such files being checked in, or is there a way for all those files to be stored inside TFS without then causing me compilation errors??
Also, if best practice is to avoid checking in the bin and obj folders, how to I check in recursively from my local drive, after building, without checking in the bin and obj folders? Is there a way to exclude certain folder or file types?
Add a .tfignore file to the repo root so that those folders are not tracked by source control.
bin
obj
should be enough.

relocated MVC solution folder in ASP.NET

When I create a MVC project in Visual Studio, it will automatically generate a solution folder with the same name alone with .sln file, packages folder.
For example:
/MyProject/MyProject
and when I run the application in server:
http://XXXXX/MyProject/MyProject
I hate the address. I want to the address looks like:
http://XXXXX/MyProject
I tried to move the solution folder to upper level directory, however, the MVC project can still run but show errors and many warnings.
Is there any way I can create a MVC and I can specify the solution folder? or I can relocate the MVC solution folder nicely?
Thanks
You can relocate sln file.
Just close solution, move sln file to project folder, and then open sln file in VS.
Project will not load. Delete unloaded project in Solution Explorer, then right click on solution (in Solution Explorer) Add => existing project...
and select .csproj file of the project.
Rebuild application, nuget will restore packeges.
But I don't know why You hate path.
You can name solution folder with diffrent name then Your project. when You add more projects every project folder will be in one solution folder and path will looks like:
http://XXXXX/Solution/Project1
http://XXXXX/Solution/Project2
And one last thing: You probobly don't want whole solution in application server, you can just deploy project as web deploy packege.

Get one or more files from Source Control Explorer into TEMP folder

I am working on VFP projects, but our source control is TFS. I would like to be able to get files from TFVC and redirect them from the workspace into the TEMP folder so I can easily use a 3rd party file compare utility against them. I can do this with Vault source control. Is there a way to get a file from TFS source control and put it into the TEMP (or any other folder) without creating the project folder structure (making a new Workspace pointing to the temp folder creates the folder structure)?
There isn't the build-in feature to redirect files into other folders.
You can create a new workspace and add mappings to the corresponding folders, then switch workspace that you want and get files.
If you want the different folder structure, you can map the corresponding server folders to different folders. More information, you can refer to Optimize your workspace.
There is a ...%TMP%\TFSTemp folder concept in TFS. However it's only used for files that you view.
For example: If you view the history of a file in TFS you can view
any version you want. Simply right click on an older version and
select view from the context menu. Hover over the tab in Visual Studio
and you will see the file was downloaded to the TFSTemp folder. That
file is not check out or download to you and you are just viewing
that file.
It's not used for storing TFS version control files.

Visual Studio 2015 TFS .tfignore file

I want to ignore a folder (and its content) in a visual studio 2015 solution from beeing checked-in into tfs.
I created a file called '.tfignore' in the root of the project that is containing the folder I want to exclude.
The content of the file looks like this: /Dist
This is not working at all. Even if I add *.cs to the file, nothing gets excluded.
Does somebody know where the problem is? How do I wire this up in a working way?
First, please make sure your .tfignore file created without any problem. This file does not have any suffix. One way to create it suggest you to rename a new.txt file with "tfignore." It will auto change to right .tfignore file.
You can also use the auto automatically generated .tfignore file, follow below steps:
In the Pending Changes page, in the Excluded Changes section, choose
the Detected changes link.
The Promote Candidate Changes dialog box appears.
Select a file, open its context menu, and choose Ignore this local
item, Ignore by extension, Ignore by file name, or Ignore by folder.
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.
More info please check the Customize which files are ignored by version control from MSDN Link:Add files to the server
If your .tfignore file is in the solution root folder, adding a \Dist to it will make TFS ignore the Dist folder only inside the root folder. For instance, if you create a Dist folder inside a subfolder (e.g any of the projects folder in the solution), it won't work.
In that case, you need to use just Dist rather than \Dist, then rule will aply to the .tfignore root folder and all its subfolders.
This only apply to folders.
Your file path slash is the wrong kind of slash, it should be a backslash \.
\Dist

How can I exclude a specific file from TFS source control

We have multiple config files (app.DEV.config, app.TEST.config, etc) and a pre-build event that copies the correct config file to app.config. Obviously the configuration specific files are in source control --- but at the moment so is App.Config, and that shouldn't be.
How can I mark that one file as excluded from source control, but obviously not from the project.
I'm using VS 2005, and 2005 Team Explorer.
It's easy in TFS2012, create a .tfignore file
http://msdn.microsoft.com/en-us/library/tfs/ms245454%28v=vs.110%29.aspx#tfignore
######################################
# Ignore .cpp files in the ProjA sub-folder and all its subfolders
ProjA\*.cpp
#
# Ignore .txt files in this folder
\*.txt
#
# Ignore .xml files in this folder and all its sub-folders
*.xml
#
# Ignore all files in the Temp sub-folder
\Temp
#
# Do not ignore .dll files in this folder nor in any of its sub-folders
!*.dll
# EDIT https://msdn.microsoft.com/en-us/library/ms245454(v=vs.110).aspx#tfignore
# A filespec is recursive unless prefixed by the \ character.
Select the App.config file in Solution Explorer, and choose File -> Source Control -> Exclude App.config from Source Control.
There is a checkin policy (Forbidden Patterns Policy) in the MS Power Tools which lets you screen filenames against a regular expression. See: Microsoft Team Foundation Server Power Tools
While checkin policies are not completely foolproof, they are the closest thing TFS has to enforcing user-defined rules like what you're looking for.
(And as the others have said, you can also cloak a file or folder, which means it stays in Source Control and is visible to everyone else on the team, but it's not copied to your PC until you decide to uncloak it; or you can delete the file, which means it gets deleted from everybody's PCs when they get latest - but neither of these options will prevent such files being added to source control in the first place)
There is an option that is hard to find:
1. Select the file or multiple files 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 :)
If all you want is to have a file in the project but not under source control with TFS, just go into SourceControl, delete the said file, and undo your checkout of the project file (it will attempt to remove the file from the project as well). Then check-in your delete of the file you are excluding. In the solution explorer you should see that there is no source control icon next to the file you're excluding. The project file should list a file there, but that file should now no longer be under source control.
Keep in mind, any other person will now see a missing file in the project when they get latest.
TFS allows you to cloak at the folder/file level. When something is cloaked, TFS won't attempt to sync it (much like a svn:ignore).
When setting up your workspace, cloak anything you want TFS to ignore. A more detailed how-to is here.
This worked for me:
One way is to add a new or existing item to a project (e.g. right click on project, Add Existing Item or drag and drop from Windows explorer into the solution explorer), let TFS process the file(s) or folder, then undo pending changes on the item(s). TFS will unmark them as having a pending add change, and the files will sit quietly in the project and stay out of TFS.
Source:
=">How can I exclude a specific files from TFS source control
Visual Studio 2013 (and 2012)
This feature is available by selecting the file(s) and going to:
File > Source Control > Advanced > Exclude ... from Source Control
This question was asked a while ago but it pertains to the same type of issue I was having.
The Problem:
We want to check in our code.
We then want build our project.
During our build we depend on Build Events to move files around so we have the proper files in place for the build process to complete.
When our Build Event tries to copy the files, we get Access Denied errors.
The Reason:
Team Foundation Server Visual Studio Plugin changes the Read Only attribute on our files to READONLY TRUE when we check in our files.
Build Event Example:
copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"
Above, we simply need to move a file from our Target Build Path (the bin\debug or bin\release folders) to our Project Folder. In my situation, this was so I could include project built files in my installer. My Installer wasn't grabbing them as part of the Project Output.
The Fix: (nearly kicked my self in the face when I figured this out)
New Build Event:
attrib -R "$(ProjectDir)SomeFile.ext"
copy "$(TargetDir)SomeFile.ext" "$(ProjectDir)"
attrib +R "$(ProjectDir)SomeFile.ext"
We're all having fun with Build Events right? Above I simply do 2 things, I remove the read only attribute, now the files not read only. Copy my file as I was originally wanting to. Then replace the Read Only Attribute (optional I guess) to keep Visual Studio and Team Foundations happy.
And yes... I'm still kicking myself in the face on this one.
I have a similar issue, my App.config contained sensible data (e.g. username) that this data should not by sync with TFS.
The article Best practices for deploying passwords and other sensitive data to ASP.NET and Azure App Service describes an good approach to prevent this issue:
Use the "file" attribute of the "appSettings" element to reference an config file that is not added to source-control
If you have an older version than TFS2012 and thus can't create a .tfignore file or use the File > Source Control > Advanced > Exclude … option, you can try this:
Make a copy of the target file in Windows Explorer.
Undo Pending Changes (if any) on the target file in Team Explorer/Visual Studio.
Delete the target file in Windows Explorer.
Move the copy of the target file to the location of the deleted target file, and rename it so it has the same name as the deleted target file.
TFS now seems to ignore the changes in the target file. If you need to edit the file again, don't use Visual Studio, as TFS will then put the file back in the list of files with Pending Changes.
You can just simply select the file from your Source Control Explorer and Right Click on it, and the select the "Rename" option from there, and you can add ".exclude" at the end of the file name.
And then do remember to check-in the file, and after that you can see that your file is excluded from Source Control.

Resources