Delete local folder when project is deleted in TFS? - visual-studio-2010

We just started using TFS and it works great. I have one question though, if we delete a folder it's not deleted on my local workspace. We are currently reorganizing a project and I wish to not have heaps of unused folders on my local drive.
Where can I configure this?
Thanks in advance.

In you have the Visual Studio Power Tools (http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f) you can use the command line tools tfpt to clean up all your workspaces.
In a shell window
change directory to your workspace root
type \tfpt.exe treeclean /recurse .
This will remove any file or folder not in source control.

Another solution, which also checks how well your project is put together, is to cut the whole folder and move it elsewhere, then perform a get across the project. This will allow you to check if the project will build or if there are some "magic" DLLs missing. Anything that is missing can be retrieved from the copy of the structure and added into source control.

Related

Eclipse - how to rename project folder (on filesystem)

My workspace filesystem folder is currently C:\work\Eclipse-Workspace_PROJ and my code filesystem folder is C:\work\PROJ.
I want to rename C:\work\PROJ to C:\work\PROJ-1 but last time I renamed it . . . bad things happened.
QUESTION
What are the steps to rename my code filesystem folder without corrupting things?
You can use Move in the context menu of the Navigator view to move the project to a different folder. This will move the project to a different folder without renaming it.
I sometimes get an error message that the move failed, but the only thing I can see is that the root folder at the old project location is not deleted. After deleting it no further problems occurred (Eclipse Neon.1 / 4.6.1).
Note that the Move function in CDT's Project Explorer view cannot do this.
Since your projects are not inside the workspace directory, they are not at their default location. So renaming the project won't rename the folder.
You should always rename things like Projects inside Eclipse using 'Refactor > Rename'.
There are many things in Eclipse that need to know about the rename, refactor will deal with updating them all.
If you are asking about renaming the Workspace folder then you do that outside of Eclipse (with Eclipse not running). Provided all the plug-ins you have installed in Eclipse are written correctly Eclipse should not care what the workspace folder is called.
Take a backup first if you are worried things may go wrong.
The real answer, according to the comments to this SO answer is that CDT doesn't have the ability to move projects on disk. :(
Copy (not move/rename) the directory on the filesystem to the desired new location.
Delete the Eclipse .project file in that new directory
Delete the old project in Eclipse.
Create a new project in Eclipse at the new location.
Delete the old directory from the filesystem.

How to delete file from TFS and exclude from source control?

I'm working on a project where I'm writing a library. I have a file, lets call it... tester.cs which I use for testing the library. Now, I'm only supposed to check in the library but i accidentally also checked in tester.cs. Is there any way I can delete it from the remote server without deleting it locally? and also ultimately removing it from source control? Thank you in advance.
If you want to delete files on the TFS server and leave them locally. There's the obvious brute-force solution of copying the files to a temporary location, fixing source control, then adding them back in to your project.
And also here is a similar question for your reference: How to delete a file from TFS repository without deleting local file
It depends really on what you mean by 'delete'. TFVC has the concept of delete which flags a file as deleted in the Project Collection database (and removes it from your workspace etc.). And you have the concept op 'destroy' which means the file will be removed from the Project Collection databases, and action that is unrecoverable except by restoring a backup of TFS. But this will leave your local file in place and erase all traces of the file in source control.
However, if you added it to your project in VS (.proj file) then there will be a reference to the file in there as well for compilation etc. This will cause issues when other users perform a Get-Latest of your solution.
Also if you are using a local workspace you can use .tfignore files to prevent such files from being added into the local workspace in the first place. See this page, near the bottom there is some information about the .tfignore file and how they work.
I think it's as simple as making a local copy of a file, deleting it in TFS and moving the local copy back to the original location. Visual Studio does not allow you to do that in a C# project or Source Control Explorer.

Visual Studio / Properties / Debug / Working Directory want it permanent but don't want to check in the *.user file

The project setting Debugging / Working Directory in Visual Studio 20015 will be saved by default in the *.user file wich I don't check in in to my repo because it's user specific. Still, I would like to have something other than $(ProjectDir) standing there when I do a clean checkout of my project. Is there an other place to store the Working Directory besides the *.user file?
Edit 1: The original idea is that I have a solution with multiple projects and all the binaries (dlls and exes) created end up in a folder called bin. If I want to debug it, I don't want to always edit the working directory again after a clean checkout.
Edit 2: In a post build step of every project within my solution, I copy the binaries in to the bin folder. If I start one of the executables from within VS, it starts them from the $(ProjectDir) folder, and of course not from the bin folder. This is why it does not find the dlls and why I want to set the working directory. I could change the output directory of my projects but then I get a lot of files ending up in the bin folder I don't want there. I will try it anyway; maybe I missed something. To be continued...
Edit 3: As expected, if I change the output directory to the bin folder, everything works fine except for some extra files that end up there and I don't want that (e.g. *.pbo, which would be okay, *.iobj, *.ipdb, etc.) Maybe that is the price I have to pay, but I don't like it.
So, the question remains: How can I have more control over which file ends up where after a build and still be able to run it from VS without changing the working dir?
The working directory should not have to be the directory that contains your DLLs. In fact, you definitely don't want that to be a requirement for running your application. Not only is it a hugely unexpected failure mode, but it could also be a potential security risk.
Put the required DLLs in the same directory as your application's executable. That's the first place that the loader will look. If necessary, use a post-build event in your library projects to copy them there.
Well since no body can help me I decided that I will change the output directory to the bin folder so VS will start my applications from the correct folder.
And how I can get rid of all the extra files that don't belong there I will find a way later.

TFS Build 2013 - Cannot resolve primary reference

I'm evaluating TFS Build 2013 for use in a corporate environment.
TFs itself has been running fine for ages, and today I setup the Build components. No problem so far.
I grabbed a fairly simple project from source and created a manually triggered build definition, using the standard defaults.
I ran a test build and hit an issue straight away with a primary reference. The error in the logs is:
C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "XYZ.dll".
So a bit of back of background on how we store and use references:
We create a root folder for the solution, inside this goes the .sln file and sub directories for the projects as normal. We then add a "References" folder at this level, which holds all of the DLLs required for the project. These are generally DLLs from other in house code libraries, but also certain 3rd party ones (such as the old Enterprise Library DLLs, and anything else we don't get from NuGet).
Each of the projects that require these DLLs reference this folder (and from inspecting the .proj files I can see the link is stored as "..\References\XYZ.dll" etc. This works fine for local builds and nobody has ever had an issue. The reference folder gets checked into TFS and everybody gets a copy. From what I've read through trying to diagnose our issue, this is a fairly common and accepted way to manage references.
So, the build error that I receive is as above. Basically saying the build target can't find the DLL from the References folder. The log goes on to list all of the places it's tried to find it.
Crucially (it would seem) the first line reads:
For SearchPath "{HintPathFromItem}".
Considered "..\References\XYZ.dll", but it didn't exist.
Furthermore it looks in the Framework folder, various default assembly folders, the GAC and so on, none of which (of course) contains it.
So I'm wondering where I've gone wrong. Have I misconfigured one of the build/drop locations? Is there some other convention for referencing required DLLs (bearing in mind our entire company uses the "..\References" folder setup, or is there something else?
I'm fairly new to TFS Build, but I'm by no means new to TFS or Visual Studio
itself. I've spent about an hour or so Googling without finding anyone experiencing the same issue as me, so any help would be greatly appreciated.
Thanks
UPDATE:
The build agent is configured as follows:
Build Agent- working directory:
D:\BuildAgent\$(BuildAgentId)\$(BuildDefinitionPath)
The build definition "Source Settings" have the (I assume) default values of:
Status: Active | Source Control Folder: $/ProjectRoot | Build Agent Folder: $(SourceDir)
Status: Cloaked | Source Control Folder: $/ProjectRoot/Drops | Build Agent Folder:
The references folder is not explicitly configured here, but when I look in the Build Agent's working directory I can see it:
D:\BuildAgent\1\ClientName\SolutionName\src\Dev\Evolution\Source\SolutionName.Solution\References
If I open VS2013 Command Prompt, navigate to the folder that contains the .sln file (and also the References folder) and run "msbuild d:\path\to\Solution.sln" then it builds successfully with no warnings or errors.
Well it turns out this wasn't a fault with TFS at all...
The problematic DLL, although present in the References folder, was not actually checked into TFS.
Right clicking the References folder in VS (added as a "Solution Folder") and selecting to Add Existing Item, then a check in fixed the issue.
So the References folder was being used as you would expect, in the same way that VS uses it. MSBuild worked locally because I had the file in my local folder, but because it wasn't part of the solution it wasn't with the rest of the source.

Converting items in Visual Studio project from "links" to copied files

I have a Visual Studio (2008) project where I have some files added as links (through Add Existing Item->Add As Link). Suppose I want to copy this project somewhere else (give it to another developer, release source code, etc.) and I would like to "convert" all these links to actual copies of these files. Is this possible? How can I do this in VS or is there some 3rd party utility to do that?
Thanks.
I met this exactly problem, and wrote a little tool to do this.
Checkout: http://translate.google.com/translate?js=y&prev=_t&hl=en&ie=UTF-8&layout=1&eotf=1&u=http%3A%2F%2Fwww.cnblogs.com%2Fdeerchao%2Farchive%2F2010%2F04%2F22%2F1718183.html&sl=zh-CN&tl=en
I would guess that the easiest approach is simply to remove the items from your project and then add them again, but not as links? If you want to keep the files as links in your project, make the copy first and then remove/add the items in the copy.
if all your files are under a single root (and not c:\...) and relative you can try use TreeTrim.
treetrim.console c:\ -workingcopy -zip:writeTo:c:\out.zip
this will create a zip will all the need info without the temporary files (.pdb, .ncb)

Resources