This question is about how to create dependencies in Visual Studio csproj files to different Debug and Release versions of DLL libraries. (I am under the impression that when working on a Release configuration of library54, it should depend on Release versions of libraries23, 24, and 25, not their Debug versions. I imagine that the different Debug/Release versions of libraries would be stored in different folders.
But Visual Studio only gives me one method for creating a single library dependency for a given library name (right click dependencies and browse to the DLL to reference). But I can't browse to separate Debug/Release versions using Visual Studio.
Context: I have more than 50 solutions that each create at least one library or (sometimes multiple) executable files and that have dependencies among the various libraries and executables. Currently, I use post-build events to copy DLLs and executables to a separate (and centralized) debug folder in the debug tree. Then I make all VStudio dependency references point to the DLLs in that debug folder.
An example post-build event script to copy build products to a single destination folder looks like this:
set bindir=%holding%\MyDebugBinaries
echo "Export folder is: %bindir%"
if not exist %bindir% mkdir %bindir%
copy "$(OutDir)$(TargetName).dll" %bindir%
copy "$(OutDir)$(TargetName).deps.json" %bindir%
This method works reasonably well as long as I only want to produce Debug versions of everything or Release versions of everything into that single destination folder so that other projects can reference the objects during the overall build. (Usually I only work on one or two solutions out of the 50 solutions, so they need to link to the libraries in the centralized storage folder.)
But there seems to be no easy way in Visual Studio to represent Debug and Release dependencies as references to objects in different Debug and Release folders. To work on any individual solution in Debug or Release mode, I need to build the whole world into the single destination folder in either Debug or Release mode.
This thread is pretty good, but it skirts around the issue I'm having. It talks about the value and use of separate Debug/Release output folders. Why have separate Debug and Release folders in Visual Studio?. But I'm talking about something different, I think.
I imagine that MSBuild target elements are smart enough to contain/set/use different dependencies for their relative Debug/Release versions and to use different output folders as well, but is there a way to do all that through Visual Studio methods?
The only way I can think of doing it is to manually edit the VS csproj file to add in custom targets that contain ItemGroup/References like so:
<Target .. Configuration = Debug >
<ItemGroup>
<Reference Include="SomeLibrary">
<HintPath>..\..\DebugFolder\SomeLibrary.dll</Hintpath>
</Reference>
</ItemGroup>
</Target>
<Target .. Configuration = Release >
<ItemGroup>
<Reference Include="SomeLibrary">
<HintPath>..\..\ReleaseFolder\SomeLibrary.dll</Hintpath>
</Reference>
</ItemGroup>
</Target>
I imagine a similar set of Post-Build targets with Debug/Release conditions would do the copying of binaries into the proper centralized Debug/Release folder.
Am I on the right track? Is this kind of thing normally done with manual coding in the project files? Am I missing something obvious? Thank you.