| description | .NET Guide |
|---|---|
| sidebar_position | 9 |
Semaphore Ubuntu images include the .NET SDK and PowerShell.
This page shows how to inspect installed versions, build .NET projects, and run tests.
Use the following commands to inspect available .NET and PowerShell versions:
dotnet --info
dotnet --list-sdks
dotnet --list-runtimes
pwsh --versionThe following example restores dependencies and builds a project in Release mode:
version: v1.0
name: .NET pipeline
agent:
machine:
type: f1-standard-2
os_image: ubuntu2404
blocks:
- name: Build
task:
jobs:
- name: Build application
commands:
- checkout
- dotnet --info
- dotnet restore
- dotnet build --configuration Release --no-restoreUse dotnet test to execute your test suite:
version: v1.0
name: .NET tests
agent:
machine:
type: f1-standard-2
os_image: ubuntu2404
blocks:
- name: Test
task:
jobs:
- name: Run tests
commands:
- checkout
- dotnet restore
- dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-buildPowerShell is available as pwsh.
Example:
version: v1.0
name: .NET with PowerShell
agent:
machine:
type: f1-standard-2
os_image: ubuntu2404
blocks:
- name: Run PowerShell
task:
jobs:
- name: PowerShell script
commands:
- checkout
- pwsh -Command "Get-ChildItem"
- pwsh -File ./scripts/build.ps1The following pipeline restores dependencies, builds the application, and runs tests:
version: v1.0
name: .NET example
agent:
machine:
type: f1-standard-2
os_image: ubuntu2404
blocks:
- name: Build and test
task:
jobs:
- name: .NET
commands:
- checkout
- dotnet --info
- dotnet restore
- dotnet build --configuration Release --no-restore
- dotnet test --configuration Release --no-buildIf your repository contains a solution file, you can target it explicitly:
dotnet restore MyApp.sln
dotnet build MyApp.sln --configuration Release --no-restore
dotnet test MyApp.sln --configuration Release --no-build