.NET, how to create an application without using Visual Studio

.NET is a software development framework that Microsoft makes available to users and programmers by periodically updating it. It is designed to build and run a wide range of applications and provides broad class library and built-in functionality, along with a virtual execution environment (Common Language RuntimeCLR) which manages the execution of the code.

Since mid-2016, Microsoft has also been distributing .NET Core, an open source, cross-platform version of .NET. Designed to be modular, lighter and more flexible than the .NET Framework traditional, .NET Core is compatible with various platforms, including Windows, macOS and various Linux distributions.

Develop a .NET application without installing Visual Studio

Visual Studio is an integrated development environment (Integrated Development Environment, IDE) developed by Microsoft. It’s a tool software development extremely popular that provides a wide range of features for writing, compiling, debugging and distributing your own programs. The Visual Studio Community version is completely free and can be downloaded, installed and used without particular limitations.

Did you know, however, that it is possible develop .NET applications even from the Windows command prompt or terminal window without installing the Visual Studio IDE? As an alternative, it is advisable to use thefree editor Visual Studio Code but any text editor can be used instead.

What is the .NET CLI and how does it work

.NET Command-Line Interface (CLI) is a command line-based tool, therefore without any graphical interface, which allows you to develop, compile, test and distribute .NET applications. It is an integral part of the .NET Core package and allows developers to interact with .NET projects using the terminal window.

Per develop a .NET application However, without using Visual Studio, you must have installed the .NET SDK package. Typing cmd in the Windows search box then pressing Enter and finally issuing the command dotnet --versionthe number of must appear SDK package version.

With the CLI dotnetthey can be created new .NET Core projects using the command dotnet new. With dotnet build you can compile the code project source and create an executable or distributable implementation of your .NET application. With the command dotnet runand launch the application compiled directly from the terminal.

Finally, the command dotnet add package allows you to add any additional packages necessary for the correct functioning of the application to the project.

Create the basic structure of the .NET application

The following command allows you to create the basic structure for a Windows Forms application.

dotnet new winforms -n NomeProgetto

In our case we want to create a very simple application that extracts some information about system configuration. We will then use the following syntax to set up a called application SystemInfo:

dotnet new winforms -n SystemInfo

By default, the application is set up using the C# language. Who would prefer to use, for example, Visual Basic can use the following syntax:

dotnet new winforms --language VB -n SystemInfo

However, it should be kept in mind that the code we provide below will necessarily have to be rewritten to adapt it to the Visual Basic syntax.

With the following command you move inside the project folderwhich in the meantime was created:

cd SystemInfo

.NET, develop Windows program

How to edit the basic project

Assuming you have already installed Visual Studio Codeby typing the following simple command at the prompt, the Microsoft editor will open all the files that make up the project being developed and allow them to be modified:

code .

When the request appears Do you trust the authors of the files in this folderjust click on the button Yes, I trust the authors.

Edit .NET Core application

In the file Form1.csthe class is located Form1 which represents the main form of the application. Here you can work on the code to add, for example, fields, buttons and change the window title bar. Try replacing the C# code present with what we present below:

using System;
using System.Windows.Forms;
using System.Management;
namespace ConfigApp
public partial class Form1 : Form
private TextBox textBoxConfig;
public Form1()
this.Text = “Configurazione hardware e software”;
private void InitializeTextBox()
textBoxConfig = new TextBox();
textBoxConfig.Multiline = true;
textBoxConfig.ScrollBars = ScrollBars.Vertical;
textBoxConfig.Dock = DockStyle.Fill;
private void DisplaySystemConfig()
ManagementObjectSearcher searcher = new ManagementObjectSearcher(“SELECT * FROM Win32_OperatingSystem”);
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject obj in collection)
textBoxConfig.Text += “OS Name: ” + obj[“Caption”] + Environment.NewLine;
textBoxConfig.Text += “Versione OS: ” + obj[“Version”] + Environment.NewLine;
// Add any other parameters you want to display
private void DisplayHardwareConfig()
ManagementObjectSearcher searcher = new ManagementObjectSearcher(“SELECT * FROM Win32_Processor”);
ManagementObjectCollection collection = searcher.Get();
textBoxConfig.Text += “Dettagli Hardware:” + Environment.NewLine;
foreach (ManagementObject obj in collection)
textBoxConfig.Text += “Processore: ” + obj[“Name”] + Environment.NewLine;
// Add other processor details if necessary
searcher = new ManagementObjectSearcher(“SELECT * FROM Win32_VideoController”);
collection = searcher.Get();
foreach (ManagementObject obj in collection)
textBoxConfig.Text += “GPU: ” + obj[“Name”] + Environment.NewLine;
// Add more details about the video card if necessary
// You can add additional WMI searches for other hardware components such as hard disk, network card, etc.

By pressing the key combination CTRL+Sit’s possible save the changes made to the file Form1.cs.

How to compile the application and run it

The following commands, always issued using the terminal window, allow you to add the package System.Management To access system information, compile the newly developed test application (build) and run it:

dotnet add package System.Management
dotnet build
dotnet run

Compile .NET app and run it

Now, if you try to copy all the files contained in the subfolder bin\debug on another Windows system, then run the executable file SystemInfo.exe created from the .NET Core CLI, you will notice that your application will run smoothly.

.NET Core bin folder

Opening image credit: iStock.com/Yumi mini


Please enter your comment!
Please enter your name here