In TFS, can I bind a file in another folder to a Project? - visual-studio-2010

I have a TFS project at $/src/main/MyProject/MyProject.csproj
It has a reference to a DLL at $/dependencies/dependency.dll.
The way I want things to work is that when my colleagues get MyProject, or open it in Visual Studio, I want TFS to go get the latest dependency.dll as well.
(In a similar way, I've actually bound MyProject to my solution in $/src/main/MySolution/MySolution.sln. So if a user gets MySolution and opens MySolution.sln then Visual Studio will go get MyProject as well. I just want to extend this to the next level, that of binding a file to a project.)

This is the perfect scenario to make use of NUGET and even though a little additional work, I would rather go this route :)
Now if you dont want to create the Nupkg etc, one easy way out is to make use of the VisualStudio Add link option.
"Add Link" is project specific and it will add a new entry to your project file specifying the location of your CS/Js/Dll etc file. As long as the file is available in the particular location TFS/VS will pull the latest copy of that file while opening the solution in VisualStudio. Make sure that the Add link creates a relative path to the file and not an absolute path.
ADD vs ADD link

Have you seen the recent announcement on package management for Team Services?

Related

Change Bindings on TFS project

I wanted to add a solution to a project, but accidentally added a solution to the wrong Team Project.
Before adding the project, I made a copy locally. I then deleted the project in Source Explorer and ran a checkin. This deleted the code from the local drive.
I then restore the code from the local copy. Opened the solution and removed the bindings from the Change Source Control form.
The issue I have is every time I try to add the solution back to source control, it is automatically added to the first project. Is there a way to pick the project you add a solution to?
You didn’t completely remove TFS Bindings.
There is a tool to remove Source Control Bindings from Visual Studio Solutions and Projects from msdn: http://blogs.msdn.com/b/saveenr/archive/2012/08/11/a-tool-to-remove-source-control-bindings-from-visual-studio-solutions-and-projects.aspx
More ways and more information for you reference: How can I completely remove TFS Bindings

Visual Studio 2013: How to copy a project's properties to use in another project?

I tried to copy a project's properties to use in another project as instructed in the stackoverflow question Visual Studio: can I copy a project's properties to use in another project? but it does not work. When I open the created PropertySheet it seems that nothing is copied to it from the original property settings. The above link seems to be for VS 2008 but now I am using 2013. What might be the fault.
Caveat: Tested only on a relatively basic C++ project. But it worked!
Right click on your source project (in the solution explorer)
Unload project
Right click on your destination project and unload that as well.
Right click on each project and Edit {project}.vcxproj. The projects' configuration files can now be edited. (Yes you could also just find the file and edit it directly)
Copy/replace elements from the source to the destination.
Reload both projects. They should reload withut problems.
Tips:
If the reload did not work then copy/replace in pieces instead of the entire project to isolate the problem.
Don't replace the "ItemGroup" and the "Globals" PropertyGroup because these (XML) elements identify the projects in the context of the solution. But you should be able to copy/paste everything below these elements from the source .vcxproj file to the destination one without problems.
Try this on two "empty" projects before proceeding to your magnum opus. And definitely make a backup of your projects before trying this. (you are reading all of this before starting, right? Of course you are...)
This solution works better than others I have seen because it sets and unsets settings completely. It's a total replacement, not just an additive one.

Rename project folder in Visual studio and Team foundation server

My Visual Studio 2013 solution has a project "Test". I can rename it in solution explorer, but I also want to rename the project folder in disk and also reflect the change in Source Control(TFS). How can I easily do this?
Thank you
#CodeCaster, Thank you. Based on your advice, I have done some quick experiment, and worked it out. First step is rename the folder name in TFS; the new folder will appear in local workspace and all contents of the folder moved to this new folder. The old folder stays there with rest content which not belong to source control. You can delete it manually.
Or
Using TFS Power Tools to rename from Explorer.
I followed those steps to preserve the version history of the files inside of TFS:
Rename/move project file (.csproj) in source control explorer in VS (alternatively, this also works from within VS Solution explorer, simply select "rename")
Rename/move project folder in source control explorer in VS
now the project should be unavailable in VS, solution also gets closed
remove project from VS
add project (new path) to VS
fix project references in other projects
adjust namespaces if desired
adjust assembly name and default namespace in project settings
Don't know of an easier way. Was searching for this myself, and this should be the way to go.
I think you can rename it from the TFS Database.
Try going into tbl_Project of the Tfs_DefaultCollection Database, which you can find on the SQL Server Instance used by tfs. You can know which one is that by going into the TFS Console, click on Application Tier, then find the details of the Server under the Data Tier Summary. Run an update query against the project you want to rename.. I haven't tested this but just assuming it should work (some educated guess)..
I am using TFS 2015 Express and rename project is grayed out.
You can still rename the project using the TFS Site for the project.
Here is a link that shows how to do it.
https://www.visualstudio.com/en-us/docs/setup-admin/rename-team-project
I was facing a similar issue while trying to rename a folder in Visual Studio 2015.This is what I tried.
Right click on the project file
Open with Notepad
This will generate your current solution file
Change the occurences of your prev file name. (Find and Replace with the desired name)
Save it and close
Change solution explorer name and rename the folder to your desired name.
This should work.

Dll dependencies on a Visual Studio 2010 solution and TFS

How can I make a solution in visual studio so that the .dll dependencies that reside in some other directory totally different from where the solution itself is affected by "get latest".
What I've tried is creating a Dependencies solution folder within the solution itself and added the dlls to it, that way they belong to the solution even though they don't belong to the directory structure of the solution.
So for example the .sln file is in:
D:\tfs\repository\main\SolutionA\solution.sln
and the dlls are in:
d:\tfs\repository\main\SolutionX\Dependencies\Binaries
What I really want to achieve is to have a foolproof way to build the solution, including the following scenario:
1- Have a brand new installation of windows, visual studio, etc.
2- open visual studio
3- find solution.sln on TFS, double click on it so that visual studio gets every project and files in the solution, and opens the solution
4- successfully build
What happens when I try the Dependencies solution folder approach and repeat the scenario above, it will get all the projects within the solution, opens it, but the dependencies solution contents won't be pulled from TFS (although Visual Studio shows them on Solution explorer), which I think is flawed.
Some suggestions that don't involve creating pre/post build scripts are appreciated.
When you attempt to open a solution for the first time using the TFS Source Control Explorer, you may find that not all of your dependencies will be retrieved - the squiggly line may be highlighting some of your missing References.
One work around is to...
SOLUTION SETUP
Checkout all of your source code from TFS (i.e. Main and all of the sub-directories)
Open your solution in Visual Studio (i.e. MyApplication.sln)
In the solution explorer, create a New Solution Folder called ThirdPartyDll, and then add the appropriate assembly references (i.e. Assembly1.dll, Assembly2.dll,...)
Check-in your solution to TFS
SAMPLE FILE STRUCTURE
Main
MyApplication.sln
Source
MyProjectA
MyProjectA.csproj
MyProjectB
MyProjectB.csproj
Dependencies
Assembly1.dll
Assembly2.dll
You've run into a limitation of the "Open from Source Control" functionality. If you added the solution to source control from Visual Studio you should have seen the following message:
"The project that you are attempting to add to source control may cause other source control users to have difficulty opening this solution or getting newer versions of it. To avoid this problem, add the project from a location below the binding root of the other source controlled projects in the solution."
Open from Source Control will create a workspace mapping for the solutions root directory (D:\tfs\repository\main\SolutionA) but not a separate one for the SolutionX folder which is a peer to SolutionA. On the "new" machine you will need to manually create a workspace mapping to d:\tfs\repository\main in order to get both the SolutionA and SolutionX folder.
Create a solution folder and add the dependencies to it, that way when VS gets latest for the solution it will download these files. A bit brittle as people will need to maintain that folder but it works.
Alternatively create a nuget package and use restore packages on build. It will require a couple of extra steps when you create a new developer box (your nuget package repo will need to be added) but it will work for all projects going forward and is less brittle than the solution folder method.

Getting Team Foundation to recognize new files added to source controlled directory

I am working on a PHP project, so I am not using Visual Studio, however the company I work at is mostly a .NET shop so we use Team Foundation Server for version control. I can use VS to manually add files to the TFS project but that is a bit cumbersome when I am adding a bunch of new files, I pretty much have to add the file right after I create it so I don't forget.
What I want to know is if there is a way to have TFS pick up a new file added to a directory that is under source control for a project. For instance if I added a few PHP files to the source controlled html directory I would like to be able to just go to check in pending changes in TFS and have the newly added files included in the list. Does anyone know if this is possible? Thanks much!
There's no way to have this happen automatically with TFS 2010 or below. I've seen a video that says they'll be adding this feature for the next release.
In the meantime, you can use Source Control Explorer, then right-click a folder in the left pane and choose "Add Items to Folder". Follow the dialog and you'll be able to add any of the items that haven't previously been added.

Resources