构建C#项目时,有Visual Studio副本DLL的x64或x86 DLL [英] Have visual studio copy x64 DLL or x86 DLL when building a C# project

查看:137
本文介绍了构建C#项目时,有Visual Studio副本DLL的x64或x86 DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在建立一个C#应用程序,使用一个外部的DLL Sqlite.NET。这是一个.NET的DLL,但它嵌入里面一个C DLL,因此它有x86和x64的味道。

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.

我们添加的引用x86版本的项目,所以当我们构建并运行在x86它的罚款。 Visual Studio中复制DLL到bin文件夹并运行。

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.

在64位仍复制过程的x86版本,然后当它运行它无法加载它。我们避开这个问题暂时设置我们的项目将仅适用于x86,但理想的,我们想告诉Visual Studio中拷贝正确版本,这取决于机器的味道是。

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 x86 only, but ideally we'd like to tell visual studio to copy the correct version depending on which flavour of machine it is.

任何的想法如何?

推荐答案

这可以在做的MSBuild(即你需要卸载该项目,并编辑 .csproj的文件)。

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.

答案就在这里:<一href="http://stackoverflow.com/questions/2583732/conditional-references-in-net-project-possible-to-get-rid-of-warning">http://stackoverflow.com/questions/2583732/conditional-references-in-net-project-possible-to-get-rid-of-warning

这篇关于构建C#项目时,有Visual Studio副本DLL的x64或x86 DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆