I have my solution laid out as follows
src/Project1 src/Project2 src/Project... bin/*.{dll,exe} lib/Debug/*.dll lib/Release/*.dll
All of the projects are set to build to the top level bin dir. I include a number of 3rd party library dependencies in the lib folder, I like having them here as they then get versioned along with the software in the source repo.
Normally I have each project add a reference to the Debug versions of the libraries but when it comes to releasing I have to manually change all the references to point to the Release versions.
My question is, is there a way to have Visual Studio automatically pick the DLL based on the build configuration?
I suppose you are talking about C#? In that case you can manually adjust the project file to reference the correct library like this:
<Reference Include="Debug\XXX" Condition="'$(Configuration)'=='Debug'"/>
<Reference Include="Release\XXX" Condition="'$(Configuration)'=='Platform'"/>
or if the directory names match the config names exaclty you can even do:
<Reference Include="$(Configuration)\XXX"/>
and if needed you can also pull in the platform names the same way
Modify the MSBuild settings in your project file and add conditions to the references. Like so:
<Reference Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<HintPath>D:\debug\libdll</HintPath>
</Reference>
<Reference Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<HintPath>D:\release\lib.dll</HintPath>
</Reference>
Some reference info:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With