Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"rollForward": false
},
"dotnet-inspect": {
"version": "0.27.0",
"version": "0.28.0",
"commands": [
"dotnet-inspect"
],
"rollForward": false
},
"purview.build": {
"version": "0.9.1",
"version": "0.9.2",
"commands": [
"purview-build"
],
Expand Down
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Purview.BuildSdk 2.2.0 - managed file, do not edit
# Purview.BuildSdk 2.2.1 - managed file, do not edit
#
# This file is written by Purview.BuildSdk and is replaced whenever the SDK version changes. The version
# on the first line is how the SDK recognises a file it owns: a .editorconfig without that marker is
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ is used only while the version is a pre-release (`-alpha`, `-beta`, `-rc`).
This file was reconstructed from the conventional-commit history at 1.0.7, so entries before that
release summarise what the commits recorded rather than what was written at the time.

## [2.2.1] - 2026-11-18

### Fixed

- **Aspire 17 AppHost detection.** `IsAspireHostProject` is now also `true` when a project references the
`Aspire.Hosting.AppHost` package, which is the form Aspire 17 uses now that `Aspire.AppHost.Sdk` is
obsolete. The package's own `IsAspireHost` property is not available when this SDK is imported from
`Directory.Build.props` (NuGet package props are imported after that file), so the comment-stripped
project text is scanned for the reference. The legacy `Aspire.Sdk.Host`/`Aspire.AppHost.Sdk` SDK
detection is unchanged, and a package-detected AppHost gets the same `OutputType=Exe`, CA1515 exemption
and `IsAspireProjectResource=false` references as an SDK-based one. A reference declared only in a shared
props file is not detected; set `IsAspireHostProject=true` before the `Sdk.props` import to opt in.

## [2.2.0] - 2026-11-17

### Changed (breaking)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ A reusable MSBuild SDK NuGet package that delivers standardised .NET project def
"runner": "Microsoft.Testing.Platform"
},
"msbuild-sdks": {
"Purview.BuildSdk": "2.2.0"
"Purview.BuildSdk": "2.2.1"
}
}
```
Expand Down Expand Up @@ -238,7 +238,7 @@ to a low-importance message) and only a copy that still fails after every retry
The bootstrapped `.editorconfig` opens with a version marker:

```editorconfig
# Purview.BuildSdk 2.2.0 - managed file, do not edit
# Purview.BuildSdk 2.2.1 - managed file, do not edit
```

That line is how the SDK recognises a file **it** wrote. When the SDK version changes, a file carrying
Expand Down Expand Up @@ -539,7 +539,7 @@ import (or, where noted, in the project).
| `IsWebProject` | *(detected from the project)* | Marks a project with web behaviour (a web SDK project or an API host). |
| `IsWebSdkProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Web`. |
| `IsWorkerSdkProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Worker`. |
| `IsAspireHostProject` | *(detected from the project)* | `true` when the project SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`. |
| `IsAspireHostProject` | *(detected from the project)* | `true` when the project SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project file references `Aspire.Hosting.AppHost` (Aspire 17+). |
| `IsBlazorWebAssemblyProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.BlazorWebAssembly`. |
| `IsRazorClassLibraryProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Razor`. |
| `IsBlazorHostProject` | *(detected from the project)* | `true` for a web SDK project that references a Blazor WebAssembly client. Says nothing about whether the host is a BFF. |
Expand Down Expand Up @@ -642,7 +642,7 @@ Read the exported property rather than re-deriving SDK behaviour — it is the S
| `IsWebProject` | Marker used in SDK web-project behaviour. |
| `IsWebSdkProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Web`. |
| `IsWorkerSdkProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Worker`. |
| `IsAspireHostProject` | True when SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`. |
| `IsAspireHostProject` | True when SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project references `Aspire.Hosting.AppHost`. |
| `IsBlazorWebAssemblyProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.BlazorWebAssembly`. |
| `IsRazorClassLibraryProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Razor`. |
| `IsBlazorHostProject` | True for a web SDK project that references a Blazor WebAssembly client. |
Expand Down
4 changes: 2 additions & 2 deletions docs/wiki/Configuration-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Override one by setting it before the `Sdk.props` import. See [Project Type Dete
| `IsWebProject` | *(detected from the project)* | Marks a project with web behaviour (a web SDK project or an API host). |
| `IsWebSdkProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Web`. |
| `IsWorkerSdkProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Worker`. |
| `IsAspireHostProject` | *(detected from the project)* | `true` when the project SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`. |
| `IsAspireHostProject` | *(detected from the project)* | `true` when the project SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project file references `Aspire.Hosting.AppHost` (Aspire 17+). |
| `IsBlazorWebAssemblyProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.BlazorWebAssembly`. |
| `IsRazorClassLibraryProject` | *(detected from the project)* | `true` when the project SDK is `Microsoft.NET.Sdk.Razor`. |
| `IsBlazorHostProject` | *(detected from the project)* | `true` for a web SDK project that references a Blazor WebAssembly client. Says nothing about whether the host is a BFF. |
Expand Down Expand Up @@ -407,7 +407,7 @@ property that is not in this list.
| `IsWebProject` | Marker used in SDK web-project behaviour. |
| `IsWebSdkProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Web`. |
| `IsWorkerSdkProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Worker`. |
| `IsAspireHostProject` | True when SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`. |
| `IsAspireHostProject` | True when SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project references `Aspire.Hosting.AppHost`. |
| `IsBlazorWebAssemblyProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.BlazorWebAssembly`. |
| `IsRazorClassLibraryProject` | True when `SdkProjectName` is `Microsoft.NET.Sdk.Razor`. |
| `IsBlazorHostProject` | True for a web SDK project that references a Blazor WebAssembly client. |
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/Getting-Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pinned SDK version — bump it deliberately, because a released version can chan
"runner": "Microsoft.Testing.Platform"
},
"msbuild-sdks": {
"Purview.BuildSdk": "2.2.0"
"Purview.BuildSdk": "2.2.1"
}
}
```
Expand Down
8 changes: 7 additions & 1 deletion docs/wiki/concepts/Project-Type-Detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ wiki.
| `IsSdkProject` | An `Sdk` value is parsed from the `<Project>`/`<Import>` element. |
| `IsWebSdkProject` | `SdkProjectName` is `Microsoft.NET.Sdk.Web`. |
| `IsWorkerSdkProject` | `SdkProjectName` is `Microsoft.NET.Sdk.Worker`. |
| `IsAspireHostProject` | `SdkProjectName` starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`. |
| `IsAspireHostProject` | `SdkProjectName` starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project file references `Aspire.Hosting.AppHost` (Aspire 17+). |
| `IsCLIProject` | Project name ends with `CLI`, `Console`, `CommandLine`, `QuickStart`, or `QuickStarts`. |
| `IsBlazorWebAssemblyProject` | `SdkProjectName` is `Microsoft.NET.Sdk.BlazorWebAssembly`. |
| `IsRazorClassLibraryProject` | `SdkProjectName` is `Microsoft.NET.Sdk.Razor`. |
Expand All @@ -31,6 +31,12 @@ wiki.
| `IsPackable` | `<IsPackable>true</IsPackable>` is declared in the project file. |
| `IsWebProject` | Marker used in SDK web-project behaviour. |

`IsAspireHostProject` also recognises Aspire 17's form: `Microsoft.NET.Sdk` plus an
`Aspire.Hosting.AppHost` `PackageReference`. The reference is read from the project file, because this
SDK is imported from `Directory.Build.props` and NuGet package props are imported after that file. A
reference declared only in a shared props file is not detected; set `IsAspireHostProject=true` in
`Directory.Build.props` before the SDK import to opt in.

`TestingType` is the detected test category suffix from the project name (for example `Unit`,
`Integration`, `E2E`); `TargetProjectName` is the inferred non-test project name that a test project
targets. The detected `TestingType` also becomes the baseline test category, while additional categories
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-sdk",
"version": "2.2.0",
"version": "2.2.1",
"homepage": "https://purview.dev/projects/build-sdk/",
"bugs": {
"url": "https://github.com/purview-dev/build-sdk/issues"
Expand Down
7 changes: 6 additions & 1 deletion skills/purview-buildsdk-project-detection/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ classification that decides it.
| the project's `Sdk="..."` declaration | `IsSdkProject`, `SdkProjectName` |
| `Microsoft.NET.Sdk.Web` | `IsWebSdkProject=true` |
| `Microsoft.NET.Sdk.Worker` | `IsWorkerSdkProject=true` |
| SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk` | `IsAspireHostProject=true` |
| SDK starts with `Aspire.Sdk.Host` or `Aspire.AppHost.Sdk`, or the project references `Aspire.Hosting.AppHost` (Aspire 17+) | `IsAspireHostProject=true` |
| `Dockerfile`, `dockerfile` or `Dockerfile.dev` in the project directory | `IsContainerProject=true` |
| name ends with `CLI`, `Console`, `CommandLine`, `QuickStart`, `QuickStarts` | `IsCLIProject=true` |
| `Microsoft.NET.Sdk.BlazorWebAssembly` | `IsBlazorWebAssemblyProject=true` |
| `Microsoft.NET.Sdk.Razor` | `IsRazorClassLibraryProject=true` |
| a web SDK project whose name ends with `Bff` (case-sensitive, like `CLI`), or that sets `IsBffProject=true` | `IsBffProject=true` |
| a web SDK project that references an `IsBlazorWebAssemblyProject` project | `IsBlazorHostProject=true` |

`IsAspireHostProject` also matches Aspire 17's form: `Microsoft.NET.Sdk` plus an
`Aspire.Hosting.AppHost` `PackageReference` in the project file. The package's own `IsAspireHost` is
imported after this SDK, so the project file is what is read. A reference declared only in a shared
props file is not detected; set `IsAspireHostProject=true` before the `Sdk.props` import to opt in.

`IsBffProject=false` opts a `*Bff` project out. `IsBlazorHostProject` is **never** inferred into
`IsBffProject`: a host that keeps no tokens is not a BFF, and BFF rules do not describe it.

Expand Down
22 changes: 18 additions & 4 deletions src/src/BuildSdk/Sdk/Sdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@
<IsWebProject>false</IsWebProject>
<IsWebSdkProject>false</IsWebSdkProject>
<IsWorkerSdkProject>false</IsWorkerSdkProject>
<IsAspireHostProject>false</IsAspireHostProject>
<!-- Honours a value set before this import, so a project that cannot be detected - one whose
Aspire.Hosting.AppHost reference lives in a shared props file - can opt in explicitly. -->
<IsAspireHostProject Condition="'$(IsAspireHostProject)' == ''">false</IsAspireHostProject>
<IsCLIProject>false</IsCLIProject>
<IsBlazorWebAssemblyProject>false</IsBlazorWebAssemblyProject>
<IsRazorClassLibraryProject>false</IsRazorClassLibraryProject>
Expand Down Expand Up @@ -304,9 +306,21 @@
<IsContainerProject
Condition="'$(IsBlazorWebAssemblyProject)' == 'true' AND '$(DisablePurviewBlazorWebAssemblyDefaults)' != 'true'"
>false</IsContainerProject>
<!--
Aspire 17 moved AppHosts off the Aspire.AppHost.Sdk MSBuild SDK: a C# AppHost is now
Microsoft.NET.Sdk plus an Aspire.Hosting.AppHost PackageReference. The package sets
IsAspireHost, but this SDK is imported from Directory.Build.props, and Microsoft.Common.props
imports that *before* the NuGet package props, so IsAspireHost does not exist yet. Read the
reference from the project text instead, through the comment-stripped text the other scans
share. A reference declared only in a shared props file cannot be seen here; set
IsAspireHostProject=true explicitly in that case.
-->
<_PurviewProjectReferencesAspireAppHost
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch($(_PurviewProjectText), `(?is)&lt;PackageReference\b[^&gt;]*\bInclude\s*=\s*[&quot;']Aspire\.Hosting\.AppHost[&quot;'][^&gt;]*&gt;`))"
>true</_PurviewProjectReferencesAspireAppHost>
<IsAspireHostProject
Label="Detect Aspire.Sdk.Host SDK projects - only works when the SDK attribute is on the Project element"
Condition="$([System.String]::Copy('$(SdkProjectName)').StartsWith('Aspire.Sdk.Host')) == 'True' OR $([System.String]::Copy('$(SdkProjectName)').StartsWith('Aspire.AppHost.Sdk')) == 'True'"
Label="Detect Aspire AppHost projects: the legacy SDK attribute, or the Aspire 17+ Aspire.Hosting.AppHost package reference"
Condition="$([System.String]::Copy('$(SdkProjectName)').StartsWith('Aspire.Sdk.Host')) == 'True' OR $([System.String]::Copy('$(SdkProjectName)').StartsWith('Aspire.AppHost.Sdk')) == 'True' OR '$(_PurviewProjectReferencesAspireAppHost)' == 'true'"
>true</IsAspireHostProject>
<IsCLIProject
Condition="$([System.String]::Copy('$(MSBuildProjectName)').EndsWith('CLI')) == 'True' OR $([System.String]::Copy('$(MSBuildProjectName)').EndsWith('Console')) == 'True' OR $([System.String]::Copy('$(MSBuildProjectName)').EndsWith('CommandLine')) == 'True' OR $([System.String]::Copy('$(MSBuildProjectName)').EndsWith('QuickStart')) == 'True' OR $([System.String]::Copy('$(MSBuildProjectName)').EndsWith('QuickStarts')) == 'True'"
Expand Down Expand Up @@ -492,7 +506,7 @@
<Description>True when SdkProjectName is Microsoft.NET.Sdk.Worker.</Description>
</CompilerVisibleProperty>
<CompilerVisibleProperty Include="IsAspireHostProject">
<Description>True when the project SDK starts with Aspire.Sdk.Host or Aspire.AppHost.Sdk.</Description>
<Description>True for an Aspire AppHost: the project SDK starts with Aspire.Sdk.Host or Aspire.AppHost.Sdk, or the project references Aspire.Hosting.AppHost (Aspire 17+).</Description>
</CompilerVisibleProperty>
<CompilerVisibleProperty Include="IsBlazorWebAssemblyProject">
<Description>True when SdkProjectName is Microsoft.NET.Sdk.BlazorWebAssembly.</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/src/BuildSdk/Sdk/Sdk.props.buildschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"defaultValue": "false"
},
"IsAspireHostProject": {
"description": "True when the project SDK starts with Aspire.Sdk.Host or Aspire.AppHost.Sdk. Set it before the `Sdk.props` import to override. No default: detected from the project.",
"description": "True for an Aspire AppHost: the project SDK starts with Aspire.Sdk.Host or Aspire.AppHost.Sdk, or the project file references Aspire.Hosting.AppHost (Aspire 17+). A reference declared only in a shared props file is not detected; set it before the `Sdk.props` import to opt in. No default: detected from the project.",
"type": "bool"
},
"IsBffProject": {
Expand Down
81 changes: 81 additions & 0 deletions src/tests/BuildSdk.IntegrationTests/ProjectClassificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,87 @@ public async Task AspireHostProject_DetectedByFileContentMarker(CancellationToke
await Assert.That(await h.GetPropertyAsync("IsAspireHostProject", cancellationToken)).IsEqualTo("true");
}

/// <summary>
/// Aspire 17 replaced the <c>Aspire.AppHost.Sdk</c> MSBuild SDK with <c>Microsoft.NET.Sdk</c> plus an
/// <c>Aspire.Hosting.AppHost</c> package reference. The package's own <c>IsAspireHost</c> property is
/// imported after this SDK (NuGet package props follow <c>Directory.Build.props</c>), so the project
/// file is scanned for the reference instead.
/// </summary>
[Test]
[Arguments("""<PackageReference Include="Aspire.Hosting.AppHost" Version="17.0.0" />""")]
[Arguments("""<PackageReference Include="Aspire.Hosting.AppHost" />""")]
[Arguments("""<PackageReference Version="17.0.0" Include="Aspire.Hosting.AppHost" />""")]
public async Task AspireHostProject_DetectedByAppHostPackageReference(
string packageReference,
CancellationToken cancellationToken
)
{
using var h = await ProjectHarness.CreateAsync(
"Acme.AppHost",
extraItems: packageReference,
cancellationToken: cancellationToken
);
var props = await h.GetPropertiesAsync(
cancellationToken,
"IsAspireHostProject",
"OutputType",
"NoWarn",
"PurviewPolicyExemptNoWarn"
);

await Assert.That(props["IsAspireHostProject"]).IsEqualTo("true");
await Assert.That(props["OutputType"]).IsEqualTo("Exe");
await Assert.That(props["NoWarn"]).Contains("CA1515");
await Assert.That(props["PurviewPolicyExemptNoWarn"]).Contains("CA1515");
}

[Test]
[Arguments("""<PackageReference Include="Aspire.Hosting" Version="17.0.0" />""")]
[Arguments("""<PackageReference Include="Aspire.Hosting.Azure.Storage" Version="17.0.0" />""")]
public async Task AspireHostProject_NotDetectedForHostingIntegrationOnly(
string packageReference,
CancellationToken cancellationToken
)
{
using var h = await ProjectHarness.CreateAsync(
"Acme.AppHost",
extraItems: packageReference,
cancellationToken: cancellationToken
);

await Assert.That(await h.GetPropertyAsync("IsAspireHostProject", cancellationToken)).IsEqualTo("false");
}

[Test]
public async Task AspireHostProject_NotDetectedWhenAppHostPackageReferenceIsCommentedOut(
CancellationToken cancellationToken
)
{
using var h = await ProjectHarness.CreateAsync(
"Acme.AppHost",
extraItems: """<!-- <PackageReference Include="Aspire.Hosting.AppHost" Version="17.0.0" /> -->""",
cancellationToken: cancellationToken
);

await Assert.That(await h.GetPropertyAsync("IsAspireHostProject", cancellationToken)).IsEqualTo("false");
}

[Test]
public async Task AspireHostProject_ExplicitOptInBeforeSdkImportGetsHostDefaults(
CancellationToken cancellationToken
)
{
using var h = await ProjectHarness.CreateAsync(
"Acme.AppHost",
preImportProps: "<IsAspireHostProject>true</IsAspireHostProject>",
cancellationToken: cancellationToken
);
var props = await h.GetPropertiesAsync(cancellationToken, "IsAspireHostProject", "OutputType");

await Assert.That(props["IsAspireHostProject"]).IsEqualTo("true");
await Assert.That(props["OutputType"]).IsEqualTo("Exe");
}

[Test]
public async Task RegularProject_IsNotAspireHostProject(CancellationToken cancellationToken)
{
Expand Down
2 changes: 1 addition & 1 deletion templates/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"runner": "Microsoft.Testing.Platform"
},
"msbuild-sdks": {
"Purview.BuildSdk": "2.2.0"
"Purview.BuildSdk": "2.2.1"
}
}
Loading