Visual Studio: Different DLLs for configurations

后端 未结 4 1348
迷失自我
迷失自我 2021-02-04 03:44

I\'d like to make a x86 and x64 version of my application because some of the libraries I\'m using have differences for x86 and x64 (e.g. SQLite). I made a new configuration fo

相关标签:
4条回答
  • 2021-02-04 04:15

    Which VS version? Which language are you developing in? If native (=not managed) C++, practically all settings, including used libraries can be set differently for each configuration. In the top of the project properties dialog, just choose which configuration's settings would you like to modify.

    0 讨论(0)
  • 2021-02-04 04:17

    You need a condition to the dll reference in the project file.
    This will cause visual studio to recheck the condition and reference whenever you change the active configuration.
    Just add a condition for each configuration.

    Example:

     <ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
        <Reference Include="DLLName">
          <HintPath>..\DLLName.dll</HintPath>
        </Reference>
        <ProjectReference Include="..\MyOtherProject.vcxproj">
          <Project>{AAAAAA-000000-BBBB-CCCC-TTTTTTTTTT}</Project>
          <Name>MyOtherProject</Name>
        </ProjectReference>
      </ItemGroup>
    
    0 讨论(0)
  • 2021-02-04 04:29

    It exists the build-in keyword Choose and When for csproj file.

    Example below:

    <Choose>
      <When Condition="'$(Configuration)' == 'DebugConversion'">
        <ItemGroup>
            <ProjectReference Include="..\OfficeConverer\WordConverter\OfficeConverter.csproj">
                <Project>{b0cbxxxx-xxxx-xxxx-xxxx-7f3353aaxxxx}</Project>
                <Name>Saur.OfficeConverter</Name>
            </ProjectReference>
        </ItemGroup>
      </When>
      <Otherwise>
        <ItemGroup>
            <Reference Include="OfficeConverter, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
                <HintPath>..\packages\OfficeConverter.1.0.1\lib\net45\OfficeConverter.dll</HintPath>
            </Reference>
        </ItemGroup>
      </Otherwise>
    </Choose>
    

    Bref explication: when choosing "DebugConversion" in Visual Studio, the project will load a project name OfficeConverter in the solution, otherwise (such as "Debug" / "Release" by default) a Nuget Dll would be restored and loaded.

    0 讨论(0)
  • 2021-02-04 04:30

    You can add conditions to the dll references in the project file but you cannot do it using Visual Studio - you will have to hand-edit the project files. See this for how to do it.

    What you need to do is to include a reference to the 32-bit dll only in the 32-bit build configuration, and a reference to the 64-bit dll in the 64-bit build configuration.

    0 讨论(0)
提交回复
热议问题