HintPath for adding links in Visual Studio

I know that I can add HintPath to external DLLs to help Visual Studio / TFS find the DLL when it is created.

I was wondering if it is possible to add multiple HintPath ?

For example, developers have their own DLLs for one place, and we make GetLatest from these DLLs in another place on the server, therefore, several HintPaths are required .

What do you think the world is?

+32
tfs build-process visual-studio-2008
Jan 20 '09 at 18:48
source share
5 answers

This answer is no longer valid. As a comment by Sardaukar says, Visual Studio always blindly uses the latest HintPath . Alex's answer supports this.




Good. This time I'm faster than Stackoverflow. I tried adding it and it seems to be working fine.

Perhaps multiple HintPath.

If you have this:

<Reference Include="System.ComponentModel.Composition.Codeplex"> <HintPath>..\..\..\MEF2_Preview2\bin\System.ComponentModel.Composition.Codeplex.dll</HintPath> </Reference> 

You can simply add another hint path:

 <Reference Include="System.ComponentModel.Composition.Codeplex"> <HintPath>..\..\..\MEF2_Preview2\bin\System.ComponentModel.Composition.Codeplex.dll</HintPath> <HintPath>D:\MEF\System.ComponentModel.Composition.Codeplex.dll</HintPath> </Reference> 
+14
Jan 20 '09 at 19:10
source share

Sorry, you cannot use multiple HintPath. Visual Studio / MSBuild accepts only the definition of last <HintPath> and ignores the previous ones. Confirmed in VS2010 and VS2012.

+37
Nov 16
source share

You can use environment variables for this. For example.

 <Reference Include="System.ComponentModel.Composition.Codeplex"> <HintPath>$(PathToDLLs)\MEF2_Preview2\bin\System.ComponentModel.Composition.Codeplex.dll</HintPath> </Reference> 
+7
Aug 08 2018-11-11T00:
source share

Add the following project file immediately after the comment section:

 <Target Name="BeforeResolveReferences"> <CreateProperty Value="YOUR_FIRST_PATH;YOUR_SECOND_PATH;$(AssemblySearchPaths)"> <Output TaskParameter="Value" PropertyName="AssemblySearchPaths" /> </CreateProperty> </Target> 

Replacing YOUR_FIRST_PATH and YOUR_SECOND_PATH your paths.

It is important that this happens after the next line or your setting will be overwritten:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Writing $(AssemblySearchPaths) at the end of the DLL string in your paths will invalidate the normal resolution. If you move it to the beginning, the usual resolution is executed first, and additional paths are checked for all that were not found. Normal resolution includes <HintPath> sections, so there is no need to delete them if your paths go first.

+2
Apr 04 '13 at 16:32
source share

Using the condition, you can:

 <Reference Include="TheAssembly"> <HintPath Condition="Exists('..\My\Assembly\Path')">..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\My\Assembly\Path')">..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\My\Assembly\Path')">..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\..\My\Assembly\Path')">..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\..\..\My\Assembly\Path')">..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\..\..\..\My\Assembly\Path')">..\..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\..\..\..\..\My\Assembly\Path')">..\..\..\..\..\..\..\My\Assembly\Path\TheAssembly.dll</HintPath> etc... </Reference> 

The last HintPath will be used, in which the condition will be true.

+2
Nov 04 '14 at 15:01
source share



All Articles