Skip to content
Docs Try Aspire

Compiler Warning ASPIREEXPORT007

Version introduced: 13.2

Export ID '0' is already defined for target type '1'. Each export ID must be unique per target type.

This diagnostic warning is reported when two or more [AspireExport] methods in the same assembly use the same export ID for the same target type. Because the export ID becomes the method name in generated code for other language runtimes, duplicate export IDs for the same target type would result in ambiguous or overwritten API members.

The following code generates ASPIREEXPORT007:

C# — Integration.cs
[AspireExport("withCache")]
public static IResourceBuilder<RedisResource> WithCache(
IResourceBuilder<RedisResource> builder)
{
return builder;
}
[AspireExport("withCache")] // Duplicate ID for the same target type
public static IResourceBuilder<RedisResource> WithCacheAndPersistence(
IResourceBuilder<RedisResource> builder)
{
return builder.WithPersistence();
}

Use a unique export ID for each method targeting the same type:

C# — Integration.cs
[AspireExport("withCache")]
public static IResourceBuilder<RedisResource> WithCache(
IResourceBuilder<RedisResource> builder)
{
return builder;
}
[AspireExport("withCacheAndPersistence")]
public static IResourceBuilder<RedisResource> WithCacheAndPersistence(
IResourceBuilder<RedisResource> builder)
{
return builder.WithPersistence();
}

Suppress the warning with either of the following methods:

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

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIREEXPORT007.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);ASPIREEXPORT007</NoWarn>
    </PropertyGroup>