在.NET项目条件引用,可以消除警告? [英] Conditional references in .NET project, possible to get rid of warning?

查看:167
本文介绍了在.NET项目条件引用,可以消除警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个引用一个SQLite组装,一个用于32位和一个64位的,它看起来像这样(这是一个测试项目,试图摆脱的警告,不要在挂了路径):

 <参考条件='$(平台)'=='64'包括=系统.Data.SQLite,版本= 1.0.61.0,文化=中性公钥= db937bc2d44ff139,ProcessorArchitecture用于AMD64 => 
< SpecificVersion>真< / SpecificVersion>
< HintPath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\64-bit\System.Data.SQLite.DLL< / HintPath>
< /参考和GT;
<参考条件='$(平台)'=='86'包括=System.Data.SQLite,版本= 1.0.65.0,文化=中性公钥= db937bc2d44ff139,的ProcessorArchitecture = 86> ;
< SpecificVersion>真< / SpecificVersion>
< HintPath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\32-bit\System.Data.SQLite.DLL< / HintPath>
< /参考和GT;

这将产生以下警告:

 警告1引用的组件System.Data.SQLite'不能被发现。 

是否有可能对我来说,摆脱这种警告?



我看着它的一种方式,只是配置我的项目是32位的,当我发展,让建筑为64位时,构建机器固定的参考,不过这似乎有点尴尬,可能容易出错。



任何其他的选择吗?



我想摆脱它的原因是,警告显然被拾起的TeamCity并定期标记的东西,我需要考虑,所以我想完全摆脱它。






修改:每答案,我想这样的:

 < ;的PropertyGroup条件='$(配置)| $(平台)'=='调试| 86'> 

< SqlitePath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\32位< / SqlitePath>
< /&的PropertyGroup GT;
<的PropertyGroup条件='$(配置)| $(平台)'=='发布| 86'>

< SqlitePath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\32位< / SqlitePath>
< /&的PropertyGroup GT;
<的PropertyGroup条件='$(配置)| $(平台)'=='调试| 64'>

< SqlitePath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\64位< / SqlitePath>
< /&的PropertyGroup GT;
<的PropertyGroup条件='$(配置)| $(平台)'=='发布| 64'>

< SqlitePath> .. \..\LVK Libraries\SQLite3\version_1.0.65.0\64位< / SqlitePath>
< /&的PropertyGroup GT;



,然后在我的参考:

 <参考包括=System.Data.SQLite> 
< SpecificVersion>假LT; / SpecificVersion>
< HintPath> $(SqlitePath)\System.Data.SQLite.DLL< / HintPath>
< /参考和GT;

这摆脱了警告,但它是正确的?


< DIV CLASS =h2_lin>解决方案

如果没有值为anycpu集结号为SQL精简版你被卡住独立的基础之上。



要做单独的构建创造,让在条件属性组正确的路径属性,然后使用该属性有一个单一的引用(即移动有条件的参考项目组之外)。存在使用这样的特性(为一个自定义的FxCop扩展)这里,你可以看到很多有条件的性质在的开始被定义 。.csproj的文件



(摘要:VS不处理了所有的可能性做的MSBuild)


I have two references to a SQLite assembly, one for 32-bit and one for 64-bit, which looks like this (this is a test project to try to get rid of the warning, don't get hung up on the paths):

<Reference Condition=" '$(Platform)' == 'x64' " Include="System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64">
  <SpecificVersion>True</SpecificVersion>
  <HintPath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\64-bit\System.Data.SQLite.DLL</HintPath>
</Reference>
<Reference Condition=" '$(Platform)' == 'x86' " Include="System.Data.SQLite, Version=1.0.65.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=x86">
  <SpecificVersion>True</SpecificVersion>
  <HintPath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\32-bit\System.Data.SQLite.DLL</HintPath>
</Reference>

This produces the following warning:

Warning 1 The referenced component 'System.Data.SQLite' could not be found.     

Is it possible for me to get rid of this warning?

One way I've looked at it to just configure my project to be 32-bit when I develop, and let the build machine fix the reference when building for 64-bit, but this seems a bit awkward and probably prone to errors.

Any other options?

The reason I want to get rid of it is that the warning is apparently being picked up by TeamCity and periodically flagged as something I need to look into, so I'd like to get completely rid of it.


Edit: Per the answer, I tried this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
    ...
    <SqlitePath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\32-bit</SqlitePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
    ...
    <SqlitePath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\32-bit</SqlitePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
    ...
    <SqlitePath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\64-bit</SqlitePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
    ...
    <SqlitePath>..\..\LVK Libraries\SQLite3\version_1.0.65.0\64-bit</SqlitePath>
</PropertyGroup>

and then in my reference:

<Reference Include="System.Data.SQLite">
    <SpecificVersion>False</SpecificVersion>
    <HintPath>$(SqlitePath)\System.Data.SQLite.DLL</HintPath>
</Reference>

This got rid of the warning, but is it correct?

解决方案

If there is no "AnyCPU" assembly for SQL Lite you are stuck with separate builds.

To do separate builds create a property that gives the correct path in a conditional property group and then use that property to have a single reference (i.e. move the conditional outside the references items group). There is an example of using such a property (for a custom FXCop extension) here, you can see lots of conditional properties being defined at the start of the .csproj file.

(Summary: VS doesn't handle all of the possibilities MSBuild does.)

这篇关于在.NET项目条件引用,可以消除警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆