这可能是一个常见问题解答,但经过大量搜索后我们仍无法找到解决方案。
我们有许多 msbuild 文件,它们都在同一组源文件上运行。 (这不是特别相关,但它们编译到完全不同的平台。)为了使管理更简单,我们希望将
源文件名移动到一个单独的文件并引用该文件来自所有 msbuild 文件。
我们尝试剪切包含
项的
并将其粘贴到新文件中,并用
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
,然后从原始文件引用该文件
但这不起作用 - 解决方案打开(由于我们破解了默认配置,因此出现警告),但解决方案中没有出现任何项目探险家。
我们做错了什么?
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?
发布评论
评论(2)
尝试使用 Visual Studio 2010:
1) 创建外部 .proj(或 .target)文件并添加文件(我使用了不同的项目名称,但这并不重要)
2) 在 处导入外部 .proj 文件在 Visual Studio 项目文件顶部:
并修改
Compile
ItemGroup,如下所示:警告: 您必须将新项目/文件添加到外部 .项目文件- 从 Visual Studio 中添加的所有项目/文件最终都会像这样:
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
Compile
ItemGroup 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:
我从未见过“包含”文件与 MSBuild 一起使用。显然,目标文件以这种方式工作,但我还没有看到另一个文件中包含部分 msbuild 文件。您可以使用如图所示的方法吗?
http://msdn.microsoft.com/en-us/ library/ms171454(VS.80).aspx
使用通配符是我过去解决这个问题的方法。
I've never seen "include" files work with MSBuild. Obviously Targets files work this way, but I haven't seen a partial msbuild file included in another. COuld you use a method such as illustrated in this?
http://msdn.microsoft.com/en-us/library/ms171454(VS.80).aspx
Using wildcards is how I've addressed this in the past.