How to identify files updated outside of TFS - tfs

We have a nopCommerce website of a client's that one of their IT guys was modifying views directly on the web server. They now want to do more extensive changes so we want to put the baseline NopCom code in TFS.
Then, ideally, we'd like to be able to identify all the views that were changed directly on the web server and have those changed views be recognize as changes in TFS source control to check-in.
Is there anyway to do this in Visual Studio/TFS in batch? i.e. it would be great to do a check-in locally so all the base code of NopCom was checked in to TFS, then download the website files and overwrite them in the local workspace and have TFS recursively do a diff and determine if any new files were added or existing ones changed and mark those for check-in.... I know...I'm probably dreaming, but any other smart workarounds appreciated as well, assuming this won't work.

TFS does what you want. To set up Team Foundation Version Control (TFVC) on your dev machine, you just need to create a workspace and then add your code. Check link: https://www.visualstudio.com/en-us/docs/tfvc/set-up-team-foundation-version-control-your-dev-machine
When your codebase is under version control, you can develop your app, create and open files in Solution Explorer and write your code, while version control does other work for you. When you check files in and out, it keeps track of your changes and creates a history of your project.
You can use the Diff window to clearly see the difference by comparing folders or files. You can compare server folders and local folders to each other, and view the differences between the contents of each folder. You can compare two server files, two local files, or a server file against a local file and view the differences between the files.
You can get more details about TFVC from website below: https://www.visualstudio.com/en-us/docs/tfvc/overview

Related

TFS - Versioning file in a drop folder

We currently use TFS 2010 for controlling some of our .NET projects.
I'd like to know whether it's possible to provide some kind of versioning within TFS for a specific folder on a network share for example.
The idea being is to control release packages (zips) for every release we do. As this bit is done by some other person (not technical and he doesn't use Visual Studio or any tech tool), it'd be great to streamline the process of versioning the zip files for every release.
Technically speaking:
We've setup this folder \servername\releasezips and every time I drop a file named release.zip, it would automatically commit (push) this file to the TFS server (no comments needed) and furthermore, once the file contents change (meaning that someone dropped another version of the file in there), the system would again push the file to TFS, but with a following version.
Is this possible somehow? I've seen somewhere that I could programatically have some extra control over TFS, using REST API.
Thanks in advance!
Thanks for your tips, Daniel and PatrickLu-MSFT.
As I said, I did want something straighforward, some kind of control similar to what box.com provides, where you associate a local folder on your machine with the cloud. So, once you drop files in the local folder, the small box client synchronizes it along with the cloud. If access the box.com, I can see the different versions of that specific file.
So what I did was, I've created a small .NET app to monitor the folder and any new files dropped in there would get checked in to our TFS server, by using the tf command line (of course ignoring work items or comments).
So, progamatically within the .NET app, it builds up the tf required commands for processing and versioning the recently dropped files and therefore, executes them.
By the way, I could have used the Team Foundation API in order to do the same job, but it would demand way more effort.
Cheers
According to your description, you want to commit/check in files during the build/release pipeline.
It's not a recommend way to check-in generated build files and modify source code during a build pipeline. If you really want to do this, you could edit the build workspace files and use tf commands in custom activity and call the powershell eq:
cd $env:BUILD_SOURCESDIRECTORY
$TFFile = Get-Item "C:\Program Files (x86)\Microsoft Visual Studio 1x.0\Common7\IDE\TF.exe"
$tfOutput = [string]( & $TFFile.FullName checkin /noprompt /override:"***NO_CI*** New version is $newVersion." /comment:"***NO_CI*** New version is $newVersion." 2>&1)
Another way is installing TFS Power Tool and use the Windows PowerShell Cmdlets to check in the files. Refer to this link for more details: PowerShell and TFS: The Basics and Beyond
For version the dropped files, you could take a look this similar question: TFS Build Copy to Versioned Folder
Basically, you have to customize build definition with custom activity and based on build.buildnumber variable to generate/create .zip file.

Mark project changes as pending in source control

I have a small C# console program which uses the AddItem() method of Microsoft.Build.Evaluation.Project to add several language .resx files to all the Projects in several Solutions. This is working fine.
The issue is, those changes do not appear as pending changes in source control. I would like to see the .csproj files marked as pending change and the new .resx as pending adds. What APIs should be used to do this? I found the SccAdd() native API (https://learn.microsoft.com/en-us/visualstudio/extensibility/sccadd-function) but it looks like something that would need to be called by the IDE, not from my command line utility.
Environment: The c# console program is VS2015. The projects it is modifying are VS2008 Compact Framework 3.5. The current Source Control system is TFS 2015.
You could use TFS API to pend changes in a workspace then check in files to TFS. Use the Workspace.PendAdd method queues files or a folder for addition to the version-control repository. Either create a temporarily workspace or use the one your project file located.
Here is a detail example of using the TFS API to add pending changes, checkin code. You could aslo take a look at this question: Calls to `Workspace.PendAdd` not adding items

Using TFS to manage mockups, other images?

I have a TFS server and I often work from two places. I'd like to have a folder that I just keep my random PSDs, mockups, etc in. Maybe even text file notes, or whatever.
The problem is, when I "Check in" a project, it only includes files that are included in the solution. Is there a simple way to have a folder always included?
For instance right now I just have a "mockups" folder in the root of my Team Project (above any individual project folders), but it's not part of any project or solution (I don't really want to publish a few megs of PSD files every time I publish my project).
You can create a Solution folder in your Solution and add the files as an existing file.
(or what is a solution folder)
Do have the psd and mockups something to do with your code?
If not I wouldn't recommend to add the files to the solution.
I would use the Windows Explorer AddIn from TFS Power Tools.
With it you have the ability to checkin/add/checkout files without Visual Studio, you only need to map a folder to your source control.
You can choose on the pending changes window whether you want to have all files checked in from your workspace or from your solution.
See How to show pending changes only for the currently opened solution in Visual Studio 2010 (TFS) and not the complete list of all changes? for a screenshot.

TFS - What happens if I delete a workspace?

I started work a lone developer last year and I found VSS is no longer a good option for source control so I decided to use TFS 2010 instead.
I have had to learn everything from a book - of which there are few.
I am currently creating a new build and in my workspaces I see a have 4. I want to delete one of them and rename another.
However I do not know what the consequences of doing this are. If I delete a workspace, will that remove the associated files under source control? How do I check which files these are? What happens if I change a status from active to cloaked?
As you can see, I am a beginner in all this.
Workspaces are only a mapping from SourceSontrol folders onto your local file system. Also workspace contains information about versions of the files you have locally, so when you hit 'Get Latest Version' only recent changes are sent from server to you, not the whole files. Information on what files are checked out is stored in workspace too, so if you have pending changes in the workspace and delete it then there'll be a bit of a challenge to check these changes in. Renaming of the workspace will not break anything as far as I know.
Article An introduction to TFS Workspaces may be interesting to you.
Like the others have said, the workspace only says what local files you have checked out, and the status, etc. Workspaces are pretty granulal (i.e. per user and per machine) so you could have mutliple workspaces with the same username in the same project. E.g. if you have a copy of Visual Studio at work and one at home, you could have different files checked out and you wouldn't run into any conflicts like you would have in VSS or something based on VSS Like like VSSConnect.
We've had a couple of people leave out project and have had to go in and remove their workspaces after the fact. This hasn't been a big deal in terms of any code losses but if you don't have access to the machine anymore you will have to use the TFS tools.
Try TFS Sidekicks, it provides a nice GUI to manage all the nitty-gritty back-end stuff in TFS

TFS out of sync between local and remote - how to "re-sync"?

I have a Project on CodePlex which is using TFS and I am using the TFS Plugin for Visual Studio. Now I have copied this project and worked on another PC without TFS and done some refactoring. Foolishly, I have then just used copy/paste and manual text editing to merge my changes, expecting that TFS just picks up the changes.
Apparantly, that is not the case.
Here is a screenshot of my local directory:
My Local TFS http://img259.imageshack.us/img259/2897/tfslocal.jpg
Notice how some files are missing the lock symbol - those are missing. If you look at the current TFS Tree on Codeplex, there are some files which do not exist locally anymore, i.e. WikiPlexExtensions.cs in the main folder.
Is there any way to easily tell TFS to compare my local to the remote repository and pick up the changes? I could re-add the local files using "Exclude from local project" and re-adding them, and I could create the "deleted" files as empty files just to delete them, but if I can avoid the manual messing around that would be good as well :)
The easiest way is to exploit VS 2008's "online" feature. Basically you want to set your solution offline, then bring it online while connected to the proper Codeplex server. TFS should figure out the rest.
Feature overview: http://msdn.microsoft.com/en-us/teamsystem/bb898913.aspx
Tweaking the settings by hand: http://blogs.msdn.com/benryan/archive/2008/07/09/using-tfs-2008-power-tools-to-modify-server-s-offline-state.aspx
To compare local and server folders, you can check out TFS Power Tool. After installing it, you can bring up the source control explorer, right click on the server folder and then select 'Compare'. Folder difference window will display the differences. You can also right click on the differences to see available commands such as 'Get Latest' to update your local folder for example. Check out Bryan Harry's blog post on the power tool
I don't think there is an easy fix... What I've done in the past is back up those files that I have edited, then do a "Get Latest Version..." for the files I edited. This should change the files back to being read-only etc... Now, check out the files the regular way and paste the backups you had into the checked out files. Obviously this really only works when there are a couple of files you have edited.
TFS (in Visual Studio) has a "Reconcile" command for this, see Microsoft documentation, or this answer with steps.
BTW: This command may not haven been existing at time of original question, but this question came first when I was searching.

Resources