Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_call:

jobs:
build:
Expand All @@ -17,15 +18,15 @@ jobs:
configuration: [Debug, Release]
fail-fast: false

steps:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
dotnet-version: |
9.0.x
8.0.x

Expand All @@ -38,7 +39,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-everything

Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ permissions:
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
publish-docs:
# Only publish from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.github.repository == 'modelcontextprotocol/csharp-sdk' }}

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -42,4 +45,4 @@ jobs:

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
81 changes: 47 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
# This workflow is triggered by new releases
# It builds, tests, and publishes to the GitHub NuGet package registry
name: Release package
# Publish new package versions of ModelContextProtocol
#
# Daily and Manual Runs
# - Triggered automatically at 07:00 UTC daily
# - Triggered manually using GitHub Actions workflow_dispatch event
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix set to `ci.{github.run_number}`
# - Package published to GitHub package registry
#
# Official Releases
# - Triggered after a GitHub Release is created
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix applied from /src/Directory.Build.props
# - Package published to GitHub package registry
# - Package published to NuGet.org
# - Version prefix and/or suffix should be updated after each release

name: Release Publishing

on:
schedule:
- cron: '0 7 * * *'

workflow_dispatch:

release:
types: [published]

jobs:
build:
run-ci:
uses: ./.github/workflows/ci.yml

build-package:
runs-on: windows-latest
needs: run-ci

env:
version_suffix_args: ${{ github.event_name != 'release' && format('--version-suffix "ci.{0}"', github.run_number) || '' }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Setup .NET
uses: actions/setup-dotnet@v2
Expand All @@ -23,25 +47,11 @@ jobs:
9.0.x
8.0.x

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-everything

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-memory

- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test --configuration Release --no-build --filter '(Execution!=Manual)'

- name: Pack
run: dotnet pack --configuration Release --output "${{ github.workspace }}/artifacts/packages"
run: dotnet pack
${{ env.version_suffix_args }}
--configuration Release
--output "${{ github.workspace }}/artifacts/packages"

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -50,20 +60,14 @@ jobs:
name: build-artifacts
path: ${{ github.workspace }}/artifacts

publish:
name: Publish Package
needs: build
publish-package:
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
9.0.x
8.0.x
dotnet-version: 9.0.x

- name: Download build artifacts
uses: actions/download-artifact@v4
Expand All @@ -75,7 +79,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: NuGet authentication for GitHub
- name: Authenticate to GitHub registry
run: dotnet nuget add source
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
--name "github"
Expand All @@ -89,3 +93,12 @@ jobs:
--source "github"
--api-key ${{ secrets.GITHUB_TOKEN }}
--skip-duplicate

- name: Publish to NuGet.org (Releases only)
# Only publish from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.event_name == 'release' && github.repository == 'modelcontextprotocol/csharp-sdk' }}
run: dotnet nuget push
${{github.workspace}}/build-artifacts/packages/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_KEY_MODELCONTEXTPROTOCOL }}
--skip-duplicate
29 changes: 23 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,32 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<PackageVersion>0.1.0-preview</PackageVersion>
<Authors>Microsoft</Authors>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName).$(TargetFramework).$(OS).trx</VSTestLogger>
<VSTestResultsDirectory>$(RepoRoot)/artifacts/TestResults</VSTestResultsDirectory>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>

<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts'))</ArtifactsDir>
<ArtifactsObjDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'obj'))</ArtifactsObjDir>
<ArtifactsBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin'))</ArtifactsBinDir>
<ArtifactsTestResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'TestResults', '$(Configuration)'))</ArtifactsTestResultsDir>
<ArtifactsPackagesDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'packages', '$(Configuration)'))</ArtifactsPackagesDir>
<OutDirName>$(MSBuildProjectName)</OutDirName>

<BaseIntermediateOutputPath>$([System.IO.Path]::GetFullPath('$(ArtifactsObjDir)$(OutDirName)\'))</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>

<BaseOutputPath>$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)$(OutDirName)\'))</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>

<PackageOutputPath>$(ArtifactsPackagesDir)</PackageOutputPath>
</PropertyGroup>

<PropertyGroup>
<VSTestLogger Condition="'$(VSTestLogger)' == ''">trx%3bLogFileName=$(MSBuildProjectName).$(TargetFramework).$(OS).trx</VSTestLogger>
<VSTestResultsDirectory Condition="'$(VSTestResultsDirectory)' == ''">$(ArtifactsTestResultsDir)</VSTestResultsDirectory>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
<PackageProjectUrl>https://github.com/modelcontextprotocol/csharp-sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/modelcontextprotocol/csharp-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionSuffix>preview.2</VersionSuffix>
<Authors>ModelContextProtocolOfficial</Authors>
<Copyright>© Anthropic and Contributors.</Copyright>
<PackageTags>ModelContextProtocol;mcp;ai;llm</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo.png</PackageIcon>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageOutputPath>$(RepoRoot)artifacts/</PackageOutputPath>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AssemblyOriginatorKeyFile>$(RepoRoot)\Open.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -23,4 +26,4 @@
<ItemGroup>
<None Include="$(RepoRoot)\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/ModelContextProtocol/ModelContextProtocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<None Include="README.md" pack="true" PackagePath="." />
<None Include="README.md" pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
</ItemGroup>

<ItemGroup>
<Content Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="..\ModelContextProtocol.TestServer\bin\$(Configuration)\net8.0\TestServer.exe">
<Content Condition="$([MSBuild]::IsOSPlatform('Windows'))" Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)ModelContextProtocol.TestServer\$(Configuration)'))\$(TargetFramework)\TestServer.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="..\ModelContextProtocol.TestServer\bin\$(Configuration)\net8.0\TestServer.dll">
<Content Condition="$([MSBuild]::IsOSPlatform('Linux'))" Include="$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)ModelContextProtocol.TestServer\$(Configuration)'))\$(TargetFramework)\TestServer.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down