C# 在visual studio项目之间同步文件
我有两个VisualStudio项目。一个是为Windows构建,另一个是为Linux和Mac构建。它们使用完全相同的源文件,但具有不同的构建配置,并针对同一库的两个副本进行链接(一个是为Mono构建的,另一个是为.NET构建的) 下面是一张图表:C# 在visual studio项目之间同步文件,c#,.net,visual-studio-2013,mono,C#,.net,Visual Studio 2013,Mono,我有两个VisualStudio项目。一个是为Windows构建,另一个是为Linux和Mac构建。它们使用完全相同的源文件,但具有不同的构建配置,并针对同一库的两个副本进行链接(一个是为Mono构建的,另一个是为.NET构建的) 下面是一张图表: Folder structure: -- ProjectA -- ProjectA.csproj -- CustomSourceA.cs -- ProjectB -
Folder structure:
-- ProjectA
-- ProjectA.csproj
-- CustomSourceA.cs
-- ProjectB
-- ProjectB.csproj
-- CustomSourceB.cs
-- ProjectCore
-- CommonFile1.cs
-- CommonFile2.cs
...
Reference Structure:
ProjectA -> LibraryA (.NET)
ProjectA -> Includes entire source code of ProjectCore
ProjectB -> LibraryB (Mono, a complete source code rewrite of LibraryA)
ProjectB -> Includes entire source code of ProjectCore
如何同步这些项目,以便从一个项目中添加/删除文件也可以从另一个项目中添加/删除文件?到目前为止,我一直在手动执行此操作。我曾考虑过编写一个脚本,只解析XML并为我完成它,但我想知道是否有一个解决方案不涉及这种手动黑客操作。我最后使用了一个小技巧来完成这项工作。用通配符替换项目B中的所有包含项:
<!-- ProjectB.csproj -->
<ItemGroup>
<Compile Include="..\ProjectA\**\*.cs"/>
</ItemGroup>
最后我用了一个小把戏。用通配符替换项目B中的所有包含项:
<!-- ProjectB.csproj -->
<ItemGroup>
<Compile Include="..\ProjectA\**\*.cs"/>
</ItemGroup>