Create C# Console App With PowerShell

In this blog post, we will show you how to create a C# console app with PowerShell. We will walk you through the steps required to get your project up and running and explain some of the key concepts involved.

C# is a powerful programming language that can be used for a variety of different applications. With PowerShell, you can easily create C# console apps that are both efficient and easy to use.

Code

Using PowerShell to create your app helps keep things consistent and prevent configuration mistakes.

The code below uses variables to create the app, to run, first set the variables or use the default values. the script will create the app in the directory you run it from.

The script also displays the latest .NET version that is installed on the machine.

$temp = dotnet --list-sdks | select -Last 1
$framework = "net6.0"
$mynetver = $temp.split()
$mynetver[0]
$appname = "myconsole"

dotnet new console -lang c# -n $appname  -f $framework
dotnet new sln -o $appname
dotnet sln $appname add $appname

About C#

.NET C# is a powerful programming language that can be used for a variety of different applications. With C#, you can easily create efficient and easy-to-use console apps. C# is also part of the .NET framework, which provides a variety of features and tools that make development easier than ever.


Posted

in

, ,

by