Environment Setup, Projects and the dotnet CLI

2.1 Install

Visual Studio with the workloads: *.NET desktop development*, optionally *ASP.NET and web development* and *Data storage and processing*.

The .NET SDK comes with VS, or from dot.net. Check with dotnet --list-sdks.

Optional: SQL Server LocalDB, SQLite, Git, Windows Terminal.

2.2 dotnet CLI Essentials

dotnet new list --language VB
dotnet new sln -n Shop
dotnet new console  -lang VB -n Shop.Cli
dotnet new classlib -lang VB -n Shop.Core
dotnet new winforms -lang VB -n Shop.Desktop
dotnet new wpf      -lang VB -n Shop.Wpf
dotnet new mstest   -lang VB -n Shop.Tests
dotnet new worker   -lang VB -n Shop.Worker        # if the template is available; otherwise use console + hosting
dotnet sln add **/*.vbproj
dotnet add Shop.Cli reference Shop.Core
dotnet add Shop.Core package Microsoft.Extensions.Logging.Abstractions
dotnet build -c Release
dotnet run --project Shop.Cli -- arg1 arg2
dotnet test
dotnet publish Shop.Cli -c Release -r win-x64 --self-contained
dotnet format                                     # code style fixes (VB supported)

2.3 Project File Anatomy (SDK-Style .vbproj)

Directory.Build.props at the solution root shares settings (Option Strict, warnings, versions) across all projects.

Central Package Management: Directory.Packages.props with <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>       <!-- net8.0-windows for WinForms/WPF -->
    <RootNamespace>Shop.Cli</RootNamespace>
    <OptionStrict>On</OptionStrict>
    <OptionExplicit>On</OptionExplicit>
    <OptionInfer>On</OptionInfer>
    <OptionCompare>Binary</OptionCompare>
    <LangVersion>latest</LangVersion>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <Nullable>disable</Nullable>                    <!-- not supported for VB -->
    <Version>1.0.0</Version>
  </PropertyGroup>
  <ItemGroup>
    <Import Include="System.Text.Json" />           <!-- project-wide Imports -->
    <PackageReference Include="Dapper" Version="2.1.35" />
    <ProjectReference Include="..\Shop.Core\Shop.Core.vbproj" />
  </ItemGroup>
</Project>

2.4 Visual Studio Productivity

IntelliSense, Quick Actions (Ctrl+.), snippets (Property + Tab), Go To Definition (F12), Find All References (Shift+F12), Rename (Ctrl+R, Ctrl+R), Peek Definition (Alt+F12), Code Cleanup profiles, .editorconfig, CodeLens, Git integration, Hot Reload (for supported scenarios).