当前位置: 移动技术网 > IT编程>开发语言>.net > .NET项目中实现多工程文件共用的方法

.NET项目中实现多工程文件共用的方法

2019年11月08日  | 移动技术网IT编程  | 我要评论

曹妃甸地图,河北找工作,普利乐比高

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

一、直接编辑项目工程文件 .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.最终实现的引用效果

20191105172002.png

20191105172528.png

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

1.右键添加现有项

20191106172153.png

2.添加为链接

20191106172410.png

3.最终实现的效果

20191106172602.png

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网