Version control and Visual Studio Solutions - visual-studio-2010

I try to get familiar with version control systems (mercurial to be exact) - nearly everything works as it should, but I have trouble with Solution files of the Microsoft Visual Studio 2010 which contain several projects.
Things I add to the ignore list: Bin/debug/Object folders (of course), the .suo file and .csproj files.
Ignoring .csproj files does not seem to be the best idea since other users of my mercurial repository have problems when opening the vs solution: the included projects are "defect".
But including the csproj. files on the other hand also causes trouble as you can read on several pages, or am I wrong here?
What can I do? Thank you

Ignoring .suo files is a good idea since they contain specific user options.
Csproj files represent files defining projects in your solution. So solution defines a number of csproj files, and csproj files define what files/folders are contained withing the projects themselves. You absolutely have to add them to the repository.

Related

Visual Studio - how to fix paths in binary project files?

In MS Visual Studio 2003, I have several related projects and solutions inherited from other developers.
Some binary files (with extensions including ncb, opt, idb, pdb, and pch) reference absolute file-system paths that don't exist on my PC but did on the previous developers' PCs.
One or more of the projects seem to depend on these paths, because the paths appear in the "Resolve Ambiguity" dialog-box when I try "Go To Definition" in source files in some projects.
I have checked the properties of all the solutions and projects in Visual Studio and can't find any reference to these paths. How can I change or remove them without directly editing the binary files?
Edit:
I've used a third-party text-editor to search all file types in the whole directory tree for these solutions and projects.
I've searched for the bad paths containing both single and double-backslashes.
Also, one of the paths contains a username, so I've searched for just the username without the rest of the path.
All of the bad paths are referenced only in binary files. They don't appear in any source-code, solution (.sln) or project (.vcproj) files.
Solved...
According to other resources, the binary files can be deleted.
I deleted those files and rebuilt the solution, which caused Visual Studio to recreate the binary files, and now there's no reference to the nonexistent paths.
I had thought the path references might be the cause of a problem I had running a test application for the solution, but that turned out to be unrelated - the test app was loading an old DLL from C:\Windows\SysWOW64 when I expected it to be using my latest built version.

Should we ignore Solution Output folder while we are using Visual Studio and Version Control?

I'm using Bazaar and Visual Studio 2010 in a C# project. I have prepared an ignore list but still I think all the files in Solution Output directory could be ignored.
I search a lot but nobody had mentioned it. So I'm going to know if I can ignore this directory because output files are changing regularly and seems are not important for repository copy.
What do you suggest about this issue ?
In general, any file that is automatically generated by compiler or build tools should NOT be committed into source control. This includes object files, executables, generated resource files, symbols, etc. Committing those files does not serve any useful purpose. Also, sometimes there are configuration files which look like can be committed, but really should not if they only contain local user specific info - for Visual Studio there are *.user files.
By that logic, solution output folder should be always put into ignore list.

Is there a way to package up just the code that a visual studio solution references.

I'm trying to tidy up a project that is a complete mess, there are several .sln files which each reference between 4 and 15 projects all in the same directory.
Some of the projects have the same or very similar names and are in differently nested directories.
Is there a sensible way to extract all the files that are referenced by a particular solution and it's project so I can put it into source control without all the extra stuff?
I assume it's possible to traverse the .sln file read in the project files listed in it and grab all the files listed there, but I wonder if somone hasn't already made a tool to do this.

how to share a folder between two projects in Visual studio 2010

If I have a project called 'testing' in project A.
How can I share that folder 'testing' for project B in visual studio 2010?
The reason I would like to achieve about this is because when I change something in the folder testing of project A, I dont want to change the same things in project B.
Thanks in advance.
Maybe too late for the person who asked the question, but this is for people with similar problems. You can share folder contents with an extention 'Project Linker':
This builds upon the concept of linked files where you refer to the same file from two projects. This extention handles the management of that for an entire project. If you add a file to the project, it will be added too to the other project as a linked file. Same for deletes...
Attention: you need to have both projects in the same solution for this to work of coarse...
Extention VS2015
I used it in VS2010 and it's also availible for later versions.
You can't share folders in Visual Studio - they are logical constructs that are part of a solution or project.
The closest you can get is to add folders to the projects you need to share on and add all the files that you want to share as links. You will still need to manually synchronize all adds/deletes of files, but updates will come across all projects.
To make things easier, you may want to write a Visual Studio macro that synchronizes these folders for you (you can bind these to keyboard shortcuts and/or menu items).
If you put your solution (*.sln) files in the same directory they can share files in sub directories.

How to prevent Visual Studio from adding generated files to source control

Here's my specific scenario: Using VS2010, Pex and TFS2008, generated moles files are getting automatically added to source-control (TFS).
Pex adds a "project_name.moles" file to your test project and then autogenerates 3 files at build time: project_name.Designer.cs, project_name.Moles.dll, and project_name.Moles.xml. I want to keep the *.moles files in TFS (it's source code) but I don't want the 3 generated files to be in TFS (they are still part of the project, but they are generated when first built on a new system).
There are two reasons I need this behavior:
1. It's not a good idea to store generated code in source-control (let's not debate the merits of that here).
2. Specially, the DLL file is BAD because every time someone builds, all moles files are regenerated and thus all files are checked-out and DLL files are checked-out EXCLUSIVELY (non-mergable) and so other people can no longer build on their local box.
The Pex/Moles team are working on this but the solution is still likely several months away.
Is there a csproj property that can be assigned to these project files so that they are in the project but not managed by version control? I don't mind hand-editing the csproj file.
Moles will not be adding any files to the project in the next version (v0.94). It will use MSBuild to generate the assemblies on demand.
I think it depends more on the version control tool than Visual Studio, as usually you can set up some kind of filters in your version control configuration in order to exclude some files/paths.
E.g. if you use Mercurial/Hg, you can (and should) edit your repository .hgignore file and specify e.g. to exclude all *.moles files and the whole sub-tree MolesAssemblies\*. I guess other version control systems have similar options.

Resources