我们的解决方案包含约50个项目。它们都导入了一个自定义.target文件,用于设置 OutDir 变量,以便所有项目都构建到一个公共 Binaries 文件夹。
问题是:MSBuild不会检查.dll的 OutDir 文件夹,但会继续查看 OutputPath 文件夹(例如bin \ Debug)。由于 OutputPath 文件夹为空,它表示每个项目都不是最新的并强制重建。这不是我们的TFS构建代理的问题,但它大大增加了在我们的开发机器上启动F5和应用程序之间的时间。调试变得非常痛苦。
从 Binaries 文件夹中,我们将.dll复制到我们用于生成设置等的应用程序文件夹结构中。因此,只需放弃使用 OutDir 以支持各种 OutputPaths 不是一个选项。
在查找现有的.dll时,有没有办法让MSBuild也检查 OutDir 文件夹?
答案 0 :(得分:0)
在csproj文件中导入后,在VS 2015中为我工作。我添加了关于哪些设置使其失败的评论:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<!-- to distinguish by $(Platform) does not work, a rebuild is triggered since the up-to-date check fails -->
<!-- if IntermediateOutputPath is not set here at all, it does not work either, i.e. it always rebuilds -->
<IntermediateOutputPath>$(SolutionDir)obj\$(Configuration)\$(MSBuildProjectName)\</IntermediateOutputPath>
<UseCommonOutputDirectory>False</UseCommonOutputDirectory>
<DisableFastUpToDateCheck>false</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Condition=" '$(OutputType)' == 'Library' ">
<!-- To distinguish by \lib\ does not work, a rebuild is triggered since the up-to-date check fails -->
<!-- <OutputPath>$(SolutionDir)bin\$(Configuration)\$(Platform)\lib\</OutputPath> -->
<OutputPath>$(SolutionDir)bin\$(Configuration)\$(Platform)</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
<PropertyGroup Condition=" '$(OutputType)' == 'Exe' ">
<OutputPath>$(SolutionDir)bin\$(Configuration)\$(Platform)\</OutputPath>
<OutDir>$(OutputPath)</OutDir>
</PropertyGroup>
</Project>
在导入Microsoft.CSharp.targets:
之前,该文件包含在csproj文件中.csproj文件:
<!-- position of include is important, OutputType of project must be defined already -->
<Import Project="$(SolutionDir)ComponentBuild.props" Condition="Exists('$(SolutionDir)ComponentBuild.props')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
另见我自己的SO问题: MSBuild, OutputPath to a lib directory is not honoured