Windows 上编译 corefx 源码生成 Linux 上可用的 System.Data.SqlClient.dll
最近在排查一个奇怪的 EF Core 查询速度慢的问题,需要在 corefx 2.2.3 的 System.Data.SqlClient 源码中打点。
github 上签出 corefx 的源代码,运行 build.cmd 命令,然后用 VS2017 打开 System.Data.SqlClient.sln ,添加 Console.WriteLine 打点代码,用 VS 进行 build 。
build 之后 corefx 根路径下 bin\Windows_NT.AnyCPU.Debug\System.Data.SqlClient\netstandard 文件夹中会生成 System.Data.SqlClient.dll 文件,但这个 dll 在 Linux 上无法使用(错误如下)。
The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'sni.dll' or one of its dependencies.
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable:
libsni.dll: cannot open shared object file: No such file or directory
at System.Data.SqlClient.SNINativeMethodWrapper.SNIInitialize(IntPtr pmo)
而 bin\AnyOS.AnyCPU.Debug 中没有生成 System.Data.SqlClient.dll 。
改用 build-managed.cmd 命令 build :
build-managed.cmd -Project=src\System.Data.SqlClient\src
出现下面的错误提示
error CS1069: The type name 'Console' could not be found in the namesp
ace 'System'. This type has been forwarded to assembly 'System.Console, Version=0.0.0.0, Culture=neutral, PublicKeyToke
n=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
在 System.Data.SqlClient.csproj 中添加 System.Console 的引用后消除了上面的错误提示。
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
<Reference Include="System.Console" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Data.Common" />
<Reference Include="System.ComponentModel.Primitives" />
<Reference Include="System.Xml.ReaderWriter" />
<Reference Include="System.Runtime.InteropServices" />
</ItemGroup>
但 build 结果与 Visual Stuido 一样,得不到 Linux 版的 System.Data.SqlClient.dll 。
到 Linux 机器上试了试,运行 ./build-managed.sh 命令后会在 bin/AnyOS.AnyCPU.Debug 文件夹中生成 System.Data.SqlClient.dll ,原来要得到 Linux 上可用的 System.Data.SqlClient.dll 需要 build 输出到 bin/AnyOS.AnyCPU.Debug 文件夹。
但 Linux 上 build 有个问题,每次修改代码后 build 总会出现下面的错误:
/root/corefx/Tools/sign.targets(113,5): error : /root/corefx/bin/obj/ref/Microsoft.CSharp/4.0.0.0/netstandard/Microsoft.CSharp.dll: PE file is already strong-name signed. [/root/corefx/src/Microsoft.CSharp/ref/Microsoft.CSharp.csproj]
需要运行 ./build-managed.sh -CleanAllProjects 命令才能消除这个错误。
继续回到 Windows 上,运行 build-managed.cmd -? 命令仔细看了一下命令参数,发现了 -OSGroup 参数
[-OSGroup] Sets the OS for the BuildConfigurtation you want to build.
=> Default value: ${OSName}
=> Legal values: [Windows_NT, Unix, Linux, OSX, FreeBSD, NetBSD].
于是使用下面的命令进行 build
build-managed.cmd -OSGroup=Linux
这样 build 后会在 bin 中多了 Linux.AnyCPU.Debug 与 Unix.AnyCPU.Debug 文件夹, Linux 上可用的 System.Data.SqlClient.dll 就在 Unix.AnyCPU.Debug 文件夹中。
Windows 上编译 corefx 源码生成 Linux 上可用的 System.Data.SqlClient.dll的更多相关文章
- [原]在win上编译 subversion 源码实践Tonyfield的专栏
(百度和网页的作者无关,不对其内容负责。百度快照谨为网络故障时之索引,不代表被搜索网站的即时页面。) [原]在win上编译 subversion 源码实践 2013-6-9阅读400 评论0 (参考 ...
- 在ubuntu16.04上编译android源码【转】
本文转载自:http://blog.csdn.net/fuchaosz/article/details/51487585 1 前言 经过3天奋战,终于在Ubuntu 16.04上把Android 6. ...
- 【转】Ubuntu10.04上编译Android源码(Build Android source in Ubuntu10.04 Platform)
原文网址:http://blog.csdn.net/chenyafei617/article/details/6570928 一.Introduction 今天我们就来谈谈如何在Ubuntu平台上面编 ...
- 在Mac mini上编译Android源码
参考文章 1.Android 6.0 源代码编译实践 2.编译Android源码致命错误解决方案 实践过程 1.Mac下安装Ubuntu双系统 (1)Ubuntu版本:Ubuntu 15.10 注:实 ...
- Windows下编译live555源码
Windos下编译live555源码 环境 Win7 64位 + VS2012 步骤 1)源码下载并解压 在官网上下载最新live555源码,并对其进行解压. 2)VS下建立工程项目 新建Win32项 ...
- CentOS6.5上编译OpenJDK7源码
本文地址:http://www.cnblogs.com/wuyudong/p/build-openjdk7.html,转载请注明源地址. 采用开源的OpenJDK版本,获取其源码的方式有两种: 通Me ...
- ant编译solr源码生成eclipse项目,解决一直resolve,一直[ivy:retrieve]的问题
这两天在学习solr,结果刚到编译solr源码就卡住了,足足卡了两天,网上找各种解决办法都是简单带过,说是缺少jar包,下载下来放到对应位置就好了....对应位置???咋不说这个问题用相应方法解决即可 ...
- Nginx (一)Windows下编译Nginx源码以及安装 nginx for windows方法步骤
转载自: http://apps.hi.baidu.com/share/detail/11192699#content Nginx介绍: Nginx ("engine x")是一个 ...
- <转>windows下编译lua源码
因为之前一直使用 lua for windows 来搭建lua的使用环境,但是最新的 lua for windows 还没有lua5.2,我又想用这个版本的lua,所以被逼无奈只能自己编一下lua源码 ...
随机推荐
- 使用echarts-for-react 绘制折线图 报错:`series.type should be specified `
解决办法: 在动态获取值的函数前面加 访问器属性 get ,去获取对象的属性 @inject('commonStore', 'reportUIStore') @observer class Line ...
- Shell 自动安装 JDK
1. 脚本文件 installjdk.sh 注意: EOF 前后不能有空格 #!/bin/bash BASE_SERVER=192.168.1.11 yum install -y wget wget ...
- linux 下nginx 集群CAS单点登录实现
1.单点登录服务器CAS应用配置于tomcat下. 1)key生成: keytool -genkey -alias mycas -keyalg RSA -keysize 2048 -keystore ...
- Java基础7-异常;jar包
昨日内容回顾 多态:多种状态,多态的前提条件是继承或者是实现 面向接口编程 降低耦合度 接口是最低标准,接口可以多重继承 接口中的所有方法都是抽象方法 抽象类中可以没有抽象方法 匿名内部类对象 将对类 ...
- POJ 1251 Jungle Roads (最小生成树)
题目: Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign ...
- flex使内部内容自适应宽度
- 解决Eclipse启动时报Initializing Java Tooling异常信息
1.启动Eclipse报错:An internal error occurred during: "Initializing Java Tooling".java.lang.Nul ...
- 洛谷P3398 仓鼠找suger
传送门啦 思路: 那么从 $ A $ 到 $ B $ 可以分解成 先从 $ A $ 到 $ X $ 再从 $ X $ 到 $ B $ ... 另一个同理 假设能相遇 那么 要么在 $ A $ 到 $ ...
- Discovery Scanning
1.NetDiscover you performe layer 2 the comand : netdiscover -r 192.168.2.0/24 or use netdiscove ...
- Main Thread Checker 问题解决
1. without a return value https://developer.apple.com/documentation/code_diagnostics/main_thread_che ...