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

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.

Related

Recovering files deleted by Android studio?

I'm working on an app at the moment, and one of the final steps was to get it built and signed in Android studio.
Unfortunately I was having some problems, and one of the recommended solutions was to remove the project and start again, however when I did this it took all of my files with it, and they're not in the trash (OSX) either.
Is there anyway to recover these files, or are they lost forever? :(
In my case I was looking for the file named 'landing_page222.java' which I deleted one day back.
Following Steps can help you to find your previously deleted files in Android Studio.
Step 1: Right Click on the folder where you deleted the file
Step 2: Find option for Local History and Click Show History.
Step 3: Find your File from Given List.
Hopefully it will be available in Instance
Step 4: Copy the code back as per need.
You can try:
looking for those files in the file system (perhaps they are still in your Android Studio projects folder)
looking in your OS's temp folder
using Android Studio's history feature (right-click on the Project tab > Local History > Show history)
Click whereever you want in the left frame (for example "drawable" file is ok) and then press CTRL+z. You are going to see "Undo delete popup" window.
And as you understand, when you press CTRL+z in Android Studio, which (XML or Java) file is active, you will undo the action on that tab. So, if you click any file on the left side and press the CTRL+z combination, you will undo the action at the file structure.
Go to View > Recent Changes > Click on the file you want to recover > Click "Revert"
Im late but this works. Go to the folder where u want to recover. right-click, local history. select ones you deleted and click revert. :)

Move solution in Source Control

I have a project under source control in Visual Studio 2012 using TFS2010. When I added this project, the solution was not added in the correct file folder location. I want to move the solution, but every time I try to do it within the Source Control Explorer I encounter an error: "The project file 'path/to/project.csproj' has been moved, renamed, or is not on your computer." What is causing this error? What is the proper way to move the solution to where I want it to be?
Move the solution file in TFS (this is more relevant if you have history you want to maintain)
Open the solution, it will complain that it can't load your projects, either edit the path to the project in the properties window, or remove each project and then re-add it. Check-in your changes
Delete the .suo file and try once. Has helped me in the past. This file is usually hidden. Restart VS after deleting.
The problem is the solution file has relative paths to the project files. I usually do any moving around when I first create the solution (before there are projects in it). However, in your case I would just use Source Control Explorer to move the solution, then edit the .sln file in a text editor and fix up the relative paths to the proj files.

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

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.

Visual Studio 2012 not recognizing all pending changes?

I'm working in TFS with my team for project and the problem occurs when I'm trying to make new modeling project for my classes, it doesn't show up in pending changes.
So here is how I go:
First I enter my folder where I keep my classes. I've tried from there many combinations: I've tried first right-clicking on my folder and putting "check-out for edit" and then continued to * (see later); next I've tried clicking on .csproj of my classes so I activate my project when I'll be adding modeling project and then moved to *; last I tried to activate whole solution of our whole projects which is connecting them and then to moved to *.
None of it worked. (I was always having last version)
here is what I did next for all the possibilities:
I went to Architecture -> New diagram (named diagram and left create new project) -> Create (then windows shows up for creating new project in which folder and I always select my folder where I keep my classes).
After when that was done, I went to check to "pending changes" in Team Explorer, because there should be some available since I created already Modeling project. But there was none. Since I couldn't do it like that, the last solution how I made it was by right-clicking to Source-control Explorer on my project and going to Add items to folder and selected my project which was created locally where I wanted it to be created.
But, this last solution was giving me errors while trying to open my modeling project after. I know I should activate first modeling project, so I clicked to .modelproj and while clicking to it, it was giving me this "notice" or rather "warning":
The solution you have opened is under source control but not currently configured for integrated source control in Visual Studio. Would you like to bind this solution to source control now?
--
What am I doing wrong? Why solutions are not integrated by default while creating my project (my friends are doing it automatically, they don't need to right-click in Source Control Explorer to add item to be able to see pending changes)?
I hope I made myself understandable.
It looks like your solution binding is broken. Either click yes on the question to bind your solution to source control, this is information that must be stored in the solution file and while Visual Studio does see that the folder is mapped to source control, it also sees that your solution isn't (did you check the add solution to source control checkbox when you created it?)
Optionally try opening file -> Source Control -> (optionally) Advanced -> Manage Source Control. You can select project in your solution individually and then click the bind button on the toolbar to bind them to sourcecontrol manually.
I had a similar issue and, in my case, the solution was to right click on my project and choose Source Control->Go online. Apparently I must have somehow been switched to the offline mode.
I have successfully checked in files from source control explorer instead of solution explorer in this case. Then after that it has worked again
VIEW > Other Windows > Source Control Explorer
Other way to do it:
File--> Source Control --> Advance --> Change Source Control.
In the window displayed select all the projects you want to bind to the TFS
I had the same issue and solve it by clicking:
File -> Source Control -> Advanced -> Refresh Status
In VS2013+, you can check if your solution is online. In my case, due to VSO service outage, my solutions went offline. I had to open the solution, File > Source Control > Go Online.

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.

Resources