Copy NuGet Boost DLL to automatically switch to output directory

I am using several Boost libraries in my C ++ project. Libraries are purchased through NuGet packages eg. Boost Thread library boost_thread .

Compilation and assembly of works without any changes in the project properties. But debugging and starting the application fails due to missing DLL in the output directory.

One solution is to use a post build step to copy the required DLLs. This is described elsewhere, for example. how to make visual studio dll to output directory? ...

This is an example of the required copy command in the Debug configuration:

xcopy /F /Y "$(SolutionDir)\packages\boost_regex-vc100.1.58.0.0\lib\native\address-model-32\lib\boost_regex-vc100-mt-gd-1_58.dll" "$(OutDir)"

      

The project is a Visual Studio 2010 project. But the IDE is actually used by Visual Studio 2013.

But is there a better way to achieve this?

+3


source to share


1 answer


I used the MSBuild copy task for this purpose:

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
  <BoostRT>-gd</BoostRT>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release' Or '$(Configuration)'=='Release_withPDB'">
  <BoostRT></BoostRT>
</PropertyGroup>
<ItemGroup>
<BoostDlls Include="..\packages\boost_log-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_log-vc120-mt$(BoostRT)-1_59.dll;
  ..\packages\boost_thread-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_thread-vc120-mt$(BoostRT)-1_59.dll;
  ..\packages\boost_system-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_system-vc120-mt$(BoostRT)-1_59.dll;
  ..\packages\boost_chrono-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_chrono-vc120-mt$(BoostRT)-1_59.dll;
  ..\packages\boost_date_time-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_date_time-vc120-mt$(BoostRT)-1_59.dll;
  ..\packages\boost_filesystem-vc120.1.59.0.0\lib\native\address-model-$(PlatformArchitecture)\lib\boost_filesystem-vc120-mt$(BoostRT)-1_59.dll" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="Build">
  <Copy SourceFiles="@(BoostDlls)" DestinationFolder="$(OutDir)" />
</Target>

      



The hardcoding version of boost lib (1.59) is not surprising, but different from the fact that it works well.

+1


source







All Articles