.csproj several hints ways to build

I am using sample code to distribute the SDK. In distribution, the relative path from code to SDK assemblies is different from assembly. For example:

Distribution

csharp/bin/assembly.dll example/ex1/ex1.csproj 

Assembly machine

 foo/sdk/csharp/bin/assembly.dll bar/baz/quux/ex1/ex1.csproj 

Suppose I can't move anything. Is there a way I can instruct ex1.csproj look in both

../../csharp/bin/ and ../../../../foo/sdk/csharp/bin/ for assembly.dll ?

In C ++, I put the dependency path in a standalone property sheet and distributed another version with the SDK. But C # does not have property sheets, and I do not want to support two versions of the full project.

I saw this question saying that I cannot use multiple <HintPath> tags, so I am looking for another way to approach the same behavior.

+43
c # visual-studio-2010 msbuild csproj
Mar 27 '13 at 18:27
source share
5 answers

I found a hacker solution that works for my case, where the parent directory is guaranteed to be different from the tree:

 <Choose> <When Condition="Exists('$(MSBuildProjectDirectory)\..\..\example')"> <ItemGroup> <Reference Include="Assembly ..."> <HintPath>..\..\csharp\bin\assembly.dll</HintPath> </Reference> </ItemGroup> </When> <Otherwise> <ItemGroup> <Reference Include="Assembly ..."> <HintPath>..\..\..\..\..\foo\sdk\csharp\bin\assembly.dll</HintPath> </Reference> </ItemGroup> </Otherwise> </Choose> 
+20
Mar 27 '13 at 19:23
source share

The easiest way to use ONE HintPath only is to use the β€œall as good” attribute as this:

 <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> 

Thus, the answer to the question will be as follows:

 <Reference Include="assembly"> <HintPath Condition="Exists('..\..\csharp\bin')">..\..\csharp\bin\assembly.dll</HintPath> <HintPath Condition="Exists('..\..\..\..\foo\sdk\csharp\bin')">..\..\..\..\foo\sdk\csharp\bin\assembly.dll</HintPath> </Reference> 
+52
Nov 04 '14 at 2:59
source share

Add the secondary path as follows to the general property group. in csproj file

 <PropertyGroup> <ReferencePath>..\..\..\..\..\foo\sdk\csharp\bin\</ReferencePath> ... </PropertyGroup> 

The ReferencePath property must be specified when MsBuild is executed, but it will work like this:

+6
Mar 27 '13 at 20:29
source share

You can substitute the /csharp/bin in the drive (differently on each computer), for example X: and then refer to X:\ or X:\bin on both machines, since the path will now be the same.

0
Mar 27 '13 at 18:30
source share

Just add the location of the DLL assembly server as a reference path in the project. It seems to do the trick beautifully and very simply. It only works if you know the DLL assembly server folder.

enter image description here

-one
May 22 '13 at 16:13
source share



All Articles