HintPath na dodanym referencji w Visual Studio
Wiem, że mogę dodać HintPath do zewnętrznych bibliotek DLL, aby pomóc Visual Studio/TFS znaleźć dll podczas kompilacji.
Zastanawiałam się nad tym... czy można dodać wiele HintPath ?
Na przykład... programiści mają swoje biblioteki DLL w jednym miejscu, a my robimy GetLatest tych bibliotek DLL w innym miejscu na serwerze, stąd potrzeba wielu HintPath.
Jak myślisz, świecie?
5 answers
Sorry, you can 't use multiple HintPath' s. Visual Studio / MSBuild zajmuje tylko last <HintPath>
definicji i zignoruje wszelkie poprzednie. Potwierdzone w VS2010 i VS2012.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-11-16 13:42:20
Ta odpowiedź jest już nieaktualna. Jak mówi komentarz Sardaukara, Visual Studio zawsze ślepo używa ostatniej ścieżki HintPath . odpowiedź Alexa to potwierdza.
W porządku. Tym razem jestem szybszy niż Stackoverflow. Próbowałem go dodać i wydaje się, że działa dobrze.
Więc możliwe jest wielokrotne Przejście.
Kiedy masz to:
<Reference Include="System.ComponentModel.Composition.Codeplex">
<HintPath>..\..\..\MEF2_Preview2\bin\System.ComponentModel.Composition.Codeplex.dll</HintPath>
</Reference>
Możesz po prostu dodać więcej ścieżek podpowiedzi w ten sposób:
<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>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:08:43
Można do tego używać zmiennych środowiskowych. Np.
<Reference Include="System.ComponentModel.Composition.Codeplex">
<HintPath>$(PathToDLLs)\MEF2_Preview2\bin\System.ComponentModel.Composition.Codeplex.dll</HintPath>
</Reference>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-08-08 11:39:19
Używając warunku Możesz:
<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>
Zostanie użyta ostatnia ścieżka HintPath, w której warunek jest oceniany na true.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-11-04 15:01:22
Dodaj poniższy tekst na dole pliku projektu tuż po skomentowanej sekcji cele:
<Target Name="BeforeResolveReferences">
<CreateProperty Value="YOUR_FIRST_PATH;YOUR_SECOND_PATH;$(AssemblySearchPaths)">
<Output TaskParameter="Value" PropertyName="AssemblySearchPaths" />
</CreateProperty>
</Target>
Zastępowanie YOUR_FIRST_PATH
i YOUR_SECOND_PATH
ścieżkami.
Ważne jest, aby to nastąpiło po następującej linii lub Twoje ustawienie zostanie nadpisane:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Z wpisem $(AssemblySearchPaths)
na końcu ciągów bibliotek DLL w ścieżkach nadpisze normalną rozdzielczość. Jeśli przeniesiesz go na początek, najpierw spróbujesz normalnej rozdzielczości, a dodatkowe ścieżki są sprawdziliśmy, czy nie znaleziono żadnych. Normalna rozdzielczość zawiera sekcje <HintPath>
, więc nie ma potrzeby ich usuwania, jeśli ścieżki są pierwsze.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-07-29 09:26:15