Connect, learn, share, and engage with IBM Power.
If you have been struggling to generate a .NET 7 tarball from source code, this blog is for you. You may have wondered why you cannot directly compile it on Power to generate SDK? The reason is that the compiler code itself is written in C# . So, you have to first cross build all required repositories and generate the .NET SDK tarball for Power on an x86 machine. You can then install this tarball on a Power virtual machine (VM) and use .NET for development.
Follow this step-by-step guide to cross build .NET 7 on IBM Power.
Download the dotnet7 folder from: https://github.com/ppc64le/build-scripts/tree/master/d/dotnet7. This folder contains all required scripts and patches for cross building.
Install ppc64el architecture specific packages on an x86 machine for cross compiling .NET. Before installing the ppc64el packages, update the /etc/apt/sources.list file with following content:
deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic main restricted deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic main restricted
deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted
## Note, this file is written by cloud-init on first boot of an instance ## modifications made here will not survive a re-bundle. ## if you wish to make changes you can: ## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg ## or do the same in user-data ## b.) add sources in /etc/apt/sources.list.d ## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to # newer versions of the distribution. deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic main restricted deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic main restricted ## Major bug fix updates produced after the final release of the ## distribution. deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates main restricted deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team. Also, please note that software in universe WILL NOT receive any ## review or updates from the Ubuntu security team. deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic universe deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic universe deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic universe deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates universe deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates universe deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu ## team, and may not be under a free licence. Please satisfy yourself as to ## your rights to use the software. Also, please note that software in ## multiverse WILL NOT receive any review or updates from the Ubuntu ## security team. deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic multiverse deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic multiverse deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic multiverse deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates multiverse deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates multiverse deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-updates multiverse ## N.B. software from this repository may not have been tested as ## extensively as that contained in the main release, although it includes ## newer versions of some applications which may provide useful features. ## Also, please note that software in backports WILL NOT receive any review ## or updates from the Ubuntu security team. deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-backports main restricted universe multiverse deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-backports main restricted universe multiverse deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security main restricted deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security main restricted deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security universe deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-security universe deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security universe deb [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security multiverse deb [arch=ppc64el] http://ports.ubuntu.com/ubuntu-ports/ bionic-security multiverse deb-src [arch=amd64] http://mirrors.adn.networklayer.com/ubuntu bionic-security multiverse ## Uncomment the following two lines to add software from Canonical's ## 'partner' repository. ## This software is not part of Ubuntu, but is offered by Canonical and the ## respective vendors as a service to Ubuntu users. # deb http://archive.canonical.com/ubuntu bionic partner # deb-src http://archive.canonical.com/ubuntu bionic partner
#ls dotnet-runtime-7.0.0-linux-ppc64le.tar.gz dotnet-runtime-internal-7.0.0-linux-ppc64le.tar.gz dotnet-sdk-7.0.100-linux-ppc64le.tar.gz Microsoft.AspNetCore.App.Runtime.linux-ppc64le.7.0.0.nupkg Microsoft.AspNetCore.App.Runtime.linux-ppc64le.7.0.0.symbols.nupkg Microsoft.NETCore.App.Host.linux-ppc64le.7.0.0.nupkg Microsoft.NETCore.App.Host.linux-ppc64le.7.0.0.symbols.nupkg Microsoft.NETCore.App.Runtime.linux-ppc64le.7.0.0.nupkg Microsoft.NETCore.App.Runtime.linux-ppc64le.7.0.0.symbols.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHost.7.0.0.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHost.7.0.0.symbols.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHostPolicy.7.0.0.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHostPolicy.7.0.0.symbols.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHostResolver.7.0.0.nupkg runtime.linux-ppc64le.Microsoft.NETCore.DotNetHostResolver.7.0.0.symbols.nupkg runtime.linux-ppc64le.Microsoft.NETCore.ILAsm.7.0.0.nupkg runtime.linux-ppc64le.Microsoft.NETCore.ILDAsm.7.0.0.nupkg
DOTNET_FILE=dotnet-sdk-7.0.100-linux-ppc64le.tar.gz mkdir -p .dotnet export DOTNET_ROOT=$(pwd)/.dotnet tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"
export PATH=$PATH:$DOTNET_ROOT
dotnet --info
$ dotnet --info .NET SDK: Version: 7.0.100 Commit: e12b7af219 Runtime Environment: OS Name: ubuntu OS Version: 18.04 OS Platform: Linux RID: linux-ppc64le Base Path: /home/ubuntu/dotnet7_ga_tarball/output/.dotnet/sdk/7.0.100/ Host: Version: 7.0.0 Architecture: ppc64le Commit: d099f075e4 .NET SDKs installed: 7.0.100 [/home/ubuntu/dotnet7_ga_tarball/output/.dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 7.0.0 [/home/ubuntu/dotnet7_ga_tarball/output/.dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 7.0.0 [/home/ubuntu/dotnet7_ga_tarball/output/.dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: DOTNET_ROOT [/home/ubuntu/dotnet7_ga_tarball/output/.dotnet] global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download ubuntu@dotnet2--2:~/dotnet7_ga_tarball/output$
mkdir HelloWorld cd HelloWorld dotnet new console
$ mkdir HelloWorld $ cd HelloWorld $/HelloWorld$ dotnet new console Welcome to .NET 7.0! --------------------- SDK Version: 7.0.100 ---------------- Installed an ASP.NET Core HTTPS development certificate. To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only). Learn about HTTPS: https://aka.ms/dotnet-https ---------------- Write your first app: https://aka.ms/dotnet-hello-world Find out what's new: https://aka.ms/dotnet-whats-new Explore documentation: https://aka.ms/dotnet-docs Report issues and find source on GitHub: https://github.com/dotnet/core Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli -------------------------------------------------------------------------------------- The template "Console App" was created successfully. Processing post-creation actions... Restoring /home/ubuntu/HelloWorld/HelloWorld.csproj: Determining projects to restore... Restored /home/ubuntu/HelloWorld/HelloWorld.csproj (in 449 ms). Restore succeeded.
dotnet build dotnet run
~/HelloWorld$ dotnet build MSBuild version 17.4.0+18d5aef85 for .NET Determining projects to restore... All projects are up-to-date for restore. HelloWorld -> /home/ubuntu/HelloWorld/bin/Debug/net7.0/HelloWorld.dll Build succeeded. 0 Warning(s) 0 Error(s) Time Elapsed 00:00:15.31 ~/HelloWorld$ dotnet run Hello, World!
In this blog you have learned to cross build .NET 7 on x86 for IBM Power. Now you are ready to install a .NET 7 tarball on a Power VM and use begin using .NET for development.
Copy