开发者

Mercurial and Visual Studio

开发者 https://www.devze.com 2023-02-03 17:53 出处:网络
I have a visual studio 2010 project under mercurial. I use mercurial either via co开发者_如何学运维mmand line or TortoiseHG. I want to work on a new feature, so I clone the repo. But now I am confused

I have a visual studio 2010 project under mercurial. I use mercurial either via co开发者_如何学运维mmand 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消