Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
118 changes: 118 additions & 0 deletions .github/workflows/build-cs-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build C# SDK

on:
workflow_call:
inputs:
version:
required: true
type: string
useWinML:
required: false
type: boolean
default: false
buildConfiguration:
required: false
type: string
default: 'Debug' # or 'Release'

permissions:
contents: read

jobs:
build:
runs-on: windows-latest
env:
buildConfiguration: 'Debug'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
clean: true

# adapted from https://github.com/actions/setup-dotnet?tab=readme-ov-file#azure-artifacts
# saves auth credentials to ../nuget.config
- name: Setup .NET 9 SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: '9.0.x'
source-url: https://pkgs.dev.azure.com/microsoft/windows.ai.toolkit/_packaging/Neutron/nuget/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.AZURE_DEVOPS_PAT }}

- name: Restore dependencies
run: |
dotnet restore sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj /p:UseWinML=${{ inputs.useWinML }} --configfile ../nuget.config

- name: Build solution
run: |
dotnet build sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj --configfile ../nuget.config --no-restore --configuration ${{ inputs.buildConfiguration }} /p:UseWinML=${{ inputs.useWinML }}

# need to use direct git commands to clone from Azure DevOps instead of actions/checkout
- name: Checkout test-data-shared from Azure DevOps
shell: pwsh
working-directory: ${{ github.workspace }}\..
run: |
$pat = "${{ secrets.AZURE_DEVOPS_PAT }}"
$encodedPat = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))

# Configure git to use the PAT
git config --global http.https://dev.azure.com.extraheader "AUTHORIZATION: Basic $encodedPat"

# Clone with LFS to parent directory
git lfs install
git clone --depth 1 https://dev.azure.com/microsoft/windows.ai.toolkit/_git/test-data-shared test-data-shared

Write-Host "Clone completed successfully to ${{ github.workspace }}\..\test-data-shared"

- name: Checkout specific commit in test-data-shared
shell: pwsh
working-directory: ${{ github.workspace }}\..\test-data-shared
run: |
Write-Host "Current directory: $(Get-Location)"
git checkout 231f820fe285145b7ea4a449b112c1228ce66a41
if ($LASTEXITCODE -ne 0) {
Write-Error "Git checkout failed."
exit 1
}
Write-Host "`nDirectory contents:"
Get-ChildItem -Recurse -Depth 2 | ForEach-Object { Write-Host " $($_.FullName)" }

- name: Run Foundry Local Core tests
run: |
dotnet test sdk_v2\cs\test\FoundryLocal.Tests\Microsoft.AI.Foundry.Local.Tests.csproj --verbosity normal /p:UseWinML=${{ inputs.useWinML }}

- name: Pack NuGet package
shell: pwsh
run: |
$projectPath = "sdk_v2\cs\src\Microsoft.AI.Foundry.Local.csproj"
$outputDir = "sdk_v2\cs\bin"
$version = "${{ inputs.version }}"
$config = "${{ inputs.buildConfiguration }}"
$useWinML = "${{ inputs.useWinML }}"

Write-Host "Packing project: $projectPath"
Write-Host "Output directory: $outputDir"
Write-Host "Version: $version"
Write-Host "Configuration: $config"
Write-Host "UseWinML: $useWinML"

& dotnet pack $projectPath --no-build --configuration $config --output $outputDir /p:PackageVersion=$version /p:UseWinML=$useWinML /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --verbosity normal

if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet pack failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}

Write-Host "Pack completed successfully"
Write-Host "Generated packages:"
Get-ChildItem -Path $outputDir -Filter "*.nupkg" | ForEach-Object { Write-Host " $($_.Name)" }
Get-ChildItem -Path $outputDir -Filter "*.snupkg" | ForEach-Object { Write-Host " $($_.Name)" }

- name: Upload NuGet packages
uses: actions/upload-artifact@v4
with:
name: cs-sdk
path: |
sdk_v2\cs\bin\*.nupkg
sdk_v2\cs\bin\*.snupkg
24 changes: 24 additions & 0 deletions .github/workflows/foundry-local-sdk-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: SDK V2 Build

on:
pull_request:
paths:
- 'sdk_v2/**'
- '.github/workflows/sdk_v2/**'
push:
paths:
- 'sdk_v2/**'
- '.github/workflows/sdk_v2/**'
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
build-cs:
uses: ./.github/workflows/build-cs-steps.yml
with:
version: '0.9.0.${{ github.run_number }}'
secrets: inherit
18 changes: 0 additions & 18 deletions .github/workflows/sdk_v2/foundry-local-sdk-build.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/sdk_v2/templates/build-cs-steps.yml

This file was deleted.

Loading