一處開發,多處同步編輯使用,並且發布時各個項目均可獨立
一、直接編輯項目工程文件 .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.最終實現的效果

