I’ve been using SQLite in a personal project and have encountered an issue with referencing the assembly. The .NET assembly references the unmanaged SQLite proper assembly, and this varies between 32 and 64 bit systems. Hence when building the project on my netbook a number of tests fail.
The solution lies in the following XML places in the project file.
<Choose>
<When Condition="$(PROCESSOR_ARCHITEW6432) == 'AMD64'">
<ItemGroup>
<Reference Include="System.Data.SQLite, Version=1.0.62.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\external-lib\x64\System.Data.SQLite.DLL</HintPath>
</Reference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="System.Data.SQLite, Version=1.0.62.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\external-lib\x86\System.Data.SQLite.DLL</HintPath>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
This conditionally includes the 32 or 64 bit SQLite assembly based on evaluating the PROCESSOR_ARCHITEW6432 variable which contains the current processor architecture. Checking the PROCESSOR_ARCHITECTURE environment variable was a seemingly obvious choice but evaluates incorrectly (for this purpose) in 32 bit MSBuild on a 64 bit system.