Thursday, March 31, 2022
Google Sheets: Pasting Delimited Data
Tuesday, March 15, 2022
Docker on Windows: Update Merged to Main
Wednesday, March 2, 2022
Docker/Visual Studio: Two Updates Merged to Master "Visual Studio Container Tools for Docker"
Microsoft has signed off on two of my edits to the documentation page Visual Studio Container Tools for Docker:
Wednesday, February 9, 2022
Docker: Containerizing a Visual Studio 2022 .NET Core Console Application with Docker
When a .NET 6, ASP.NET Core project is created by Visual Studio 2022 an "Enable Docker" checkbox is provided as part of the project creation wizard. Simply checking the "Enable Docker" checkbox adds Docker support to the ASP.NET core web application.
Other Visual Studio 2022 project types including .NET Core console projects are not afforded the option to enable Docker support during project creation. This post demonstrates how to add Docker support to a Windows .NET Core console application support created with Visual Studio 2022. Additionally this post will drill down into the changes made the project and solution when Docker support is added.
Microsoft does provide an excellent tutorial on how to create a .NET Core console application using Visual Studio Code, Tutorial: Containerize a .NET app. The aforementioned tutorial shows there are significantly more manual steps to Dockerize a console project using Visual Studio Code compared to Visual Studio 2022 (just a few clicks).
The steps to add Docker support to a console application are as follows:
1) Create a .NET Core console application (see: Docker: Create a .NET Core (.NET 6) Console Application in Visual Studio 2022 for future Containerization)
2) Setup the console application to be published (see: Docker: Publishing a .NET Core (.NET 6) Console Application with Visual Studio 2022 (a Containerization Prereq)). Technically a Docker Support can be added without configuring publish for the project but it is cleaner to configure publishing for the project.
3) Right click on the .NET Core console project in Solution Explorer (project ForensicDataPusher) and select Add | Docker Support:
4) Once Add | Docker Support is selected the Docker File Options dialog is displayed:
Changes Made by invoking "Docker support"
The startup project command changed from ForensicDataPusher (build the solution) to Docker (deploy to Docker).
The ForensicDataPusher .csproj is changed as follows (see the line demarcated in boldface)
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>
Docker: Publishing a .NET Core (.NET 6) Console Application with Visual Studio 2022 (a Containerization Prereq)
Before a Docker image can be created that hosts an application (such as a console app created with Visual Studio 2022), the artifacts (files) needed to run the application must be created. The process for creating the artifcatds needed to run an application is called publishing. Simply put, an application must be published before it can be copied to a Docker image and the application subsequently containerized.
The console application to be published was created in the post Docker: Create a .NET 6 Console Application in Visual Studio 2022 for future Containerization. The newly created project and the solution that contains the project are as follows (opened in Visual Studio 2022):
Configure Publishing
Publishing
Publishing Configuration File
Publish Folder
Tuesday, February 8, 2022
Visual Studio: Displaying all Files in Solution Explorer
By default Visual Studio's Solution Explorer only displays the files that are contained in projects or in the solution. An example of Solution Explorer from Visual Studio 2022 is as follows:
The previous solution (ForensicDataPusher) contains a console application project named ForensicDataPusher. Solution Explorer does not show, by default, folders such as bin or obj.
The toolbar at the top of Solution Explorer contains a "Show all Folders" icon:
Hovering over the icon displays its function via a tooltip:
Clicking on the "Show All Files" icon displays all files and folders solution's folder (as follows):
Docker: Create a .NET Core (.NET 6) Console Application in Visual Studio 2022 for future Containerization
In this post, a .NET Core (.NET 6) console application will be created using Visual Studio 2022. In a later post, this console application will be containerized with Docker.
The steps to create a .NET 6 console application with Visual Studio 2022 are as follows:
1) When Visual Studio 2022 is launched the start screen contains a button, "Create a new project." To create a project (including a console application), click on "Create new project:"