This is probably a FAQ, but we weren’t able to find a solution even after a lot of searching.
We have a number of msbuild files that all operate on the same set of source files. (It’s not particularly relevant but they compile to completely different platforms.) To make managing these a little simpler, we’d like to move the <Compile> source file names to a separate file and reference that from all the msbuild files.
We tried cutting the <ItemGroup> containing the <Compile> items and pasting it into a new file, and surrounding it with
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
and then referencing that file from the original with
<Import Project="Common.files.csproj" />
but that does not work – the solution opens (with a warning since we hacked the default config), but no items appear in the Solution Explorer.
What are we doing wrong?
Tried with Visual Studio 2010:
1) Create your external .proj (or .target) file and add your files (I used a different item name but that shouldn’t matter)
2) Import your external .proj file at the top of your Visual Studio project file:
and modify the
CompileItemGroup like this:Warning: You’ll have to add new items/files to your external .proj file – all items/files added from within Visual Studio will end up like this: