MSDN | Windows Development Tutorials

Learn to build powerful .NET Core applications for Windows.

Getting Started with .NET Core on Windows

This tutorial will guide you through setting up your environment and creating your first .NET Core application on Windows. We'll cover installation, basic project structure, and running your application.

1. Prerequisites

2. Installing the .NET SDK

Download the latest .NET SDK from the official dotnet.microsoft.com. Make sure to select the correct version for Windows (x64 or ARM64).

Follow the on-screen instructions for a standard installation.

3. Creating Your First .NET Core Application

You can create applications using either Visual Studio or the .NET CLI.

Using Visual Studio:

  1. Open Visual Studio.
  2. Click "Create a new project".
  3. Search for "Console App" and select the C# template.
  4. Click "Next".
  5. Enter your project name (e.g., MyFirstWindowsApp) and choose a location.
  6. Select the desired .NET version (e.g., .NET 8.0).
  7. Click "Create".

Using the .NET CLI:

Open a command prompt or PowerShell and run the following commands:

dotnet new console -o MyFirstWindowsApp
cd MyFirstWindowsApp

4. Exploring the Project Structure

Your project will typically contain:

5. Running Your Application

In Visual Studio, press F5 or click the "Run" button.

Using the .NET CLI, run:

dotnet run

You should see the output:

Hello, World!

Congratulations! You've successfully created and run your first .NET Core application on Windows.

Next: Building a Desktop Application

Building a Windows Desktop Application with WPF

Learn how to create native Windows desktop applications using Windows Presentation Foundation (WPF) and .NET Core.

1. Creating a WPF Project

Using Visual Studio, create a new project and search for "WPF App".

dotnet new wpf -o MyWpfApp
cd MyWpfApp

2. Understanding WPF Concepts

3. Designing Your UI

Edit the MainWindow.xaml file to define your window's layout and controls.

<Window x:Class="MyWpfApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:MyWpfApp"
        mc:Ignorable="d"
        Title="My WPF App" Height="450" Width="800" WindowStartupLocation="CenterScreen">
    <Grid Margin="10">
        <TextBlock Text="Welcome to WPF on .NET Core!"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontSize="24"
                   Foreground="{StaticResource PrimaryBrush}"/>
    </Grid>
</Window>

You'll need to define PrimaryBrush in your App.xaml or resources.

4. Adding Interactivity

Modify MainWindow.xaml.cs to handle events and logic.

// MainWindow.xaml.cs
using System.Windows;

namespace MyWpfApp
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

5. Building and Running

Build your project in Visual Studio or use the CLI:

dotnet build
dotnet run

Explore the official Microsoft Docs for Windows Desktop for more advanced topics.

Next: Deploying Your Application

Deployment Options for .NET Core on Windows

Understand how to deploy your .NET Core applications to Windows users.

1. Framework-Dependent Deployment (FDD)

To publish:

dotnet publish -c Release -f net8.0-windows --runtime win-x64 --self-contained false

2. Self-Contained Deployment (SCD)

To publish:

dotnet publish -c Release -f net8.0-windows --runtime win-x64 --self-contained true

3. MSI Installer

For a professional installation experience, create an MSI installer using tools like:

This allows for standard Windows installation, uninstallation, and updates.

4. ClickOnce Deployment

A simpler deployment technology for applications deployed over a network (HTTP/FTP) or from removable media. Supports automatic updates.

5. Packaging for Microsoft Store

Package your application using MSIX for distribution through the Microsoft Store, offering modern deployment and update capabilities.

For more details, visit the official .NET Deployment documentation.