MSBuild任务不会构建项目引用

时间:2014-09-23 00:01:59

标签: msbuild

假设最新版本的MSBuild,我们说我有3个项目ProjA,ProjB和ProjC。我在A和B中有一个自定义目标,它将各个输出(bin项目)复制到自定义路径$(CustomOutputPath) - 这一切都可以单独使用。 ProjC还有一个自定义目标,但除了将文件复制到$(CustomOutputPath)之外,它还首先清理输出路径,然后链接ProjA和ProjB,以便基本上所有3个项目都将自己的文件放在自定义输出路径中。 / p>

我们假设我无法改变这一要求。

我的ProjC目标看起来像这样:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <!-- Contains groups and properties only like 
         CustomOutputPath and BuildProjects -->
    <Import Project="SharedGroups.msbuild"/>

    <Target Name="AfterBuild">

        <!-- Removing old output -->
        <RemoveDir Directories="$(CustomOutputPath)" />

        <ItemGroup>
            <!-- Arbitrary contents of this project -->
            <FilesToCopy Include="**\*.*" /> 
        </ItemGroup>

        <!-- this works fine -->
        <Copy SourceFiles="@(FilesToCopy)"
              DestinationFolder="$(CustomOutputPath)"
              OverwriteReadOnlyFiles="true" />

        <!-- Once cleanup and copy is completed, I want to run all the other 
             projects builds which contain similar but specific copy tasks as 
             above, with no clean up. BuildProjects is an ItemGroup of all 
             the projects I want to build -->
        <MSBuild Projects="@(BuildProjects)" 
                 Properties="Configuration=$(Configuration); BuildProjectReferences=true"/>

    </Target>

</Project>

我遇到的问题是我在最后一步中尝试构建的项目之一是失败的,因为它引用了解决方案中的另一个项目,该项目不是作为{{1}的一部分构建的}指令,因此无法找到DLL。如果我单独构建此依赖项,那么MSBuild任务将起作用,但我不想独立构建此项目。

为什么我的引用项目没有构建,是否有更好的方法来使用MSBuild?

注意:我对其他解决方案持开放态度 - 我试图制作ProjC的ProjA和ProjB引用(因此不需要ProjC目标底部的MSBuild任务)但是C中的清理步骤发生在A和B副本之后他们的输出是不起作用的。

1 个答案:

答案 0 :(得分:0)

使用/verbosity:detailed并将输出重定向到文件。仔细查看这个词,看看ResolveProjectReferences目标发生了什么。您也可以使用/verbosity:diag并查看为什么跳过事物的详细信息等。这可能很有用,因为在那里使用的各种任务的条件非常多毛。