开发者

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

We're building a C# app that uses an external DLL for Sqlite.NET. This is a .NET dll but it embeds a C dll inside it and so it comes in x86 and x64 flavours.

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 the bin folder and runs.

On x64 it still copies the x86 version of course and then when it runs it fails to load it. We get round this by temporarily setting our project to be x8开发者_StackOverflow中文版6 only, but ideally we'd like to tell visual studio to copy the correct version depending on which flavour of machine it is.

Any ideas how?


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

Essentially add a property in the property groups that are conditional on the platform to identifier the path of the appropriate assembly, and then use that property in the references item group.

The answer is here: Conditional references in .NET project, possible to get rid of warning?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜