Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Core .NET and C# skills for coding agents.

## LSP

This plugin declares a C# LSP server that is launched through the .NET CLI.
This plugin declares a C# LSP server that is installed through the .NET CLI.
Comment thread
JoeRobich marked this conversation as resolved.
Outdated

Prerequisites:
- .NET SDK installed
- .NET 10 SDK installed
- `dotnet` available on PATH
Comment thread
JoeRobich marked this conversation as resolved.
Outdated
Comment thread
JoeRobich marked this conversation as resolved.
Comment thread
JoeRobich marked this conversation as resolved.

## Skills
Expand Down
13 changes: 13 additions & 0 deletions plugins/dotnet/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"hooks": {
"sessionStart": [
Comment thread
JoeRobich marked this conversation as resolved.
Outdated
{
"type": "command",
"bash": "./scripts/session-start.sh",
"powershell": "./scripts/session-start.ps1",
"timeoutSec": 30
}
]
}
}
9 changes: 2 additions & 7 deletions plugins/dotnet/lsp.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
{
"lspServers": {
"csharp": {
"command": "dotnet",
"command": "roslyn-language-server",
"args": [
Comment thread
JoeRobich marked this conversation as resolved.
Outdated
"dnx",
"roslyn-language-server",
"--yes",
"--prerelease",
"--",
"--stdio",
"--autoLoadProjects"
],
Expand All @@ -16,4 +11,4 @@
}
}
}
}
}
84 changes: 84 additions & 0 deletions plugins/dotnet/scripts/session-start.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#Requires -Version 5.1
<#
.SYNOPSIS
Initializes the development session by ensuring the roslyn-language-server tool is installed and up to date.
.DESCRIPTION
Creates a temporary working directory for the session and installs or updates the
roslyn-language-server .NET global tool to the latest prerelease version.
#>
[CmdletBinding()]
param()

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$ToolName = 'roslyn-language-server'
$NuGetSource = 'https://api.nuget.org/v3/index.json'

function New-SessionDirectory {
$dir = New-Item -ItemType Directory -Path (Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString()))
Write-Verbose "[$ToolName] Created temp directory: $($dir.FullName)"
Set-Location -Path $dir.FullName
return $dir
}

function Write-GlobalJson {
param([string]$Directory)

@{
sdk = @{
version = '10.0.100'
rollForward = 'latestMajor'
}
} | ConvertTo-Json -Depth 3 | Set-Content -Path (Join-Path $Directory 'global.json') -Encoding utf8
Write-Verbose "[$ToolName] Wrote global.json pinning SDK to 10.0.100 (rollForward: latestMajor)"
}

function Get-InstalledToolVersion {
param([string]$Name)

$toolList = dotnet tool list --global
$installedEntry = $toolList | Select-String -Pattern $Name
if ($installedEntry) { ($installedEntry -split '\s+')[1] } else { $null }
}

function Get-LatestToolVersion {
param([string]$Name, [string]$Source)

$searchJson = dotnet package search $Name --source $Source --exact-match --prerelease --format json | ConvertFrom-Json
$packages = $searchJson.searchResult | ForEach-Object { $_.packages } | Where-Object { $_.id -eq $Name }
if ($packages) { ($packages | Select-Object -Last 1).version } else { $null }
}

function Install-OrUpdateTool {
$currentVersion = Get-InstalledToolVersion -Name $ToolName

if ($currentVersion) {
Write-Host "[$ToolName] Installed version: $currentVersion"

$latestVersion = Get-LatestToolVersion -Name $ToolName -Source $NuGetSource

if (-not $latestVersion) {
Write-Warning "[$ToolName] Unable to determine the latest version. Skipping update."
return
}

Write-Host "[$ToolName] Latest available version: $latestVersion"

if ($currentVersion -ne $latestVersion) {
Write-Host "[$ToolName] Updating from $currentVersion to $latestVersion..."
dotnet tool update --global --prerelease $ToolName --add-source $NuGetSource
Comment thread
JoeRobich marked this conversation as resolved.
Outdated
Write-Host "[$ToolName] Update complete."
} else {
Write-Host "[$ToolName] Already up to date."
}
} else {
Write-Host "[$ToolName] Not found. Installing latest prerelease..."
dotnet tool install --global --prerelease $ToolName --add-source $NuGetSource
Write-Host "[$ToolName] Installation complete."
}
}

$tempDir = New-SessionDirectory
Write-GlobalJson -Directory $tempDir.FullName
Install-OrUpdateTool
80 changes: 80 additions & 0 deletions plugins/dotnet/scripts/session-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
#
# Initializes the development session by ensuring the roslyn-language-server
# tool is installed and up to date.

set -euo pipefail

TOOL_NAME="roslyn-language-server"
NUGET_SOURCE="https://api.nuget.org/v3/index.json"

create_session_directory() {
local dir
dir="$(mktemp -d)"
echo "[$TOOL_NAME] Created temp directory: $dir" >&2
cd "$dir"
echo "$dir"
}

write_global_json() {
local dir="$1"
cat > "$dir/global.json" <<'EOF'
{
"sdk": {
"version": "10.0.100",
"rollForward": "latestMajor"
}
}
EOF
echo "[$TOOL_NAME] Wrote global.json pinning SDK to 10.0.100 (rollForward: latestMajor)" >&2
}

get_installed_version() {
local name="$1"
dotnet tool list --global | grep -i "$name" | awk '{print $2}' || true
}

get_latest_version() {
local name="$1"
local source="$2"
local search_json
search_json=$(dotnet package search "$name" --source "$source" --exact-match --prerelease --format json)
echo "$search_json" | jq -r \
--arg name "$name" \
'.searchResult[].packages[] | select(.id == $name) | .version' | tail -1
}

install_or_update_tool() {
local current_version
current_version=$(get_installed_version "$TOOL_NAME")

if [[ -n "$current_version" ]]; then
echo "[$TOOL_NAME] Installed version: $current_version"

local latest_version
latest_version=$(get_latest_version "$TOOL_NAME" "$NUGET_SOURCE")

if [[ -z "$latest_version" ]]; then
echo "[$TOOL_NAME] WARNING: Unable to determine the latest version. Skipping update." >&2
return
fi

echo "[$TOOL_NAME] Latest available version: $latest_version"

if [[ "$current_version" != "$latest_version" ]]; then
Comment thread
JoeRobich marked this conversation as resolved.
Outdated
echo "[$TOOL_NAME] Updating from $current_version to $latest_version..."
dotnet tool update --global --prerelease "$TOOL_NAME" --add-source "$NUGET_SOURCE"
echo "[$TOOL_NAME] Update complete."
else
echo "[$TOOL_NAME] Already up to date."
fi
else
echo "[$TOOL_NAME] Not found. Installing latest prerelease..."
dotnet tool install --global --prerelease "$TOOL_NAME" --add-source "$NUGET_SOURCE"
echo "[$TOOL_NAME] Installation complete."
fi
}

temp_dir=$(create_session_directory)
write_global_json "$temp_dir"
install_or_update_tool