Compiler Warning ASPIRECOMPUTE003
이 콘텐츠는 아직 번역되지 않았습니다.
The
ContainerRegistryResourcetype 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.
Example
Section titled “Example”The following code generates ASPIRECOMPUTE003:
var builder = DistributedApplication.CreateBuilder(args);
// Add a container registry with literal valuesvar registry = builder.AddContainerRegistry("docker-hub", "docker.io", "myusername");
var api = builder.AddProject<Projects.Api>("api") .WithContainerRegistry(registry);var builder = DistributedApplication.CreateBuilder(args);
// Add a container registry with parameterized valuesvar 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
Key features
Section titled “Key features”Flexible configuration
- Use literal strings for static registry configuration
- Use
ParameterResourcevalues for dynamic configuration - Specify optional repository paths within the registry
Integration with deployment pipelines
- Automatic
PushandPushPrereqsteps 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
To suppress this warning
Section titled “To suppress this warning”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 = noneFor more information about editor config files, see Configuration files for code analysis rules.
-
Add the following
PropertyGroupto your project file:C# project file <PropertyGroup><NoWarn>$(NoWarn);ASPIRECOMPUTE003</NoWarn></PropertyGroup> -
Suppress in code with the
#pragma warning disable ASPIRECOMPUTE003directive:C# — Suppressing the warning var builder = DistributedApplication.CreateBuilder(args);#pragma warning disable ASPIRECOMPUTE003var registry = builder.AddContainerRegistry("docker-hub", "docker.io", "myusername");#pragma warning restore ASPIRECOMPUTE003var api = builder.AddProject<Projects.Api>("api").WithContainerRegistry(registry);
See also
Section titled “See also”- ASPIRECOMPUTE001 — Compute environment resource creation
- ASPIRECOMPUTE002 — Host address expression method
- What’s new in Aspire 13.1 - Container registry support