目前,我正在寻求增加一些调试只有code到Windows Phone项目。这调试code会拖一些调试类库引用(NUnit的助手)和一些WCF服务客户端的参考,我真的很想没有这些的发行版本引用。
任何人都可以提出任何方式,我可以添加一个汇编参考调试,但又不希望它出现在发布?
我已经看到了这个在连接 - https://connect.microsoft.com/VisualStudio/feedback/details/106011/allow-adding-assembly-references-on-a-per-configuration-basis-debug-release - 但它被标记为延期
解决方案使用的MSBuild 条件两种情况
,你一旦配置的csproj
,而忘记了这一点。
第一:使用条件
的csproj
文件一种情况需要过滤引用:
< ProjectReference
包括=DebugOnlyHelpers.csproj
条件='$(配置)'=='DEBUG'
二:使用条件
与选择/当:
<选择>
<当条件='$(配置)'=='DEBUG'>
< ItemGroup>
<参考包括=NUnit.dll/>
<参考包括=Standard.dll/>
< / ItemGroup>
< /当>
<否则>
< ItemGroup>
<参考包括=Standard.dll/>
< / ItemGroup>
< /否则>
< /选择>
I'm currently looking to add some debug only code to a windows phone project. This debug code will drag in some debug class library references (nunit helpers) and some WCF service client references, and I'd really like to not have these referenced in the release build.
Can anyone suggest any way that I can add an Assembly-Reference to debug, but not have it appear in release?
I've seen this on Connect - https://connect.microsoft.com/VisualStudio/feedback/details/106011/allow-adding-assembly-references-on-a-per-configuration-basis-debug-release - but it's marked as "postponed"
解决方案Both cases using MSBuild Condition
, you've once configure csproj
and forget about this.
First: Using Condition
csproj
file where need to filter references:
<ProjectReference
Include="DebugOnlyHelpers.csproj"
Condition=" '$(Configuration)' == 'DEBUG' "
Second: Using Condition
together with Choose/When:
<Choose>
<When Condition=" '$(Configuration)'=='DEBUG' ">
<ItemGroup>
<Reference Include="NUnit.dll" />
<Reference Include="Standard.dll" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Standard.dll" />
</ItemGroup>
</Otherwise>
</Choose>
上一篇:转换一个枚举在F#列表或序列或泛型集合类型序列、类型、列表
下一篇:我如何使用方法异步任务&LT;字符串&GT;并返回字符串,然后我如何通过一个委托的方法来构造和以后使用它?字符串、方法来、使用方法、任务