Mercurial and Visual Studio - visual-studio-2010

I have a visual studio 2010 project under mercurial. I use mercurial either via command line or TortoiseHG. I want to work on a new feature, so I clone the repo. But now I am confused, am I supposed to import an entire new project into VS2010 just to work on this feature? I tried importing the VS Solution that was cloned, but got lots of build errors from dependencies cannot be found errors, which I assume is because I am trying to load this cloned Solution just like the original Solution and some paths are wrong (no idea where though).
How are you supposed to use mercurial and VS2010?

Cloning produces an exact copy of the original repository.
The clone should work exactly the same way as the original repository, so you open your cloned solution exactly the same way as the original one.
If you get build errors in the cloned solution but not in the original one, there are probably some dependencies (=3rd party assemblies that your application needs to work properly) which exist in the original solution, but weren't committed to the repository.
So, when you clone the repository, the referenced files are missing in the clone...so the clone won't work.
Source control works the best way if you check in the complete solution, including all dependencies:
Make a "Libs" folder somewhere in your solution, put all your dependencies inside, reference those files from your solution and commit the whole "Libs" folder to the repository.
If you do it this way, you can clone the repository from a different machine and open the solution, without worrying about any dependencies...it just works.

It sounds like your root problem is that you're adding references using full paths rather than relative paths. You'll need to rectify that before branching is going to be easy for you. I usually make a "References" folder that is on the same folder level as the .sln file, but one level up from the individual projects, then branch the whole thing.
Example Folder Structure
MySolution
MySolution.sln
References
MyProject1
MyProject2
As for VS integration, I use TortoiseHG combined with VisualHG, it works great.
There is also Mercurial Toolbar
Other tools

This may or may not be related, but I've had to load hotfix KB2286556 in order to get rid of the "Unable to update project dependencies" error from VS2010 when building a fresh checkout of our code. It seems this only happens to setup and deployment projects when compilation is invoked from the command line (such as in our build system), but when it happens it's a very frustrating issue to find the solution for.
Also, VisualHg is a good way to track and invoke versioning from within Visual Studio.

While VisualHG still proves to be a wonderful tool after so many years, I would also suggest HgSccPackage as a very viable alternative for all Visual Studio versions (up to VS2015).
PROS: Stand-alone package (TortoiseHg is not required).
CONS: Doesn't have all the handy features of TortoiseHg such as Git support (which I find incredibly handy to handle GitHub-hosted projects) and Mercurial Keyring.
Both of them are freeware and can be installed through the Visual Studio GUI (Tools > Extensions and Updates...).
For a more extensive comparison between them you can also read this post on my blog.

Related

How to build FaceDetect/cnn_face_detection project on github?

I want to use the https://github.com/FaceDetect/cnn_face_detection project stored on Github repository but it shows so many different files and no proper documentation is available. Can anyone tell me how to build that github project into an executable?
If the github project has releases or tag, like tornado releases on github.
Then you can run
pip install https://github.com/project_name/archive/version.tar.gz
like this:
pip install https://github.com/tornadoweb/tornado/archive/v4.3.0.tar.gz to install the github online project.
But when the project does't have release tab. You need clone the project and compile from source.
In most cases, you can run python setup.py install.
The question has a python tag. So take python project as an example.
GitHub is mostly used for code. in various languages
How to make any github project usable or executable is specific to the language and to the kind of the project itself.
Also it need to be careful with the license terms, the state of reliability and completeness of the project you intend to work on (i.e: github.com/leezivin/FaceDetection_CNN – snakecharmerb); The fact that the specific project you mention, at the time, do not have a README.md and a license file jet , let's suggest to contact the author or someone contribute/commit the sources for any further informations.
btw the project you mention appears to be a c++ language project; so you need to be able to compile and link it ( Clean an Rebuid ) in some form of executable; The specific repo: cnn_face_detection contains Visual Studio solutions and projects therefore the easy way could be by using Visual Studio and open/import the artifacts ( it depends by version of visual studio you eventually can use ).
It is also required:
to choose if you intend to trust ( or not to trust ) the code:
to take care to the paths of the dependencies referenced by the prj because likely they need to be changed to the actual paths were you clone ( download ) the sources on your own filesystem. if don't do that you may not be able to compile the solution (i.e the three projects contained in the repo ):
By looking around the project, you will find folders named "VC2010" and "VC2006". This is a good clue that this is a Microsoft Visual C (or Visual Studio) based project. Inside you will find .sln and .vcxproj files, which are "solution" and "project" files, according to this list
Download and install Visual Studio from here. There are several options, try the Community edition first.
Download the source code of the project from github. To keep it simple you can just use "Download ZIP" button on the project home page.
Run Visual Studio and follow these directions to open one of the solution (.sln) files:
On the File menu, click Open Solution. The Open Solution dialog box opens.
Navigate to the solution you want.
Click the solution folder, which displays and selects the solution file within the folder. If no solution file is visible, verify that the value in the Files of type list box is Solution Files.
Click Open.
Build using these instructions. At this point you either have an .exe or a .dll (depending on which project you're building).

VS2012 Solution Open scripting or automation

I need to copy standard component DLLs into a standard folder defined in every VS2012 project when the project is opened. We're not allowed to store DLLs in Subversion so I need to reload this folder every time a developer opens the project/solution. I'm looking for an automation solution that will pull DLLs from a centralized location and copy them into the developer's solution. I looked at Visual Studio Extensions but it seems like an awful lot of work just to copy a couple of files. Are there any other hooks in VS2012 (and hopefully VS2010) where I can code simple PowerShell scripts to copy these files?
It turns out AntHillPro has it's own functionality for storing common DLLs and loading them into folders in your Solution before building. It's not as elegant as an MSBuild pre-build task but it fits in with the model followed by our Java builds with some slight tweaking.
Why you just do no use Nuget? Adding nuget reference and enable nuget restore on build will do exactly what you need. You can create nuget repository as shared folder.

Tracking multiple sub-projects using Visual Studio 2012 git

I have been struggling with what (at least in my mind) should be simple:
I have two projects, the "MainProgram" and a "SubLibrary". Both were created with a Git Repository using the new Visual Studio 2012 Git support.
Both repositories work fine independently.
However when I "Add Existing Project"/SubLibrary to my MainProgram Solution, SubLibrary is not being "git-monitored" by Visual Studio at all - no overlaid status icons in Solution Explorer etc. - its just as if that project was not under source-control.
Through some research, I added a git submodule to the MainProgram repo, added the cloned version of SubLibrary project to the solution and .. the git-icons in Solution Explorer appeared!! ... but my joy was short-lived ..... No History, the status of changed files did not show in Solution Explorer. The changes were however picked up by TortoiseGit from within File Explorer.
The .gitmodules file looked OK (but as you can gather I am NO git guru!) .....
Surely it must be possible to have version control over multiple projects/repos within a single solution!
I would be very greatful if anyone could point me in the right direction!
In Git it is indeed usual to have smaller repositories. A typical repository will contain a single project while TFS and Subversion tend to have multiple projects in a single repository.
That will lead to the situation you described. Currently as far as I can see there is no git multi-repository support within Visual Studio (and TFS). It is simply not possible to have a single solution with multiple projects while each project resides in its own Git repository.
What I've done in the past:
I created a directory that served as the root
In that directory create a subdirectory for each individual project
Clone each git repository in its respective subdirectory
In a project use a file reference with a relative path to add references
(optional) create a single MSBuild file that builds all the solutions in its correct order. This way you can create a build using multiple Git repositories.
You won't have a single solution this way, but you will be able to track your changes in each individual repository.
Hope this helps you.

Dll dependencies on a Visual Studio 2010 solution and TFS

How can I make a solution in visual studio so that the .dll dependencies that reside in some other directory totally different from where the solution itself is affected by "get latest".
What I've tried is creating a Dependencies solution folder within the solution itself and added the dlls to it, that way they belong to the solution even though they don't belong to the directory structure of the solution.
So for example the .sln file is in:
D:\tfs\repository\main\SolutionA\solution.sln
and the dlls are in:
d:\tfs\repository\main\SolutionX\Dependencies\Binaries
What I really want to achieve is to have a foolproof way to build the solution, including the following scenario:
1- Have a brand new installation of windows, visual studio, etc.
2- open visual studio
3- find solution.sln on TFS, double click on it so that visual studio gets every project and files in the solution, and opens the solution
4- successfully build
What happens when I try the Dependencies solution folder approach and repeat the scenario above, it will get all the projects within the solution, opens it, but the dependencies solution contents won't be pulled from TFS (although Visual Studio shows them on Solution explorer), which I think is flawed.
Some suggestions that don't involve creating pre/post build scripts are appreciated.
When you attempt to open a solution for the first time using the TFS Source Control Explorer, you may find that not all of your dependencies will be retrieved - the squiggly line may be highlighting some of your missing References.
One work around is to...
SOLUTION SETUP
Checkout all of your source code from TFS (i.e. Main and all of the sub-directories)
Open your solution in Visual Studio (i.e. MyApplication.sln)
In the solution explorer, create a New Solution Folder called ThirdPartyDll, and then add the appropriate assembly references (i.e. Assembly1.dll, Assembly2.dll,...)
Check-in your solution to TFS
SAMPLE FILE STRUCTURE
Main
MyApplication.sln
Source
MyProjectA
MyProjectA.csproj
MyProjectB
MyProjectB.csproj
Dependencies
Assembly1.dll
Assembly2.dll
You've run into a limitation of the "Open from Source Control" functionality. If you added the solution to source control from Visual Studio you should have seen the following message:
"The project that you are attempting to add to source control may cause other source control users to have difficulty opening this solution or getting newer versions of it. To avoid this problem, add the project from a location below the binding root of the other source controlled projects in the solution."
Open from Source Control will create a workspace mapping for the solutions root directory (D:\tfs\repository\main\SolutionA) but not a separate one for the SolutionX folder which is a peer to SolutionA. On the "new" machine you will need to manually create a workspace mapping to d:\tfs\repository\main in order to get both the SolutionA and SolutionX folder.
Create a solution folder and add the dependencies to it, that way when VS gets latest for the solution it will download these files. A bit brittle as people will need to maintain that folder but it works.
Alternatively create a nuget package and use restore packages on build. It will require a couple of extra steps when you create a new developer box (your nuget package repo will need to be added) but it will work for all projects going forward and is less brittle than the solution folder method.

Mercurial and the missing Visual Studio references

I'm rather new to Mercurial and i've just started a project on bitbucket with TortoiseHg. My project in in Visual Studio 2010. I'm able to commit changes to the mercurial without problem but when my team mate pull the project from the mercurial to work on it he get's references missing error. I was wondering if this is a bad config in my project or a missing references on his side?
The files that are referenced in your project are not going to be included in Mercurial, unless those files are contained within the repository.
Your colleague can find which references are missing by expanding theReferences folder in the solution explorer, and seeing which ones have a yellow warning triangle on them. You might need to the copy those missing files over to their machine.
Another option would be to place those referenced files (if appropriate) into a directory within your repository, then remove the reference from the project and re-reference from the new location. Then the files are be added to the repository, although it could bloat the repository, so not ideal if using remote central repositories.
I would also recommend VisualHG for Visual Studio to TortoiseHG integration, if you're not already aware of it.

Resources