Have a visual studio copy of the x64 DLL or x86 DLL when building your C # project

We are creating a C # application that uses an external DLL for Sqlite.NET. It's a .NET dll, but it has a C-dll built in, so it comes in x86 and x64 flavors.

We add a reference to the x86 version in the project, so when we build and run on x86 it's fine. Visual studio copies the dll to bin folder and starts.

On x64, it still copies the x86 version and then when it starts up, it doesn't load it. We'll get around this by temporarily setting only x86 for our project, but ideally we would like to say that visual studio copies the correct version depending on what taste of that machine is.

Any ideas how?

+2


a source to share


1 answer


This can be done in MSBuild (i.e. you need to unload the project and edit the file .csproj

).

Essentially add the property to property groups that are conditional on the platform to identify the path to the corresponding assembly, and then use that property in the referenced item group.



The answer is here: Conditional references in a .NET project, can I get rid of the warning?

+2


a source







All Articles