Visual Studio和源代码管理:如何共享代码? [英] Visual Studio&Source Control: How to have shared code?

查看:542
本文介绍了Visual Studio和源代码管理:如何共享代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Visual Studio中有一些共享的代码(代码库,控件,实用程序,帮助程序类等).我不是指共享程序集,而是共享代码(即,我想随我的应用程序一起发布一个程序集,即可执行程序集).

其他开发环境中的技术是在机器上的路径中包含通用源代码,并且为IDE提供了用于搜索代码文件的路径列表.

Visual Studio不支持代码搜索路径.

备份黑客解决方案是将源代码一遍又一遍地复制到每个项目中.但是,为了将它们全部保留为一个版本,必须在源代码管理中共享它们.当您的源代码控制提供程序是Microsoft Visual SourceSafe(支持共享文件)时,此方法效果很好.

但是其他源代码控制产品(CVS,Subversion,Microsoft Team Foundation源代码保存服务器,SVN)不支持共享文件.

那么其他人如何避免将DLL与可执行文件一起运送呢?


更新1

这是单个文件部署的问题. ClickOnce在3个文件夹中生成18个文件(即多个文件)

解决方案

我可以提出两种解决方案:

  1. Visual Studio允许您将链接添加到文件.选择添加现有项",选择文件,然后单击添加"按钮旁边的箭头.将显示一个弹出窗口,您应该从此处选择添加为链接".现在,您可以将通用代码存储在一个位置(文件夹)中.

  1. 在可重用的程序集中编译您的通用代码,并在您的项目中使用它们.使用 ILMerge 在部署时将所有程序集合并为一个.我个人更喜欢此选项.

i want to have some shared code (code library, controls, utilities, helper classes, etc) in Visual Studio. i do not mean shared assemblies, i mean shared code (i.e. i want to ship one assembly with my application, the executable assembly).

The technique in other development environments way is to have the common source code in a path on my machine, and the IDE is given a list of paths to search for code files.

Visual Studio does not support code search paths.

The back-up hack solution is to copy the source-code over and over into every project. But then in order to keep them all as one version, they are shared in source control. This works well when your source control provider is Microsoft Visual SourceSafe - which supports shared files.

But other source control products (CVS, Subversion, Microsoft Team Foundation Source Save Server, SVN) do not support shared files.

So how does everyone else avoid shipping DLL's with their executable?


Update 1

It is an issue of single file deployment. ClickOnce generates 18 files in 3 folders (i.e. more than one file)

解决方案

I could propose two solutions:

  1. Visual Studio allows you to add a link to a file. Choose "Add Existing Item", pick your file and then click the arrow next to the "Add" button. A popup will display and you should choose "Add as link" from there. Now you can store your common code in one location (folder).

  1. Compile your common code in reusable assemblies and use them in your projects. Use ILMerge to merge all assemblies into one when deploying. I personally prefer this option.

这篇关于Visual Studio和源代码管理:如何共享代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆