diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 000000000..b06c57878 --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "Azure.Sdk.Tools.SnippetGenerator": { + "version": "1.0.0-dev.20241213.1", + "commands": [ + "snippet-generator" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/nuget.config b/nuget.config index 54e660f9c..3da872e48 100644 --- a/nuget.config +++ b/nuget.config @@ -4,5 +4,6 @@ + \ No newline at end of file diff --git a/scripts/Update-Snippets.ps1 b/scripts/Update-Snippets.ps1 new file mode 100644 index 000000000..6e91fb733 --- /dev/null +++ b/scripts/Update-Snippets.ps1 @@ -0,0 +1,24 @@ +[CmdletBinding()] +param( + [string]$Path +) + +# If this is not a real path, assume snippets should be refreshed in a relative +# path to the OpenAI.csproj file from the git root. +if (-not $Path) { + $_gitRoot = git rev-parse --show-toplevel 2>$null + + if ((-not $_gitRoot) -or ($LASTEXITCODE -ne 0)) { + Write-Error "Could not determine the git root directory. Please specify the path to the project file." + exit 1 + } + + $Path = Join-Path -Path $_gitRoot -ChildPath '/src/OpenAI.csproj' + $Path = (Resolve-Path -LiteralPath $Path).Path +} + +# Update snippets +Write-Host "Updating snippets in $Path" + +dotnet tool restore +dotnet tool run snippet-generator -b $Path \ No newline at end of file