Skip to main content
DotNET Build Buddy includes an intelligent NuGet compatibility checker that verifies your package dependencies work with your target framework and provides actionable recommendations when issues are found.

Overview

The NuGet compatibility checker analyzes your project’s package references and:
  • Validates compatibility with your target framework
  • Checks version availability on NuGet.org
  • Suggests correct versions when incompatibilities are found
  • Recommends alternatives for deprecated or incompatible packages
  • Analyzes transitive dependencies (dependencies of dependencies)
  • Suggests framework upgrades when all packages support newer versions
The compatibility checker combines local rules with real-time NuGet API lookups to provide accurate, up-to-date compatibility information.

How It Works

Three-Tier Checking System

  1. Local Rules - Built-in compatibility rules for popular packages
  2. NuGet API - Real-time lookups for accurate version data
  3. Caching - Performance optimization with configurable expiry
// From nugetCompatibilityChecker.ts:98
public async checkCompatibility(
    packageName: string,
    packageVersion: string | undefined,
    targetFramework: string
): Promise<CompatibilityIssue | null> {
    // Check if checks are enabled
    if (!this.config.get<boolean>('nugetCheckEnabled', true)) {
        return null;
    }

    // Check cache first
    if (this.config.get<boolean>('nugetCacheEnabled', true)) {
        const cached = this.getCachedResult(cacheKey);
        if (cached !== undefined) {
            return cached;
        }
    }

    // Try API lookup if enabled
    if (this.config.get<boolean>('nugetApiEnabled', true)) {
        issue = await this.checkCompatibilityViaAPI(...);
    }

    // Fall back to local rules
    issue = this.checkCompatibilityLocal(...);
}

Issue Types

The checker identifies three types of compatibility issues:

Incompatible

Package cannot run on the target framework.Severity: Error (red squiggly)

Version Mismatch

Package version doesn’t exist or doesn’t match framework.Severity: Warning (yellow squiggly)

Deprecated

Package or version is deprecated.Severity: Warning (yellow squiggly)

Enhanced Compatibility Reports

Build Buddy provides detailed compatibility reports with actionable suggestions:
// From nugetCompatibilityChecker.ts:805
export interface EnhancedCompatibilityIssue extends CompatibilityIssue {
    suggestedVersion?: string;
    alternativePackage?: {
        name: string;
        version?: string;
        reason?: string;
    };
    transitiveIssues?: Array<{
        packageName: string;
        version?: string;
        message: string;
    }>;
}

Example Reports

⚠️ Microsoft.AspNetCore.Mvc version 2.0.0: Package version too old for net8.0
  💡 Suggested version: 8.0.0
  📝 Recommendation: Upgrade to at least version 8.0.0

NuGet API Integration

The checker queries the official NuGet.org API for real-time compatibility data:

Package Version Lookup

// From nugetCompatibilityChecker.ts:273
private async fetchPackageInfo(packageName: string, timeout: number): Promise<NuGetPackageInfoExtended | null> {
    const url = `https://api.nuget.org/v3-flatcontainer/${packageName.toLowerCase()}/index.json`;
    
    // Fetches available versions from NuGet.org
    const json = JSON.parse(data);
    const versions = json.versions || [];
    
    return {
        packageId: packageName,
        versions: versions,
        deprecated: false
    };
}
API requests are subject to a configurable timeout (default: 5000ms). If the API is unavailable, Build Buddy falls back to local compatibility rules.

Alternative Package Suggestions

Build Buddy knows about modern alternatives for deprecated packages:
Legacy PackageModern AlternativeReason
Microsoft.AspNet.MvcMicrosoft.AspNetCore.MvcModern ASP.NET Core MVC for .NET Core/.NET 5+
System.Web.MvcMicrosoft.AspNetCore.MvcModern ASP.NET Core MVC for .NET Core/.NET 5+
EntityFrameworkMicrosoft.EntityFrameworkCoreModern Entity Framework Core for .NET Core/.NET 5+
Newtonsoft.JsonSystem.Text.JsonBuilt-in JSON serialization in .NET Core/.NET 5+
// From nugetCompatibilityChecker.ts:907
private async suggestAlternative(
    packageName: string,
    targetFramework: string
): Promise<{ name: string; version?: string; reason?: string } | undefined> {
    const alternatives: Record<string, { name: string; reason: string }[]> = {
        'EntityFramework': [
            { name: 'Microsoft.EntityFrameworkCore', 
              reason: 'Modern Entity Framework Core for .NET Core/.NET 5+' }
        ],
        // ... more alternatives
    };
}

Framework Upgrade Suggestions

When all your packages support a newer framework, Build Buddy suggests upgrading:
// From nugetCompatibilityChecker.ts:1165
public async suggestFrameworkUpgrade(
    targetFramework: string,
    packageReferences: Array<{ Include: string; Version?: string }>
): Promise<{ suggestedFramework: string; reason: string; packagesSupporting: string[] } | null> {
    const upgradePaths: Record<string, string[]> = {
        'netcoreapp3.1': ['net5.0', 'net6.0', 'net7.0', 'net8.0'],
        'net6.0': ['net7.0', 'net8.0'],
        'net7.0': ['net8.0']
    };
    
    // Checks all packages for compatibility with newer frameworks
    // Returns highest framework where all packages are compatible
}

Upgrade Path Examples

1

Current: .NET Core 3.1

Possible upgrades: .NET 5.0 → .NET 6.0 → .NET 7.0 → .NET 8.0
2

Current: .NET 6.0

Possible upgrades: .NET 7.0 → .NET 8.0
3

Current: .NET Standard 2.0

Possible upgrades: .NET Standard 2.1 → .NET Core 3.1 → .NET 5.0+
Build Buddy shows upgrade suggestions as informational messages when 80% or more of your packages support the newer framework.

Built-in Compatibility Rules

Build Buddy includes comprehensive rules for popular .NET packages:

ASP.NET Core

{
    packageName: 'Microsoft.AspNetCore.Mvc',
    supportedFrameworks: [
        'netcoreapp2.0', 'netcoreapp2.1', 'netcoreapp2.2', 
        'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0'
    ],
    versionRules: {
        frameworkVersions: {
            'netcoreapp2.1': { min: '2.1.0', max: '2.1.x' },
            'net8.0': { min: '8.0.0' }
        }
    }
}

Entity Framework

  • EntityFramework - .NET Framework only (legacy)
  • Microsoft.EntityFrameworkCore - .NET Standard 2.0+ (modern)

Testing Frameworks

  • xunit - .NET Standard 1.1+
  • NUnit - .NET Standard 1.6+
  • Moq - .NET Standard 2.0+
  • Newtonsoft.Json - All frameworks from .NET 2.0+
  • Serilog - .NET Standard 1.5+
  • AutoMapper - .NET Standard 2.0+
  • MediatR - .NET Standard 2.0+
Build Buddy includes over 30 compatibility rules for:
  • ASP.NET Core packages
  • Entity Framework (classic and Core)
  • Microsoft.Extensions.* packages
  • Blazor components
  • SignalR
  • gRPC
  • Testing frameworks
  • Popular third-party libraries
See nugetCompatibilityChecker.ts:561 for the complete list.

Inline Diagnostics

Compatibility issues appear directly in your project files with:
  • Squiggly underlines (red for errors, yellow for warnings)
  • Hover tooltips with detailed information
  • Quick fixes where applicable
Example of inline NuGet diagnostics

Transitive Dependency Checking

Build Buddy can check dependencies of your dependencies:
// From nugetCompatibilityChecker.ts:966
private async checkTransitiveDependencies(
    packageName: string,
    packageVersion: string,
    targetFramework: string
): Promise<Array<{ packageName: string; version?: string; message: string }>> {
    const packageMetadata = await this.fetchPackageMetadata(packageName, packageVersion);
    const dependencies = packageMetadata.dependencies || [];

    for (const dependency of dependencies) {
        const depIssue = await this.checkCompatibility(
            dependency.id,
            depVersion,
            targetFramework
        );
        // Reports issues with transitive dependencies
    }
}
Transitive dependency checking requires NuGet API access and may increase check duration. This feature is automatically enabled when nugetApiEnabled is true.

Configuration

Customize the compatibility checker behavior:
settings.json
{
  "dotnetBuildBuddy.nugetCheckEnabled": true,
  "dotnetBuildBuddy.nugetApiEnabled": true,
  "dotnetBuildBuddy.nugetCacheEnabled": true,
  "dotnetBuildBuddy.nugetCacheExpiry": 3600,
  "dotnetBuildBuddy.nugetIgnoredPackages": [
    "MyInternalPackage",
    "Company.Internal.*"
  ],
  "dotnetBuildBuddy.nugetApiTimeout": 5000
}

Configuration Options

nugetCheckEnabled
boolean
default:"true"
Enable or disable all NuGet compatibility checking.
nugetApiEnabled
boolean
default:"true"
Enable real-time NuGet API lookups. Disable to use only local rules.
nugetCacheEnabled
boolean
default:"true"
Cache compatibility check results for better performance.
nugetCacheExpiry
number
default:"3600"
Cache expiration time in seconds (default: 1 hour).
nugetIgnoredPackages
string[]
default:"[]"
List of package names or patterns to ignore. Supports wildcards (e.g., Internal.*).
nugetApiTimeout
number
default:"5000"
NuGet API request timeout in milliseconds.

Performance Optimization

Caching Strategy

The compatibility checker uses intelligent caching:
// From nugetCompatibilityChecker.ts:338
private getCachedResult(key: string): CompatibilityIssue | null | undefined {
    const entry = this.cache.get(key);
    if (!entry) {
        return undefined;
    }

    const expiry = this.config.get<number>('nugetCacheExpiry', 3600) * 1000;
    const now = Date.now();
    
    if (now - entry.timestamp > expiry) {
        this.cache.delete(key);
        return undefined;
    }

    return entry.value;
}
Cache Keys: packageName|version|targetFramework
For large projects, keeping cache enabled significantly improves performance. Adjust nugetCacheExpiry based on how frequently you want fresh NuGet data.

Ignored Packages

You can ignore specific packages or patterns:
// From nugetCompatibilityChecker.ts:315
private isPackageIgnored(packageName: string): boolean {
    const ignoredPackages = this.config.get<string[]>('nugetIgnoredPackages', []);
    
    for (const pattern of ignoredPackages) {
        // Exact match
        if (pattern === packageName) {
            return true;
        }
        
        // Pattern match (simple wildcard support)
        const regexPattern = pattern
            .replace(/\./g, '\\.')
            .replace(/\*/g, '.*');
        
        const regex = new RegExp(`^${regexPattern}$`, 'i');
        if (regex.test(packageName)) {
            return true;
        }
    }
}

Example Ignore Patterns

{
  "dotnetBuildBuddy.nugetIgnoredPackages": [
    "MyCompany.Internal.Package",  // Exact match
    "MyCompany.Internal.*",         // Wildcard match
    "*.PrivatePackage"              // Suffix match
  ]
}

Framework Matching

Build Buddy understands .NET framework semantics:
// From nugetCompatibilityChecker.ts:503
private getFrameworkType(framework: string): string {
    const lower = framework.toLowerCase();
    if (lower.startsWith('netframework') || lower.match(/^net[1-4]\./)) {
        return 'netframework';
    }
    if (lower.startsWith('netcoreapp')) {
        return 'netcoreapp';
    }
    if (lower.startsWith('netstandard')) {
        return 'netstandard';
    }
    if (lower.startsWith('net')) {
        return 'net';  // Modern .NET (5+)
    }
    return 'unknown';
}

Framework Types

  • net - Modern .NET (5.0, 6.0, 7.0, 8.0)
  • netcoreapp - .NET Core (1.0-3.1)
  • netframework - .NET Framework (4.0-4.8)
  • netstandard - .NET Standard (1.0-2.1)

Best Practices

While local rules cover many packages, the NuGet API provides the most accurate and up-to-date compatibility information. Keep nugetApiEnabled: true for best results.
Enable caching (nugetCacheEnabled: true) to avoid repeated API calls. Set a reasonable expiry time (1-24 hours) based on your needs.
Add your company’s internal packages to nugetIgnoredPackages to avoid unnecessary API calls and false warnings.
When Build Buddy suggests a framework upgrade, consider it seriously. Modern frameworks offer better performance, security, and features.

Build docs developers (and LLMs) love