Supercharge your C# top-level programs with intelligent NuGet package autocomplete! This extension provides seamless autocomplete for #:package, #:sdk, #:property directives.
Complete IntelliSense support for .NET 10 file-based app directives in Visual Studio Code. Build and run C# applications directly from single .cs files with full autocomplete for packages, SDKs, and MSBuild properties.
By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all of the following statements:
- You unequivocally condemn Russia and its military aggression against Ukraine
- You recognize that Russia is an occupant that unlawfully invaded a sovereign state
- You agree that Russia is a terrorist state
- You fully support Ukraine's territorial integrity, including its claims over temporarily occupied territories
- You reject false narratives perpetuated by Russian state propaganda
To learn more about the war and how you can help, click here. Glory to Ukraine! πΊπ¦
- Type
#:packageand get instant autocomplete suggestions from the official NuGet repository - Intelligent search with fuzzy matching for package names
- Real-time package information with descriptions and download statistics
- Version management with
@syntax for easy version selection - Shows latest stable versions first (excludes pre-release by default)
- Full autocomplete for .NET SDKs including:
Microsoft.NET.Sdk- Console applications and class librariesMicrosoft.NET.Sdk.Web- ASP.NET Core applications and Web APIsMicrosoft.NET.Sdk.Worker- Background services and hosted servicesMicrosoft.NET.Sdk.WindowsDesktop- WPF and Windows Forms applicationsMicrosoft.NET.Sdk.Razor- Razor class libraries and componentsMicrosoft.NET.Sdk.BlazorWebAssembly- Blazor WebAssembly applications
- Rich documentation with SDK descriptions and default target frameworks
- Intelligent autocomplete for common MSBuild properties:
- LangVersion - C# language version (
latest,preview,12,11, etc.) - TargetFramework - Target framework (
net10.0,net9.0,net8.0, etc.) - Nullable - Nullable reference types (
enable,disable,warnings,annotations) - ImplicitUsings - Implicit using statements (
enable,disable) - PublishAot - Ahead-of-time compilation (
true,false) - TreatWarningsAsErrors - Compiler warning handling
- WarningLevel - Compiler warning levels (0-5)
- And many more...
- LangVersion - C# language version (
- Context-aware value suggestions with default values and descriptions
- Comprehensive hover information for all directive types
- Package descriptions, download counts, and direct links to NuGet
- SDK explanations with use cases and target frameworks
- Property documentation with possible values and defaults
- Visual indicators for package popularity and property defaults
- Intelligent caching reduces API calls and improves response time
- Non-blocking searches don't interrupt your coding flow
- Minimal resource usage with smart request batching
- Install .NET 10 Preview 4 or later from dotnet.microsoft.com
- Open Visual Studio Code
- Go to Extensions (
Ctrl+Shift+X) - Search for "C# Package Autocomplete"
- Click "Install"
- Create a C# file with
.csextension - Type any directive and get autocomplete:
#:package Humanizer@2.14.1 #:sdk Microsoft.NET.Sdk.Web #:property LangVersion preview
- Start typing and see intelligent suggestions
- Run your script with
dotnet run yourfile.cs
#:package Humanizer@2.14.1
using Humanizer;
var dotNet10Released = DateTimeOffset.Parse("2025-11-01");
var since = DateTimeOffset.Now - dotNet10Released;
Console.WriteLine($"It has been {since.Humanize()} since .NET 10 was released.");#:sdk Microsoft.NET.Sdk.Web
#:package Microsoft.AspNetCore.OpenApi@10.*-*
#:property LangVersion preview
var builder = WebApplication.CreateBuilder();
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();
app.MapGet("/", () => "Hello, World from .NET 10!");
app.MapGet("/time", () => new { Time = DateTime.Now, Message = "Current server time" });
app.Run();#:sdk Microsoft.NET.Sdk.Worker
#:package Microsoft.Extensions.Hosting@8.0.1
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<WorkerService>();
var host = builder.Build();
await host.RunAsync();
public class WorkerService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
Console.WriteLine($"Worker running at: {DateTimeOffset.Now}");
await Task.Delay(1000, stoppingToken);
}
}
}#:sdk Microsoft.NET.Sdk.Web
#:package FluentValidation@*
#:package FluentValidation.DependencyInjectionExtensions@*
#:package Serilog.AspNetCore@8.0.0
#:property LangVersion preview
#:property Nullable enable
#:property TreatWarningsAsErrors true
#:property EnablePreviewFeatures true
using FluentValidation;
using Serilog;
// Modern C# with preview features enabled
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseSerilog();
builder.Services.AddValidatorsFromAssemblyContaining<Program>();
var app = builder.Build();
app.MapPost("/user", async (CreateUserRequest request, IValidator<CreateUserRequest> validator) =>
{
var result = await validator.ValidateAsync(request);
return result.IsValid ? Results.Ok("User created") : Results.BadRequest(result.Errors);
});
app.Run();
public record CreateUserRequest(string Name, string Email);
public class CreateUserRequestValidator : AbstractValidator<CreateUserRequest>
{
public CreateUserRequestValidator()
{
RuleFor(x => x.Name).NotEmpty().MaximumLength(100);
RuleFor(x => x.Email).NotEmpty().EmailAddress();
}
}#:package PackageName@Version
#:package Newtonsoft.Json@13.0.3
#:package Microsoft.Extensions.Hosting@8.*#:sdk Microsoft.NET.Sdk // Console/Library (default)
#:sdk Microsoft.NET.Sdk.Web // ASP.NET Core
#:sdk Microsoft.NET.Sdk.Worker // Background Services
#:sdk Microsoft.NET.Sdk.WindowsDesktop // WPF/WinForms#:property LangVersion preview // C# language version
#:property TargetFramework net10.0 // Target framework
#:property Nullable enable // Nullable reference types
#:property ImplicitUsings enable // Implicit usings
#:property PublishAot true // AOT compilationNo configuration needed! The extension works out of the box with sensible defaults.
Future versions may include these customizable settings:
- Cache duration for package searches
- Number of suggestions to display
- Include/exclude pre-release packages
- Custom package source URLs
- Additional MSBuild properties
- Visual Studio Code 1.103.0 or higher
- .NET 10 Preview 4 or later with file-based app support
- C# Dev Kit extension (recommended) for best experience
- Internet connection for package search (cached results work offline)
- Install the C# Dev Kit extension
- Switch to Pre-Release version of the C# extension (version 2.79.8+)
- Ensure you have .NET 10 Preview 4 installed
- Network dependency: Requires internet connection for initial package searches
- API rate limits: Heavy usage might temporarily reduce suggestion speed
- Case sensitivity: Package names are case-sensitive in NuGet
- SDK validation: Some custom SDKs may not be recognized for autocomplete
- Custom package sources - Support for private NuGet feeds and Azure Artifacts
- Enhanced property validation - Real-time validation of property values
- Project conversion hints - Suggestions for converting to full projects
- Dependency visualization - Show package dependency trees
- Version comparison - Compare versions with changelogs
- Package templates - Quick scaffolding for common scenarios
- Offline mode - Enhanced offline package suggestions
- Multi-file support - Support for file-based apps with multiple files
- Debug support - Enhanced debugging experience for file-based apps
We welcome contributions! Here's how you can help:
- Report bugs by creating issues on GitHub
- Request features through GitHub discussions
- Submit pull requests for bug fixes or new features
- Share feedback and rate the extension
- Add SDK or property definitions for better autocomplete coverage
# Clone the repository
git clone https://github.com/TarasKovalenko/csharp-filebased-directive-support
# Install dependencies
npm ci
# Compile TypeScript
npm run compile
# Run tests
npm test
# Package extension
npm run packageCreate test files and run them:
# Create a test file
echo '#:package [email protected]
using Humanizer;
Console.WriteLine("Hello".Humanize());' > test.cs
# Run with .NET 10
dotnet run test.cs
# Convert to project when ready
dotnet project convert test.csThis project is licensed under the MIT License - see the LICENSE file for details.
If you find this extension helpful:
- β Star the repository on GitHub
- π Leave a review on the VS Code Marketplace
- π¦ Share it with your fellow developers
- π¬ Join discussions about .NET 10 file-based apps
- Microsoft .NET Team for the innovative file-based apps feature in .NET 10
- NuGet team for the comprehensive package API
- VS Code team for the excellent extension platform
- C# Dev Kit team for the enhanced C# experience
- Community for feedback, bug reports, and feature requests
Transform your C# development with single-file simplicity! π
Made with β€οΈ for the .NET community
