Visual Studio 2010 - how to force a project link to use the exact path of NOT GAC or Program Files?

We always have this problem, we have a number of solutions and the adjacent folder / Components /. All DLLs that we want to find are in this folder. We built some of them from the source to use a specific version number, which exists only in the Components binary, but when the user on another machine receives the last of everything that is in TFS, and therefore has the exact size on the disk structure. Visual Studio STILL changes the links to those installed in Program Files, GAC, or elsewhere.

We tried to manually edit the proj file to enable HintPath, for example.

<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 visualize FORCE studio to respect this path?

+12
visual-studio-2010
Jul 31 '13 at 10:17
source share
3 answers

Setting "SpecificVersion" to true, in addition to specifying "hintPath", seems to be a solution because it "prevents visual studio from using multiple target rules to allow assembly."

However, as soon as foo.dll is unavailable (when creating or loading a project), Visual Studio starts the magic and changes the build path to the nearest build.

After that, it does not matter if the original foo.dll file is restored to its location (at the specified path) or even CHANGED ! - Visual Studio still refers to its recently found match. This is very undesirable .

Possible solutions:

  • The strong name is foo.dll, but then foo.dll can only refer to other strong named assemblies (often unwanted).

  • Configure assembly permission by registering for the event in the parent application. This allows you to pinpoint where to find the target assembly at runtime, but it seems too large to solve this simple problem.

My one working on this problem (easily) was to set LOCAL COPY to FALSE and add a post assembly to the project that manually copies the target assembly to the target bin folder. The bad part of this is the amount of duplication (and decoupling) created between the post-build phase and the configuration of the project links.

Please Microsoft - add an option to the Reference properties page that will prioritize hintPath (which we will explicitly indicate) by the magic path of surprise ... or at least throw a warning / error if they differ from each other!

+5
Mar 26 '14 at 13:05
source share

We have the same setup - we refer to third-party assemblies (and some of our own) in a separate folder, and the hints in the .csproj file work very well for us.

Visual Studio will first try to find the dll in HintPath , and only if it does not find it, then it will look further - binary files next to the executing assembly, the solution folder or the GAC. Also, remember that the Reference Paths tab in the project properties is handled in the same way as HintPath , and that the listed order of tooltips in folders matters.

If this still bothers you, perhaps you should consider creating your own local NuGet server (which is supposedly not so difficult) from which assemblies will be automatically assembled when the solution loads. This is a bit overkill, but it also handles issues with multiple versions of the dll that are used in different solutions. We still haven't done it, so I can't recommend it first hand, but it's on our to-do list.

+1
Jul 31 '13 at 11:25
source share

Sometimes a hintpath can be a little trickier. Visual Studio is not as smart as we need, and sometimes we can edit the csproj file in XML. The way to do this is as follows:

1.) Right-click the project in the solution explorer and select "Upload Project". // This will make the project inactive in the solution explorer.

2.) Right-click the project while it is inactive, and select "Edit YourProject.ext", where ext is either vbproj or csproj. This will open the XML editor in Visual Studio. // If you need to search in a file, you can press Ctrl-F, but remember that you will need to configure “Look in:” as “Current document”, otherwise it will not search.

3.) When the viewing / editing is completed and the changes are saved, you close the XML file, right-click the project again and select "Update Project".

I rephrased these steps that I found here: http://wiki.visualwebgui.com/pages/index.php/Visual_Studio_HintPath#Viewing_or_editing_the_project_file

Hope this helps, it helps me.

+1
Nov 25 '15 at 16:40
source share



All Articles