Friday, September 30, 2022
Visual Studio: Disable Map Mode
Sunday, September 11, 2022
C#: xUnit Testing Constructor Exceptions
xUnit's Assert class implements the following methods that test whether or not a method throws an exception:
The Throws method signatures that take a parameter of type Action are used to test methods that return no value (void). The Throws method signatures that take a parameter of type Func are used to test methods that return a value. In order to test a constructor that throws an exception, a lambda expression is required such as:
The lambda expressions above return no values, so the Throws method that takes an Action parameter is invoked by the above code (public static T Throws<T>(Action testCode) where T : Exception).
Friday, September 9, 2022
Git: Get Submodules from an already Cloned Repo
A git repo that contains a submodule or modules is cloned using the --recurse-submodules command-line option such as the following:
At one time or another, every developer has performed a git clone and forgotten the --recurse-submodules command-line option. The following git command will remedy this problem but updating the submodules for a git repo ever in the case where the git clone was performed without specifying --recurse-submodules:
git submodule update --init --recursive
Sunday, September 4, 2022
cmake: ExternalProject_Add Ignore the INSTALL_COMMAND
The cmake function ExternalProject_Add is documented at ExternalProject. There are circumstances when ExternalProject_Add's install command needs to be disabled. The simplest way to disable the install command is to set the parameter to an empty string as follows:
Docker/Ubuntu: Installing the latest cmake on Docker Image
This post demonstrates how to install the latest version of cmake during docker build targetting an Ubuntu 20.04 image. The Dockerfile for such an image starts with:
A previous post, Ubuntu: Upgrade to the latest cmake, demonstrated the bash commands that could be used to install the latest version of cmake on an Ubuntu 20.04.4 LTS image. Fundamentally these are the same commands that could be used to install cmake on a Docker image during build. From the previously demonstrated script, the sudo commands were removed a few additional apt-get commands are required.
A sample Dockerfile that installs the latest cmake (currently 3.24.1) on an Ubuntu 20.04 image is follows:
FROM ubuntu:20.04
Ubuntu/Azure: Upgrade an Ubuntu 20.04.4 LTS VM to the latest cmake
This post demonstrates how to install the latest version of cmake on an Azure Ubuntu 20.04.4 LTS virtual machine (VM).
In the post, Ubuntu: Upgrade to the latest cmake, the steps required to install the latest version of cmake on Ubuntu 20.04.4 LTS were presented. These aforementioned steps apply to environments like running Ubuntu under WSL where the native Ubuntu image was used to create the virtual machine or image. Multiple bash commands were required to install cmake and similarly, the uninstall required multiple bash commands.
Azures Ubuntu 20.04.4 LTS VMs contain additional packages to that of a stock Ubuntu image. These packages include Snap, a popular package manager. Using Snap the latest version of cmake can be installed as follows:
sudo snap install cmake --classic
The output from the above install steps is shown below where the version of cmake (3.24.1) is displayed during installation:
Using apt-get to install cmake will get Ubuntu's version of cmake which is not the latest version of cmake. This means that features like DOWNLOAD_NO_EXTRACT will not be available to cmake.
The steps to uninstall cmake using the snap command are as follows:
Appendix A: Snap
Friday, September 2, 2022
Ubuntu: Upgrade to the latest cmake
Ubuntu 20.04.4 LTS allows cmake to be installed as follows using -y to suppress the prompt:
The cmake installed is not the latest version as can be seen using cmake --version:
To install the latest version of cmake, first uninstall cmake (if it is already installed and that it was installed using apt-get):
Latest cmake Install
The following script downloads and installs a specific version of cmake (version 3.24.1):