2010-04-06 42 views
19

我有兩個引用一個SQLite裝配,一個用於32位和一個64位,它看起來像這樣(這是一個測試項目,試圖擺脫的警告,不要在掛了路徑):.NET項目中的條件引用,有可能擺脫警告?

<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> 

這將產生以下警告:

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

是否有可能對我來說,擺脫這種警告?

我研究過的一種方法是在開發時將我的項目配置爲32位,讓構建機器在構建64位時修復參考,但這看起來有點尷尬,可能很容易錯誤。

還有其他的選擇嗎?

我想擺脫它的原因是,警告顯然是由TeamCity拾起並定期標記爲我需要看的東西,所以我想完全擺脫它。


編輯:每答案,我想這:

<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> 

,然後在我的參考:

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

這擺脫了警告,但它是正確的?

回答

8

如果對SQL精簡版沒有「AnyCPU」集結號你被卡住獨立的基礎之上。

要做到單獨構建創建給出了在條件屬性組正確的路徑的屬性,然後使用該屬性具有單個參考(即移動條件的參考文獻中的項目組之外)。有一個使用這樣一個屬性的例子(對於定製的FXCop擴展)here,你可以看到很多在.csproj文件開頭定義的條件屬性。

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

+0

我已經編輯我的答案跟我的想法是正確的,你可以看看它,並告訴我,如果這是你的意思? – 2010-04-06 10:26:37

+0

@Lasse:這看起來是正確的。 – Richard 2010-04-06 11:22:02

1

在我看來,與原有項目的問題是,你有<SpecificVersion>True</SpecificVersion>指定System.Data.SQLite, Version=1.0.61.0,而實際裝配了1.0版本0.65。在Reference的程序集名稱中修復版本應該有所幫助。

+0

嗯,你有一個觀點,儘管它對x86和x64都會產生警告,其中一個顯然是正確的。我會研究它。 – 2010-04-06 11:56:06

+0

顯然我有一個文件的問題,該文件實際上是1.0.61在這種情況下。該引用已通過Visual Studio手動添加,因此應該是正確的。儘管我會修復這些文件,但那不是警告的罪魁禍首。 – 2010-04-06 11:56:57

+0

另外兩個建議 - 在ItemGroup上放置'Condition',而不是'Reference'本身;嘗試絕對路徑。 – 2010-04-06 16:05:45