0
votes

Our solution contains ~50 projects. They all import a custom .target file that sets the OutDir variable so that all projects build to a common Binaries folder.

Problem is: MSBuild does not check the OutDir folder for the .dlls but keeps looking inside the OutputPath folder (e.g. bin\Debug). As the OutputPath folder is empty it states that each project is not up-to-date and forces a rebuild. This is not an issue on our TFS build agents but it drastically increases the time between hitting F5 and the application starting on our development machines. Debugging becomes quite a pain.

From the Binaries folder we copy the .dlls to our applications folder structure which we use for generating setups etc. Thus simply dropping the use of OutDir in favor of various OutputPaths is not an option.

Is there any way to tell MSBuild to also check the OutDir folder when looking for existing .dlls?

1
Did you ever figure this out?Steven Liekens
@StevenLiekens Not really. We manually modified each and every *.csproj file to match the OutDir path in the end.Sebastian Weber
I'm doing the OutDir vs OutputPath dance right now. It seems to work at least partially as long as I set the properties before importing Microsoft.CSharp.targets.Steven Liekens

1 Answers

0
votes

Following import in csproj files works for me in VS 2015. I added comments about which settings make it fail:

   <?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>

The file is included in csproj files just before Import Microsoft.CSharp.targets:

.csproj file:

<!-- 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>

Also see my own SO question about it: MSBuild, OutputPath to a lib directory is not honoured