Skip to content

jkristia/cs-hello-world-cross-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cross-Platform C# Hello World

A minimal .NET 10 console app that can be built, run, debugged, tested, and published as native executables for macOS and Windows from macOS or Windows using VS Code and Make.

Layout

  • app/src: primary C# console app (positioned here so additional stacks like Python or Node can live alongside later).
  • tests/HelloWorld.Tests: xUnit test project validating the shared logic.
  • publish: output folder populated by the Makefile publish targets.

Requirements

  • .NET SDK 10.0.101 (project targets net10.0; update global.json if you install a different SDK)
  • VS Code with the official C# extension
  • make available in your shell (preinstalled on macOS, available through WSL or Git Bash on Windows)

Initial Setup

make restore

This restores NuGet packages for both the app and the test project.

Common Tasks

Command Purpose
make build Build the console app in Debug mode
make run Build and run the app
make test Run the xUnit test project (prints a reminder if the test project is removed)
make clean Clean build artifacts and publish output
make publish-macos Produce a self-contained, single-file macOS ARM64 binary in publish/macos
make publish-windows Produce a self-contained, single-file Windows x64 binary in publish/windows
make publish-linux-arm Produce a self-contained, single-file Linux ARM64 binary in publish/linux
make publish Publish for macOS, Windows, and Ubuntu/Linux

All make targets operate on app/src/cstest.csproj via the PROJECT variable. If you rename or relocate the project again, run make build PROJECT=relative/path/to.csproj or update the default in the Makefile.

You can override defaults, for example:

make build CONFIG=Release
make publish-macos RUNTIME_OSX=osx-x64

VS Code Integration

  • dotnet: build and dotnet: run tasks are defined in .vscode/tasks.json.
  • The .NET Launch configuration in .vscode/launch.json uses the build task before debugging so it works on both macOS and Windows without further setup.
  • Tests and publish tasks are also available through the VS Code task runner (⇧⌘B / Ctrl+Shift+B).

Publishing

The Makefile uses dotnet publish with --self-contained true, -p:PublishSingleFile=true, and -p:UseAppHost=true so the generated binaries do not require a shared runtime and satisfy the .NET single-file requirements.

  • macOS output: publish/macos/cstest
  • Windows output: publish/windows/cstest.exe
  • Linux ARM output: publish/linux/cstest (defaults to linux-arm64)

Adjust RUNTIME_OSX, RUNTIME_WIN, or RUNTIME_LINUX if you need different architectures (for example osx-x64, win-arm64, linux-x64).

Testing

A lightweight xUnit project lives under tests/HelloWorld.Tests and verifies the message builder logic. Run it with make test or the dotnet: test VS Code task.

Troubleshooting

  • If dotnet is missing or you have a different SDK installed, either install 10.0.101 or adjust global.json to the version you have before rerunning make restore.
  • Update the program path in .vscode/launch.json if you rename the project folder, since the DLL name matches the folder name.
  • Platform-specific setup tips for Windows/Linux (extra PATH entries, drive mapping, etc.) now live in .github/copilot-instructions.md to keep this README lean.

About

CoPilot generated "Hello World" C# project. Runs on macOS, Windows and Linux.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors