Aspirerelease/17.0

Compiler Warning ASPIRE012

このコンテンツはまだ日本語訳がありません。

Version introduced: 17.0

‘[ProjectName]’ uses the Aspire.AppHost.Sdk, which is obsolete but remains available for staged migration. Switch the project’s Sdk attribute to Microsoft.NET.Sdk, add explicit PackageReference items for Aspire.Hosting.AppHost and Aspire.Hosting.Dotnet, and migrate C# resource ProjectReference items to AddDotnetProject calls. See https://aka.ms/aspire/diagnostics/aspire012 for migration guidance.

This diagnostic warning is reported when a C# AppHost uses Aspire.AppHost.Sdk, either in a project file’s Sdk attribute or in a file-based app’s #:sdk directive. The SDK still works, including AppHost project references and AddProject resources, so you can migrate in stages.

C# AppHosts now use Microsoft.NET.Sdk with explicit Aspire.Hosting.AppHost and Aspire.Hosting.Dotnet packages, and add .NET projects with AddDotnetProject. Running aspire update doesn’t remove the SDK for you.

The following project file produces ASPIRE012:

MyApp.AppHost.csproj
<Project Sdk="Aspire.AppHost.Sdk/17.0.0">

The following file-based AppHost directive also produces ASPIRE012:

apphost.cs
#:sdk Aspire.AppHost.Sdk@17.0.0

Replace the SDK with Microsoft.NET.Sdk and explicit package references:

MyApp.AppHost.csproj
<Project Sdk="Microsoft.NET.Sdk">
<!-- Keep your existing PropertyGroup -->
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="17.0.0" />
<PackageReference Include="Aspire.Hosting.Dotnet" Version="17.0.0" />
</ItemGroup>
</Project>

In a file-based AppHost, replace the #:sdk directive with package directives:

apphost.cs
#:package Aspire.Hosting.AppHost@17.0.0
#:package Aspire.Hosting.Dotnet@17.0.0

Then review the AppHost’s project references. Without the SDK, project references no longer generate Projects.* metadata automatically. Migrate resources to AddDotnetProject, or mark references that legacy APIs still need. For complete steps, see Remove the obsolete AppHost SDK.

Suppress ASPIRE012 only temporarily while you migrate. Set the following property in the AppHost project file:

MyApp.AppHost.csproj
<PropertyGroup>
<SuppressAspireAppHostSdkObsoleteWarning>true</SuppressAspireAppHostSdkObsoleteWarning>
</PropertyGroup>

Alternatively, add ASPIRE012 to NoWarn:

MyApp.AppHost.csproj
<PropertyGroup>
<NoWarn>$(NoWarn);ASPIRE012</NoWarn>
</PropertyGroup>

Suppressing ASPIRE012 doesn’t suppress CS0618 warnings for obsolete resource APIs such as AddProject, and doesn’t remove the Aspire CLI bundle requirement.