Git with Visual Studio Source Control Explorer available yet? - visual-studio-2012

we set up Git as version control system (we used tfs before). Now the source control explorer is not available anymore.
I found this thread from 2013:
Using Git in Visual Studio, how do I navigate repository files?
It's 2015 now and I cannot find any info from late 2014 or 2015. Does anybody know something new?
Thanks

VS2015 still does not have a file browser for Git projects. They do have a list of *.sln files that can be opened within a Git repo. If you have say a "ReadMe.txt" at the root level of the repo though, you still need to open it in explorer or command line and modify it (either by adding to VS or elsewhere), then the file will show up in pending.
In VS2012, there was an add in called "Mindscape File Explorer" that added a file explorer. You could set the root directory to your projects folder and save you from leaving VisualStudio.
Apparently no one at Microsoft cares about solving this problem since it's been around for years now. Seems like it would be an easy win to just show all files at the project root level in either the solution tab or a new project view tab.

Visual Studio "15" Preview has an "Open Folder" feature that let's you load up any folder in the Solution Explorer but it's not connected with Source Control, you have to do it manually after you've connected with the repository in Team Explorer but it's better than nothing.
You can right-click the file to access History, Commit, Compare with unmodified, Undo, Go to git changes... etc

Related

VS2015 Team Explorer showing solutions from node_modules

I just started using the npm package gulp-sass which relies on node-sass.
The node-sass package has a src folder, which includes a .sln file.
This .sln file shows up under my VS2015 Team Explorer Solutions heading. I really don't want that to happen.
Is there a way to exclude solutions placed under "node_modules" from being shown in the Team Explorer?
See attachment for documentation.
For TFVC, when you open the VS, then Visual Studio will scan the local workspace for solution files.
According to your screenshot, you are using GIT as your source control. This should be the same mechanism. VS will scan your local mapping repository. Unless you move the folders in your local repository, the solutions from node_modules will still shown in Team Explorer.
If you really can't stand this feature, you may have to create a "dummy" repository for some folders including sln file on your machine and let Team Explorer scan that one every time you start up, instead.

How can TFS track changes but the solution not yet be bound to source control?

I cannot recall how we got this particular solution down from source control.
The current situation is:
When I explore the solution via "Source Control Explorer" I can see that it is mapped to a local workspace.
When I make changes to files within Visual Studio for the Solution, these changes show up under Pending Changes in Team Explorer.
I can check in these changes and they show up in the history for the solution.
BUT
When I right click on any file in Solution Explorer, I get the option Add Solution to Source Control...
If I choose this option, I get the message:
The item [blah.sln] is already under source control at the selected location....
I know I can fix the issue by selecting File > Source Control > Advanced > Change Source Control and then selecting each project in the solution and pushing the Bind button.
My question is:
How can TFS track changes but the solution not yet be bound to source control?
The source control bindings are stored in numerous places:
On the TFS Server your workspace configuration is kept. Whenever you connect to a TFS Project using Team Explorer your workspace mappings are retrieved and cached on your computer. So Visual Studio will know which folders are mapped to the TFS Server you're connected to.
In the local machine's workspace cache the workspace configuration is kept. This data is refreshed every time you connect to that TFS server. By default this is in you local appdata folder:
This workspace information contains your machine and user information as well as the server path mapping to a local path on your workstation. You can see this information by editing your workspace information in Visual studio:
In the workspace root the $tf folder keeps track of all files in case you're using a local workspace and Visual Studio can use these to detect changes. The Local Workspace was introduced with TFS 2012 and requires you to use Visual studio 2012 or newer, TFS 2012 or newer and to configure your workspace as Local (default for new workspaces in recent versions of Visual Studio).
In the workspace the files are marked read-only when checked in or writable when checked out when you're using a server workspace.
The above was make sure that even with no solution opened, you can use Source Control and check-in/out files.
In addition information is stored in the project file and solution to enable deeper integration in Visual Studio.
In your project file a number of Properties are added to indicate the project
is source controlled.
<PropertyGroup>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
In your solution file a number of Properties are added to indicate the project is source controlled.
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {xxxxx}
SccTeamFoundationServer = http://some-other-guys-tfs-server/
SccLocalPath0 = .
SccProjectUniqueName1 = xxDemo\\xxDemo.csproj
SccProjectName1 = xxDemo
SccLocalPath1 = xxDemo
EndGlobalSection
In your case Visual Studio is relying on the first group of settings to interact with Source Control, but the second set is missing. Using the "Bind" option in the Change Sourcecontrol window will add the proper information to the solution and project files.
Since you're connected to a TFS server and the workspace mappings are synchronized to your system, Visual Studio knows that the folder containing your project is mapped to a TFS project using a workspace mapping.
This functionality is also useful when you're using another IDE that doesn't support TFVC at all, you can still use Visual Studio or the commandline to interact with TFS and operate on the workspace directly.

Visual Studio 2012 - Adding files via Solution Explorer not showing in Pending Changes

I have a VS 2012 solution with multiple projects in it.
When I create a new solution folder or new a folder under projects and add files via the "Solution Explorer" it just modifies the sln or csproj file. The newly added files do not show up in "Pending Changes".
I am having to add the files explicitly again via "Source Control Explorer" -> "Add Items to Folder" to have it actually [add] before check-in.
What would I need to change to have the files added via "Solution Explorer" itself?
Try creating a brand new solution, and then add it to source control. Does the issue still happen for new projects in that solution? Is it the same behaviour for your colleagues?
If so then it sounds to me like you have some strange checkin policy screwing it up.
See the answers in this question for ideas.
Failing all of those, maybe a reinstall of TFS on the server is required, or if it's only affecting you, reinstall VS.

Importing an existing source file in Visual Studio 2012

I want to add the source-code of a tutorial into an existing project, and I want the file to be copied to the project folder from the temporary file on the desktop I downloaded it to. Context clicking on the "Source Files" Folder in the Solution Explorer leads me the Add->Existing Item... menu, and I can then add the source file. However, it is NOT copied into the project folder, but stays in its original location. The project just knows about it, displays it in the Solution Explorer, and considers it part of the project.
This help page on MSDN tells me that in Visual Studio 2010, default behaviour used to consist in copying the file into the project folder, and that one could choose to Add a link instead of physically importing the file into the project directory by choosing "Add Link". However, now I always only get a link, and real physical import into the project folder seems impossible.
I could go through the File Explorer to physically import, but the Solution Explorer doesn't update the new files on the fly, and I would like to do this from within VS.
Is there a way? Is this a bug in VS 2012?
Copy in the files using Explorer, then in the solution explorer tick the Show All files option in the button bar of the solution explorer (you might need to select a Project first).
You can now right-click any files not part of the projects and choose Include in Project.
Or use the Add Existing File option.
The reason files are not added automatically to your solution when pasted into the folder using Explorer is because you might not want to have them added.
A neat little trick is to use the "Open In explorer" option:
(though it might be added by the Productivity Power Tools).
Plus, you can Drag&Drop files directly from explorer to the Visual Studio (when they're both running in the same elevation level if you have User Account Control enabled). To fix the UAC issues, you can either run Explorer as administrator too or install the VSCommands extension.
And you can Copy&Paste a file or set of files into the solution explorer by right-clicking a project or project folder and picking Paste on the context menu.

How to change working directory in Visual Studio

How can I change the working director of Visual Studio C++ 2012. The default working directory is $(ProjectDir), every file I create in my codes are created in the project directory. What I want is that every file is created in the source code's directory, is that possible?
There is no convenient way to do it, but there are some workarounds.
One solution is to move project file to source directory.
Another solution is to add whole source directory to project (just drag'n'drop directory from windows explorer to project in solution explorer). Now, you can add items by right-clicking at source directory in solution explorer. They'll go to physical source folder. This surely works on Visual Studio 2013 RC, but I'm not quite sure about Visual Studio 2012.
One more solution, is to create Project Wizard or even Plugin. It's along story. Maybe, someone already done this, but I was unable to find.

Resources