Visual Studio 2010 Compiling with the Debug or Release version of third party library depending on if my project is being compiled Build or Release?

前端 未结 4 1170
盖世英雄少女心
盖世英雄少女心 2020-11-29 20:28

I\'ve downloaded a number of 3rd party libraries (dlls) now for Visual Studio 2010/C# and I\'ve noticed that in their distributions \\bin directory they usually have two ver

4条回答
  •  盖世英雄少女心
    2020-11-29 21:00

    The answer by WaffleSouffle is definitely the best if you use a Release- and a Debug-folder, as the original question states.

    There seems to be another option that is not so obvious because VS (VS2010) does not show it in the IntelliSense when editing the csproj-file.

    You can add the condition to the HintPath-element. Like this:

          
          ..\lib\MyLib.dll
          ..\lib\Debug\MyLib.dll
    
    

    I found an article by Vivek Rathod describing the above approach at http://blog.vivekrathod.com/2013/03/conditionally-referencing-debug-and.html.

    I checked the XMS Schema file for the project file at: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild\Microsoft.Build.Core.xsd and: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild\Microsoft.Build.Commontypes.xsd

    I cannot see that Condition is a supported attribute for the HintPath-element, but it does seem to work.....

    EDIT 1: This does not make the reference show up twice in Visual Studio which is an issue with the accepted answer.

    EDIT 2: Actually, if you omit the HintPath alltogether Visual Studio will look in the projects output folder. So you can actually do this:

            
          
     
    


    The search order is specified in the file Microsoft.Common.targets
    See: HintPath vs ReferencePath in Visual Studio

提交回复
热议问题