Zum Inhalt springen

Compiler Warning ASPIRECOMPUTE003

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Version introduced: 13.1

The ContainerRegistryResource type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic warning is reported when using the experimental ContainerRegistryResource class and related container registry functionality.

The following code generates ASPIRECOMPUTE003:

C# — Using ContainerRegistryResource
var builder = DistributedApplication.CreateBuilder(args);
// Add a container registry with literal values
var registry = builder.AddContainerRegistry("docker-hub", "docker.io", "myusername");
var api = builder.AddProject<Projects.Api>("api")
.WithContainerRegistry(registry);
C# — Using ContainerRegistryResource with parameters
var builder = DistributedApplication.CreateBuilder(args);
// Add a container registry with parameterized values
var endpointParameter = builder.AddParameter("registry-endpoint");
var repositoryParameter = builder.AddParameter("registry-repo");
var registry = builder.AddContainerRegistry("my-registry", endpointParameter, repositoryParameter);
var api = builder.AddProject<Projects.Api>("api")
.WithContainerRegistry(registry);

Understanding container registry resources

Section titled “Understanding container registry resources”

The ContainerRegistryResource represents a general-purpose container registry that can be referenced in your Aspire application model. It enables integration with:

  • Docker Hub — Public or private Docker Hub repositories
  • GitHub Container Registry — GitHub’s container registry (ghcr.io)
  • Azure Container Registry — Azure’s managed container registry service
  • Private registries — Self-hosted or third-party container registries

Flexible configuration

  • Use literal strings for static registry configuration
  • Use ParameterResource values for dynamic configuration
  • Specify optional repository paths within the registry

Integration with deployment pipelines

  • Automatic Push and PushPrereq steps for container registry operations
  • Seamless integration with container image builds
  • Support for authentication and credentials

Resource builder pattern

  • Follows Aspire’s resource builder pattern for consistency
  • Can be referenced by other resources using WithContainerRegistry
  • Supports chaining with other resource configuration methods

Suppress the warning with either of the following methods:

  • Set the severity of the rule in the .editorconfig file.

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIRECOMPUTE003.severity = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIRECOMPUTE003</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIRECOMPUTE003 directive:

    C# — Suppressing the warning
    var builder = DistributedApplication.CreateBuilder(args);
    #pragma warning disable ASPIRECOMPUTE003
    var registry = builder.AddContainerRegistry("docker-hub", "docker.io", "myusername");
    #pragma warning restore ASPIRECOMPUTE003
    var api = builder.AddProject<Projects.Api>("api")
    .WithContainerRegistry(registry);
Fragen & AntwortenZusammenarbeitenCommunityDiskutierenAnsehen