Visual Studio 2010-如何强制项目引用使用非GAC或程序文件的确切路径? [英] Visual Studio 2010 - how to force project reference to use exact path NOT GAC or Program Files?

查看:65
本文介绍了Visual Studio 2010-如何强制项目引用使用非GAC或程序文件的确切路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们永远都会遇到这个问题,我们有许多解决方案和一个相邻的/Components/文件夹.我们要引用的所有DLL都在此文件夹中.我们从源代码中构建了其中一些代码,以使用仅存在于Components二进制文件中的特定版本号,但是当另一台计算机上的用户从TFS获取最新信息时,Visual Studio STILL会更改磁盘上的确切磁盘结构对程序文件,GAC或其他位置中安装的文件的引用.

We're forever having this problem, we have a number of solutions and an adjacent /Components/ folder. All the DLLs we want to reference are in this folder. Some of them we've built from source to use a specific version number that only existins in the Components binary but when a user on a different machine gets-latest of everything from TFS and so has the exact on disk structure Visual Studio STILL changes the references to ones that are installed in Program Files, the GAC or elsewhere.

尝试手动编辑proj文件以包含HintPath,例如

Have tried manually editing the proj file to include HintPath, e.g.

<Reference Include="Foo, Version=5.5.5.5, Culture=neutral, processorArchitecture=MSIL">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>..\Components\Foo.dll</HintPath>
</Reference>

无济于事.我们如何强制Visual Studio遵守这条道路?

to no avail. How do we FORCE visual studio to respect this path?

推荐答案

将"SpecificVersion"设置为true,除了指定"hintPath"外,这似乎是一种解决方案,因为它防止Visual Studio使用多个目标规则进行程序集解析"".

Setting "SpecificVersion" to true, in addition to specifying the "hintPath" seemed like a solution because it "prevents visual studio from using multiple target rules for assembly resolution".

但是,一旦foo.dll不可用(在构建或加载项目时),Visual Studio魔术就会启动并将程序集目标路径更改为最接近的匹配"程序集.

However, once foo.dll is unavailable (while building or loading a project) Visual Studio magic kicks in and changes the assembly target path to the nearest 'matching' assembly.

此后,将原始foo.dll恢复到其位置(位于目标路径名)还是什至 CHANGED (已更改)都没有关系!-Visual Studio仍引用其新发现的匹配项.这是非常不可取的.

After this point, it doesn't matter whether the original foo.dll is restored to its location (at the target pathname) or even CHANGED! - Visual studio still refers to its newly found match. This is very undesirable.

可能的解决方案:

  1. 全名foo.dll,但是foo.dll可能仅引用其他强命名程序集(通常是不希望的).

  1. Strong Name foo.dll, but then foo.dll may only reference other strong named assemblies (often undesirable).

通过在父应用程序中注册事件来自定义程序集分辨率.这使您可以精确地定义在运行时在何处查找目标程序集-但这似乎花费了太多精力来解决这个简单问题.

Customize assembly resolution by registering for an event in the parent application. This allows you to define exactly where to find the target assembly at runtime - but this seems like far too much effort to resolve this simple problem.

我的解决此问题的方法(轻松)是将LOCAL COPY设置为FALSE,并向项目添加了一个后构建步骤,该步骤手动复制了目标程序集到目标bin文件夹.不好的部分是在构建后步骤和项目的References配置之间创建的重复(和去耦)数量.

My work around for this problem (easily) was to set LOCAL COPY to FALSE, and add a post build step to the project, which manually copies the target assembly to the target bin folder. The bad part about this is the amount of duplication (and decoupling) created between the post-build step and the References configuration of the project.

请Microsoft -在引用"属性页中添加一个选项,该选项将对hintPath(我们明确指定)的优先级高于惊奇魔术路径...或者至少发出警告/error,如果两者彼此不同!

Please Microsoft - add an option to the Reference property page that that will prioritize the hintPath (which we explicitly specify) over the surprise magic path... or at the very least, throw a warning/error if the two differ from one another!

这篇关于Visual Studio 2010-如何强制项目引用使用非GAC或程序文件的确切路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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