Visual Studio 2010 - how to force project reference to use exact path NOT GAC or Program Files?
.net, visual-studio-2010
Solution
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".
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.
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.
Possible solutions:
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.
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.
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!
Problem
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. 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> ``` to no avail. How do we FORCE visual studio to respect this path?