如何引用不同版本的DLL带的MSBuild [英] How to reference different version of dll with MSBuild

查看:297
本文介绍了如何引用不同版本的DLL带的MSBuild的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有利用一组第三方的DLL的Web应用程序项目。问题是,开发/分期环境是32位,但产量为64bit。因此,我们不得不重新参考,我们要部署的每个时间构建解决方案。我现在想自动化这一点,但不知道该如何去了解它的MSBuild?

I have a web application project which utilises a set of 3rd party dll's. The issue is that the dev/staging environment is 32bit, but production is 64bit. As such, we have to re-reference and build the solution each time we want to deploy. I am now wanting to automate this, but unsure how to go about it with MSBuild?

所有其它的DLL是一样的,只是3第三方dll的。

All other dll's are the same, just the 3 3rd party dll's.

修改

我已经取得了一些进展,但是我来了一些运行时的装配问题。

I have made some headway, however am coming up with some runtime assembly issues.

我有3个DLL文件,1.DLL,2.DLL,3.dll。文件版本为5.1每个。为64位的DLL,名称是完全一样的,只是区别文件版本。我做了什么,更名为每一个1.v5.dll,1.v6.dll等。在我的项目文件,我再引用每个DLL如下:

I have 3 dll files, 1.dll, 2.dll, 3.dll. The file version is 5.1 for each. For the 64 bit dlls, the names are exactly the same, just difference file versions. What I have done, is renamed each one to 1.v5.dll, 1.v6.dll etc. In my project files, I am then referencing each dll as follows:

<Reference Include="1.v5.dll" Condition="'$(Platform)'=='x86'">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>bin\1.v5.dll</HintPath>
  <Private>False</Private>
</Reference>
<Reference Include="1.v6.dll" Condition="'$(Platform)'=='x64'">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>bin\1.v6.dll</HintPath>
  <Private>False</Private>
</Reference>

这工作在Visual Studio IDE中,和我的解决方案编译文件,但是当我去跑的网站,我得到以下错误...

This works in Visual Studio IDE, and my solution compiles file, however when I go to run the website, I get the following error...

无法加载文件或程序集1.v5'或其依赖项之一,位于集清单定义不匹配的程序集引用。

"Could not load file or assembly '1.v5' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

对如何处理这有什么想法?

Any thoughts on how to approach this?

推荐答案

这是我想通了,而且似乎工作没有任何问题。

This is what I have figured out, and seems to work no problems.

我已经建立2解决方案平台,的 86 的和的 64 的。我在所谓的参考的解决方案目录中创建一个新的文件夹,并生成N条x86和x64文件夹:
\\参考\\ 86 \\
\\参考\\ 64 \\
然后将3 DLL的每个被放置在其各自的目录。

I have created 2 solution platforms, x86 and x64. I have created a new folder in my solution directory called "References", and created n x86 and x64 folder: \References\x86\ \References\x64\ The 3 dll's for each are then placed in their respective directories.

在每个项目的文件,我已经然后加入以下参考资料:

In each project's file, I have then added the following references:

<Reference Include="{Reference1}" Condition="'$(Platform)'=='x86'">
  <HintPath>..\References\dlls\x86\{Reference1}.dll</HintPath>
</Reference>
<Reference Include="{Reference2}" Condition="'$(Platform)'=='x64'">
  <HintPath>..\References\dlls\x64\{Reference2}.dll</HintPath>
</Reference>

现在,当我在IDE中开发,我的工作相关的DLL具体到我的需求。

Now, when I develop within the IDE, I am working the the relevant dll specific to my needs.

我然后只添加了复制DLL基于$(平台)变量到bin目录中生成后事件。

I have then just added a post-build event which copies the dll based on the $(Platform) variable into the bin directory.

这篇关于如何引用不同版本的DLL带的MSBuild的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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