http://stackoverflow.com/questions/18963750/add-file-as-a-link-on-visual-studio-debug-vs-publish

http://stackoverflow.com/questions/2593612/visual-studio-add-item-add-as-link-rather-than-just-add

http://blogs.msdn.com/b/jjameson/archive/2009/04/02/linked-files-in-visual-studio-solutions.aspx

http://blogs.msdn.com/b/jjameson/archive/2009/04/03/shared-assembly-info-in-visual-studio-projects.aspx

需要注意的是,有一个文件名为GlobalAssemblyInfo.cs的文件,这个文件是通过添加链接的方式加入项目的

添加方法为:在项目上右键,添加,现有项,最后选中文件,之后的添加按钮有一个小箭头,点一下,出来菜单,选择添加为链接

A couple of years ago, I wrote a post introducing my system for structuring Visual Studio solutions. However, I apparently forgot to post a follow-up providing additional details, such as configuring assembly versioning and what I like to call "shared assembly information."

Before I can cover these details, I need to first ensure that you are familiar with the concept of linking files in Visual Studio solutions, why this is a powerful feature, and when to use it.

If you ever used Visual SourceSafe (VSS), you likely used its feature for sharing files across multiple projects. For example, you could check-in a file at the root of your solution, and then drag-and-drop it into other projects (i.e. "subfolders") in your solution. Thus, whenever a change was made to the file (regardless of which particular VSS project the change was made in), the next time you "got latest" the change would be reflected in all locations. This was a common way of, for example, having all of your .NET assemblies in the same Visual Studio solution specify the same assembly version.

Note that Team Foundation Server (TFS) does not provide an equivalent "share file" feature. Fortunately, however, you no longer need such a feature.

Back in the days of the original Visual Studio .NET and the following version, Visual Studio .NET 2003, whenever you added an existing file to a project, it copied the file into the corresponding location in the project.

However, in Visual Studio 2005, the Add Existing Item feature provided the ability to choose to either Add the item or Add As Link (via the little down arrow on the button in the dialog box).

In other words, once you upgraded to Visual Studio 2005, it was no longer necessary to rely on any "sharing" features of your source control system in order to have multiple projects always reference the latest version of a file.

Note that when you Add an item in Visual Studio 2005 or Visual Studio 2008, the behavior is the same as earlier versions (meaning the file is copied into the corresponding location within the project). When you choose to Add As Link, however, you simply reference the file in-place. [Don't worry, relative paths ensure that everyone on your team is free to choose whatever root folder they wish for their individual workspaces.]

To illustrate this concept, I quickly built out a "demo" solution, as shown below.

In Windows Explorer, the corresponding folder structure looks like this:

The corresponding folder structure on disk resembles the following:

  • Fabrikam

    • Demo

      • Dev (branch)

        • Lab1 (branch)

          • AssemblyVersionInfo.cs
          • CustomDictionary.xml
          • Fabrikam.Demo.sln
          • Fabrikam.Demo.snk
          • SharedAssemblyInfo.cs
          • AdminConsole

            • AdminConsole.csproj
            • Program.cs
            • Properties
              • AssemblyInfo.cs
          • CoreServices
            • CoreServices.csproj
            • Logging
              • Logger.cs
            • Properties
              • AssemblyInfo.cs

Note that AssemblyVersionInfo.csCustomDictionary.xmlFabrikam.Demo.snk, and SharedAssemblyInfo.csreside in the same folder as the Visual Studio solution file and are subsequently "linked into" the two Visual C# projects. Thus whenever a change is made to one of these files, the next build of each project will reflect that change.

With this foundation in place, I'll explain some other recommended best practices over a series of follow-up posts, including:

Stay tuned!

需要注意的是:

GlobalAssemblyInfo.cs文件需要单独用一个文件夹SolutionItems来存放,此文件夹和解决方案下的其他项目平级

2015年07月03日,发现了新的资源

What are the best practices for using Assembly Attributes?

We're using a global file called GlobalAssemblyInfo.cs and a local one called AssemblyInfo.cs. The global file contains the following attributes:

[assembly: AssemblyProduct("Your Product Name")]

[assembly: AssemblyCompany("Your Company")]
[assembly: AssemblyCopyright("Copyright © 2008 ...")]
[assembly: AssemblyTrademark("Your Trademark - if applicable")] #if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif [assembly: AssemblyVersion("This is set by build process")]
[assembly: AssemblyFileVersion("This is set by build process")]

The local AssemblyInfo.cs contains the following attributes:

[assembly: AssemblyTitle("Your assembly title")]
[assembly: AssemblyDescription("Your assembly description")]
[assembly: AssemblyCulture("The culture - if not neutral")] [assembly: ComVisible(true/false)] // unique id per assembly
[assembly: Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]

You can add the GlobalAssemblyInfo.cs using the following procedure:

  • Select Add/Existing Item... in the context menu of the project
  • Select GlobalAssemblyInfo.cs
  • Expand the Add-Buton by clicking on that little down-arrow on the right hand
  • Select "Add As Link" in the buttons drop down list

一个解决方案下的多个项目共享一个AssemblyInfo的更多相关文章

  1. 一个tomcat下部署多个项目或一个服务器部署多个tomcat

    最近需要把两个项目同时部署到服务器上,于是研究了一下,页借鉴了很多别人的方法,把过程记录下来,以儆效尤. 目录: 1,一个tomcat下同时部署两个项目(多个项目可以参考) 1.1项目都放在webap ...

  2. VS2010如何在同一个解决方案下建立多个项目以及切换运行不同项目

    前言: 在编一些小程序时,往往我们不需要一个问题就建立一个解决方案,我们完全可以让多个项目放在同一个解决方案下,切换启动项运行即可.接下来介绍具体的步骤 一.建立空白解决方案以及添加新项目 1.先建立 ...

  3. Visual Studio中一个解决方案设置多个启动项目

    在解决方案上右键,选择属性. 这样设置之后,点击开始运行之后,会同时启动2个项目. 适合一个项目既包含客户端也包含服务端,方便调试

  4. 一个Tomcat下部署多个项目异常:org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean 的解决方法

    内容简介 在测试服务器上Tomcat下部署两个Spring boot项目,总是一个能启动成功,另一个启动不成功.这两个war包单独部署均能正常启动. 查看日志:启动时报出 org.springfram ...

  5. VS2015如何在同一个解决方案下建立多个项目

    1.先按照常规的方法建一个项目: 2.点击解决方案:右键=>添加=>新建项目 注:本文链接:https://blog.csdn.net/weixin_43081805/article/de ...

  6. 一个域名下多个Vue项目

    公司写的网站要英文和中文的,所以就写了两个项目,都是用vue写的单页面项目,但是域名只有一个,所以就想把两个vue项目合并到一个域名下面.思考:vue的页面都是单页面应用,说白了就是一个index.h ...

  7. 两个域名同时访问一个tomcat下的两个项目

    两个域名,分别映射一个TOMCAT底下,两个应用. 分三个步骤完成. 1.域名与IP的解析,此步骤在万网等机构完成. 2.APACHE的httpd.conf的配置 <VirtualHost *: ...

  8. VisualSVN 新版本终于支持一个解决方案下多workcopy了,并解决了上个版本一个重要BUG

    Multiple working copies within a single solution VisualSVN 7.0 and older require the solution file a ...

  9. oracle怎么把一个用户下的表复制给另一个用户?(授予表权限)

    //把system读写权限 授权给scottselect 'Grant all on '||table_name||' to scott;' from all_tables where owner = ...

随机推荐

  1. C#如何获取快捷方式指向的目标文件

    前几天,做个小程序时遇到的问题,在百度上搜索了很久,没有发现好的解决方案,在英文网站上立刻搜到办法,看来还是国外的资源要全面一些,只是Google经常访问不正常,没办法啊. “C#如何获取快捷方式指向 ...

  2. php检查漏洞防护补丁-防护XSS,SQL,文件包含等多种高危漏洞

    /** * 通用漏洞防护补丁 * 功能说明:防护XSS,SQL,代码执行,文件包含等多种高危漏洞 * Class CheckRequestServer */ class CheckRequestSer ...

  3. Spark小课堂Week3 FirstSparkApp(RDD开发)

    Spark小课堂Week3 FirstSparkApp 问题:Java有哪些数据结构 大致有如下几种,其中List与Map是最重要的: List Map Set Array Heap Stack Qu ...

  4. Python生成验证码

    #!/usr/bin/env python #coding:utf8 import random #方法1: str_code='zxcvbnmasdfghjklqwertyuiopZXCVBNMAS ...

  5. SQL Server是如何让定时作业

    如果在SQL Server 里需要定时或者每隔一段时间执行某个存储过程或3200字符以内的SQL语句时,可以用管理->SQL Server代理->作业来实现. 1.管理->SQL S ...

  6. How to install Hadoop

    1.How to install Hadoop 3.0.0 http://blog.sina.com.cn/s/blog_4a1f59bf01010kx3.html 2.How to install ...

  7. NodeJS包管理工具——npm入门

    如今每个语言体系中都有一个包管理工具,PHP的Composer,Ruby的gem,Python的pip,Java的Maven……当然还有Node.js的npm.有的人会奇怪为何要引入又一个新东西来让我 ...

  8. java实现附件预览(openoffice+swfTools+FlexPaper) (转载)

    下边例子是在网上找了一个网友做的例子,在次记录 1.概述 主要原理 1.通过第三方工具openoffice,将word.excel.ppt.txt等文件转换为pdf文件 2.通过swfTools将pd ...

  9. poj 3207 Ikki's Story IV - Panda's Trick (2-SAT)

    http://poj.org/problem?id=3207 Ikki's Story IV - Panda's Trick Time Limit: 1000MS   Memory Limit: 13 ...

  10. poj 2762 Going from u to v or from v to u?(强连通分量+缩点重构图+拓扑排序)

    http://poj.org/problem?id=2762 Going from u to v or from v to u? Time Limit: 2000MS   Memory Limit:  ...