Announcing dotnet run app.cs – A simpler way to start with C# and .NET 10

thumbnail

Table of Contents

  1. Introduction
  2. New File-Level Directives
  3. Setting MSBuild Properties
  4. Converting to a Project-Based App
  5. Getting Started
  6. Learn More

Introduction

  • Announces the new dotnet run app.cs capability in .NET 10, allowing running C# files directly without project setup.
  • Introduces file-based apps for quick scripts and experiments, similar to scripting languages.

New File-Level Directives

  • Introduces file-level directives for declaring important aspects in C# files without needing a project file.
  • Includes examples of directives like setting MSBuild properties directly in the file.

Setting MSBuild Properties

  • Shows how to configure build properties using file-level directives for advanced language features and platform targeting.
  • Illustrates setting properties for different language versions and platform configurations.

Converting to a Project-Based App

  • Explains the process of converting a file-based app to a standard project for more advanced capabilities.
  • Describes how to use the dotnet new console command to create a project from an existing C# file.

Getting Started

  • Provides steps to install .NET 10 Preview 4 and update Visual Studio Code for file-based apps support.
  • Guides users on creating a C# file, running it, and converting it to a project when needed.

Learn More

  • Encourages users to watch a demo session showcasing file-based apps in action.
  • Mentions upcoming improvements for file-based apps in VS Code and invites feedback on the feature development on GitHub.