Analysis of the Compilation Problem of. NET Core Source Code

  • 2021-11-29 23:27:09
  • OfStack

Introduction:. NET Core source code compilation

https://github.com/dotnet

git clone https://github.com/dotnet/runtime.git

1: Windows compilation

VS 2019 16.6 (Do not install preview version) Win 10 Professional Edition, Latest Edition (1903/2004) Long Path Support: Group Policy (gpedit. msc) > Computer configuration > Management template > System > File system > Enable Win32 long path Git Long Path: git config--system core. longpaths true The latest official version of CMake http://www.cmake.org/download The latest official version of Python Compile instructions:

./build -subset Clr
./build -subset Libs
./build -subset Installer

2: Linux compilation

1. Ubuntu 18.04 LTS (Docker/VM/vps) Memory at least 1G

2. Environment:


# 1.  Install the following packages 
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget

# 2.  Get the signing key 
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add -

# 3.  Will kitware The repository is added to the source list and updated. 
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update

# 4.  Installation  kitware  Key update package 
sudo apt-get install kitware-archive-keyring

# 5.  Dependent package 
sudo apt-get install cmake llvm-9 clang-9 autoconf automake libtool build-essential python curl git lldb-6.0 liblldb-6.0-dev libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libssl-dev libnuma-dev libkrb5-dev

#  Coding (optional)  bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
apt-get install locales

3. Cloning the source repository

4. Compile instructions:


./build -subset Clr
./build -subset Libs
./build -subset Installer

5. Installation runtime:


#  In /usr/share Create dotnet Directory 
mkdir -p /usr/share/dotnet
#  Next, unpack the runtime 2 Binary compression package to this newly created directory 
tar zxf /home/runtime/artifacts/packages/Debug/Shipping/dotnet-runtime-5.0.0-dev-linux-x64.tar.gz -C /usr/share/dotnet
#  Create a soft connection to bin Directory 
ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
#  Test 
dotnet --info

6. SDK installation:


#  First, the   Microsoft   To the list of trusted keys 
wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
#  Then, add the package repository 
dpkg -i packages-microsoft-prod.deb
#  Update source 
apt-get update
#  Installation .NET SDK 3.1
apt-get install -y dotnet-sdk-3.1
#  Look 1 Next version information 
dotnet --info

Related articles: