cja*_*cja 14 c# compiler-directives csproj visual-studio-2013
Visual Studio 2013.
我有一个外部DLL,我在csproj文件中引用如下:
<ItemGroup>
<Reference Include="NameOfDll">
<HintPath>Path\To\Dll\NameOfDll.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
我希望这个引用在编译器符号存在时起作用,而在编译器符号不存在时不起作用.(为了解决下面的第一条评论,假设编译器符号被称为Fred.)
这个问题[ 条件参考 ]让我觉得我可以在上面显示的Reference元素中添加一个名为Condition的属性,但我无法确定哪个值赋予该属性以实现我想要的效果.
我很高兴能在VS UI中找到一种方法,但我会采取任何方法.
Mik*_*ray 23
条件编译符号位于DefineConstantsMSBuild属性中.检查它是否包含您的符号:
<Reference Include="NameOfDll" Condition="$(DefineConstants.Contains('Fred'))">
<HintPath>Path\To\Dll\NameOfDll.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)
为符号选择一个与众不同的名称.不是像Debug或Trace这样的另一个常量的子串.
| 归档时间: |
|
| 查看次数: |
4557 次 |
| 最近记录: |