我有一个.NET 3.5程序集,它引用了在Visual Studio 2010中构建的ODP(Oracle.DataAccess.dll)。复制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 运行Platform x86。
CSProject参考:
<Reference Include="Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86" />
(我尝试将Run Platform更改为x86,似乎接受了Oracle.DataAccess.DLL库,但抱怨所有其他核心.NET库都针对错误的平台,例如mscorlib
我也尝试通过rake脚本进行构建,该脚本使用msbuild构建项目解决方案,并获得类似的问题。
问题: 如何才能在x64机器上正确构建? x86和x64版本的库具有相同的PublicKeyToken,所以不应该工作吗?可以将CSProj中的Reference标记设置为“任何CPU”而不是显式x64(通过手动编辑文件)?或者,有没有办法根据构建机器的体系结构设置一种有条件地引用库的方法,如here所示(不完全确定问题是什么,但这可能是一个解决方案)?
[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:
答案 0 :(得分:5)
我有同样的问题。问题出在服务器上的MsBuild版本中。我使用的是Msbuild 4.0,它使用的是v4.0运行时而不是MsBuild 3.5中使用的2.0.xx。
尽可能尝试使用Msbuild 3.5。如果没有,请检查您的GAC是否正确安装了ODP。我不记得我是如何为MSBuild 4.0修复它的,但我必须使用GAC程序集和machine.config。
这是我在64位构建服务器上的Oracle.DataAccess.dll的GAC列表:
这是machine.config的一部分。我不得不添加程序集重定向:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" culture="neutral" />
<bindingRedirect oldVersion="2.102.0.0-2.120.0.0" newVersion="2.112.2.0" />
</dependentAssembly>
<dependentAssembly>
</assemblyBinding>
</runtime>
我更新了所有的machine.configs以确定:)但是更新Framework64 machine.config就足够了。