一处开发,多处同步编辑使用,并且发布时各个项目均可独立

一、直接编辑项目工程文件 .csproj

具体实现为:编辑 .csproj 文件,在<itemgroup>中添加新的 <content /><compile /> 节点:
include: 属性值为项目文件的相对引用路径
link: 节点中放置要引用到当前项目中的位置

1.无需编译的静态资源文件等,使用 标签引入

  • 引用当前工程内的文件
  <itemgroup>
    <content include="views\_emailofficecancelledemail.cshtml"/>
  </itemgroup>
  • 引用外部项目工程中的文件
  <itemgroup>
    <content include="..\mvcdemo\mvcweb\views\_emailofficecancelledemail.cshtml">
    <link>views\_emailofficecancelledemail.cshtml</link>
    </content>
  </itemgroup>

2.需要编译的cs文件等,使用 标签引入

  • 引用当前工程内的文件
  <itemgroup>
    <compile include="controllers\commoncontroller.cs"/>
  </itemgroup>
  • 引用外部项目工程中的文件
  <itemgroup>
    <compile include="..\..\mvcdemo\mvcweb\controllers\commoncontroller.cs">
      <link>controllers\homecontroller.cs</link>
    </compile>
  </itemgroup>

3.最终实现的引用效果

二、使用 visual studio 软件可视化操作

1.右键添加现有项

2.添加为链接

3.最终实现的效果