.csproj 程序集的多个提示路径 [英] .csproj multiple hint paths for an assembly
问题描述
我正在打包 SDK 分发版的示例代码.在发行版中,从代码到 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
同时查看两者
Assume that I can't move anything. Is there a way I can instruct ex1.csproj
to look in both
../../csharp/bin/
和 ../../../../foo/sdk/csharp/bin/
for 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.
我看过这个问题,其中指出我不能使用多个
标签,所以我正在寻找另一种方法来近似相同的行为.
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.
推荐答案
我找到了一个适用于我的案例的 hacky 解决方案,其中父目录保证在树上的某处是不同的:
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>....csharpinassembly.dll</HintPath>
</Reference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Assembly ...">
<HintPath>..........foosdkcsharpinassembly.dll</HintPath>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
这篇关于.csproj 程序集的多个提示路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!