Stephen A. Fuqua (saf)

a Bahá'í, software engineer, and nature lover in Austin, Texas, USA

Preparing for PowerShell Core and .NET Development on Ubuntu on Windows

Goal: setup PowerShell Core and .NET for development in Ubuntu running in Windows subsystem for Linux (WSL). And a few other tools.

Motivation: porting PowerShell scripts for .NET development on Linux, thus enabling more programmers to develop on a certain codebase and enabling use of Linux-based containers for continuous integration and testing.

1. Install Ubuntu and PowerShell (Core) 7

Read Install PowerShell 7 On WSL and Ubuntu, which nicely covers not only PowerShell but WSL as well. Be sure to download the powershell-?.?.?-linux-x64.tar.gz file for a typical Windows machine.

TIP: the author shows use of a pre-release over version 7. Head over to the GitHub repo’s release page to find the latest relevant release.

If you want to verify the SHA256 hash after download, then run the following in your Bash prompt:

openssl sha256 <file>

2. Install .NET

First, make sure you know which Ubuntu distribution version you have with this command:

lsb_release -a

Now read Install the .NET SDK or the .NET Runtime on Ubuntu. Make sure you follow both sets of instructions for your version: the instruction that has you download a .deb file, and the instructions for installing the SDK.

The examples in this article show installation of .NET Framework 6.0. You can easily change the commands to 5.0 or 3.1 as needed.

3. Git

See Get started using Git on Windows Subsystem for Linux

4. Bonus: Install Custom Certificate

Most users will not have this situation… needing to install a custom certificate in WSL, e.g. for a corporate network.

Assuming you have the certificate file, you’ll need to know which kind of file you have. Not sure? See What are the differences between .pem, .cer and .der?

Now install it, with help from How do I install a root certificate?.

5. Try It Out

I have previously cloned Ed-Fi AdminApp into c:\source\edfi\AdminApp on my machine. Instead of re-cloning it into the Linux filesystem, I’ll use the Windows version (caution: you could run into line feed problems this way; I have my Windows installation permanently set to Linux-style LF line feeds).

cd /mnt/c/source/edi/AdminApp
git fetch origin
git checkout origin/main
pwsh ./build.ps1

And… the build failed, but that is hardly surprising, given that no work has been done to support Linux in this particular build script. Tools are in place to start get this fixed up.

Screenshot of terminal window

Posted with : DevOps Tools and Practices, Tech, General Programming, Linux, Windows

Comments