问题描述
我包装例如code为SDK分布。在分布,从code将SDK组件的相对路径是从构建机器不同。例如:
I'm packaging example code for an SDK distribution. In the distribution, the relative path from code to the SDK assemblies is different from the build machine. For example:
分配
csharp/bin/assembly.dll
example/ex1/ex1.csproj
建机
foo/sdk/csharp/bin/assembly.dll
bar/baz/quux/ex1/ex1.csproj
假设我动不了什么。有没有一种方法,我可以指示 ex1.csproj
在这两个看起来
../../ CSHARP /斌/
和 ../../../。 ./foo/sdk/csharp/bin /
为 assembly.dll
?
在C ++中我把依赖路径在一个独立的属性表,并与SDK分配一个不同的版本。但C#不具有属性页,我不想保持整个项目的两个版本。
In C++ I'd put the dependency path in a standalone property sheet and distribute a different version with the SDK. But C# doesn't have property sheets, and I don't want to maintain two versions of the full project.
我见过其中指出,我不能使用多个< HintPath方式>
标签,所以我在寻找另一种方式来近似相同的行为
I've seen this question which states that I can't use multiple <HintPath>
tags, so I'm looking for another way to approximate the same behavior.
推荐答案
我发现我的情况,这里的父目录是保证不同工作的哈克解决地方上树:
I found a hacky solution that works for my case, where the parent directory is guaranteed to be different somewhere up 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>
这篇关于对于组装的.csproj多路径的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!