我有一个引用 ODP (Oracle.DataAccess.dll) 的 .NET 3.5 程序集,在 Visual Studio 2010 中构建。复制 Local = False,特定版本为 false。路径是
C:\[ORACLE_BASE]\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll
版本是 2.112.3.0,(运行时 v.2.0.50727)。我的开发机器上安装了 ODAC 11.2.0.3.0 x86。当我构建这个项目并在集成测试中对其进行测试时,一切正常,ODP 已加载并使用。我正在尝试使用 MSBuild(通过 Team City)在 Windows Server 2003 x64 机器上的 Team City 7 上构建相同的集成测试。这台机器安装了相同版本的ODAC,但是是x64版本。
尝试加载 Oracle.DataAccess.dll 时出现问题。好像是在找.NET 2的版本,但是先找到.NET 4的版本,然后就难免失败了。查看日志,它找到了 .NET 4 版本,但仍然无法解析引用,并且似乎明确地在寻找 x86 版本。MSBuild 的配置为:MSBUILD 版本:.NET 4.0 运行平台 x86。
CS项目参考:
<Reference Include="Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86" />
(我尝试将运行平台更改为 x86,并且似乎接受了 Oracle.DataAccess.DLL 库,但抱怨所有其他核心 .NET 库都针对错误的平台,例如 mscorlib
我还尝试通过 rake 脚本进行构建,该脚本使用 msbuild 来构建项目解决方案,并遇到类似的问题。
问题: 我怎样才能让它在我的 x64 机器上正确构建?x86 和 x64 版本的库具有相同的 PublicKeyToken,所以它不应该工作吗?CSProj 中的引用标记是否可以设置为针对“任何 CPU”而不是显式 x64(通过手动编辑文件)?或者,是否有某种方法可以根据构建机器的体系结构有条件地引用库,如此处所示(不完全确定问题是什么,但这可能是一个解决方案)?
[14:30:09]PrepareForBuild:
[14:30:09] Creating directory "bin\Debug\".
[14:30:09]ResolveAssemblyReferences:
[14:30:09] Unified primary reference "Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86".
[14:30:09] Using this version instead of original version "2.112.3.0" in "D:\TeamCity\buildAgent\work\f2ad3a714cc001ba\Source\MyProj\MyProj.Data.Oracle\bin\Debug\MyProj.Data.Oracle.dll" because AutoUnify is 'true'.
[14:30:09]C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\TeamCity\buildAgent\work\f2ad3a714cc001ba\Source\MyProj\MyProj.IntegrationTests\MyProj.IntegrationTests.csproj]
[14:30:09] For SearchPath "D:\TeamCity\buildAgent\work\f2ad3a714cc001ba\Source\MyProj\MyProj.Data.Oracle\bin\Debug".
[14:30:09] Considered "D:\TeamCity\buildAgent\work\f2ad3a714cc001ba\Source\MyProj\MyProj.Data.Oracle\bin\Debug\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "D:\TeamCity\buildAgent\work\f2ad3a714cc001ba\Source\MyProj\MyProj.Data.Oracle\bin\Debug\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] For SearchPath "{TargetFrameworkDirectory}".
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] For SearchPath "{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}".
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Itanium\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Itanium\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\VSTA\v9.0\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\VSTA\v9.0\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\PublicAssemblies\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "D:\ODAC_Base\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.dll", but its name "Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" didn't match.
[14:30:09] Considered "D:\ODAC_Base\product\11.2.0\client_1\ODP.NET\bin\2.x\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "D:\ODAC_Base\product\11.2.0\client_1\ASP.NET\bin\2.x\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "D:\ODAC_Base\product\11.2.0\client_1\ASP.NET\bin\2.x\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] For SearchPath "{AssemblyFolders}".
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\100\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft.NET\ADOMD.NET\100\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Tasks\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Tasks\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\PipelineComponents\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\PipelineComponents\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\ForEachEnumerators\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\ForEachEnumerators\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09] For SearchPath "{GAC}".
[14:30:09] Considered "Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86", which was not found in the GAC.
[14:30:09] For SearchPath "bin\Debug\".
[14:30:09] Considered "bin\Debug\Oracle.DataAccess.dll", but it didn't exist.
[14:30:09] Considered "bin\Debug\Oracle.DataAccess.exe", but it didn't exist.
[14:30:09]GenerateTargetFrameworkMonikerAttribute: