mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
Merge branch 'main' into structured-autonomy-plan-prompt-fix
This commit is contained in:
@@ -154,6 +154,7 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for
|
||||
| [Style Components with Modern Theming (Preview)](../instructions/pcf-fluent-modern-theming.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpcf-fluent-modern-theming.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpcf-fluent-modern-theming.instructions.md) | Style components with modern theming using Fluent UI |
|
||||
| [Svelte 5 and SvelteKit Development Instructions](../instructions/svelte.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsvelte.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fsvelte.instructions.md) | Svelte 5 and SvelteKit development standards and best practices for component-based user interfaces and full-stack applications |
|
||||
| [Swift MCP Server Development Guidelines](../instructions/swift-mcp-server.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fswift-mcp-server.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fswift-mcp-server.instructions.md) | Best practices and patterns for building Model Context Protocol (MCP) servers in Swift using the official MCP Swift SDK package. |
|
||||
| [Symfony Development Instructions](../instructions/php-symfony.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fphp-symfony.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fphp-symfony.instructions.md) | Symfony development standards aligned with official Symfony Best Practices |
|
||||
| [Taming Copilot](../instructions/taming-copilot.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftaming-copilot.instructions.md) | Prevent Copilot from wreaking havoc across your codebase, keeping it under control. |
|
||||
| [TanStack Start with Shadcn/ui Development Guide](../instructions/tanstack-start-shadcn-tailwind.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md) | Guidelines for building TanStack Start applications |
|
||||
| [Task Plan Implementation Instructions](../instructions/task-implementation.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftask-implementation.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftask-implementation.instructions.md) | Instructions for implementing task plans with progressive tracking and change record - Brought to you by microsoft/edge-ai |
|
||||
@@ -167,5 +168,6 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for
|
||||
| [Update Documentation on Code Change](../instructions/update-docs-on-code-change.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-docs-on-code-change.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fupdate-docs-on-code-change.instructions.md) | Automatically update README.md and documentation files when application code changes require documentation updates |
|
||||
| [Upgrading from .NET MAUI 9 to .NET MAUI 10](../instructions/dotnet-maui-9-to-dotnet-maui-10-upgrade.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fdotnet-maui-9-to-dotnet-maui-10-upgrade.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fdotnet-maui-9-to-dotnet-maui-10-upgrade.instructions.md) | Instructions for upgrading .NET MAUI applications from version 9 to version 10, including breaking changes, deprecated APIs, and migration strategies for ListView to CollectionView. |
|
||||
| [Use Code Components in Power Pages](../instructions/pcf-power-pages.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpcf-power-pages.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fpcf-power-pages.instructions.md) | Using code components in Power Pages sites |
|
||||
| [Visual Studio Extension Development with Community.VisualStudio.Toolkit](../instructions/vsixtoolkit.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvsixtoolkit.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvsixtoolkit.instructions.md) | Guidelines for Visual Studio extension (VSIX) development using Community.VisualStudio.Toolkit |
|
||||
| [VueJS 3 Development Instructions](../instructions/vuejs3.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.instructions.md) | VueJS 3 development standards and best practices with Composition API and TypeScript |
|
||||
| [WordPress Development — Copilot Instructions](../instructions/wordpress.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fwordpress.instructions.md)<br />[](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fwordpress.instructions.md) | Coding, security, and testing rules for WordPress plugins and themes |
|
||||
|
||||
@@ -23,5 +23,6 @@ Skills differ from other primitives by supporting bundled assets (scripts, code
|
||||
| Name | Description | Bundled Assets |
|
||||
| ---- | ----------- | -------------- |
|
||||
| [azure-role-selector](../skills/azure-role-selector/SKILL.md) | When user is asking for guidance for which role to assign to an identity given desired permissions, this agent helps them understand the role that will meet the requirements with least privilege access and how to apply that role. | `LICENSE.txt` |
|
||||
| [nuget-manager](../skills/nuget-manager/SKILL.md) | Manage NuGet packages in .NET projects/solutions. Use this skill when adding, removing, or updating NuGet package versions. It enforces using `dotnet` CLI for package management and provides strict procedures for direct file edits only when updating versions. | None |
|
||||
| [snowflake-semanticview](../skills/snowflake-semanticview/SKILL.md) | Create, alter, and validate Snowflake semantic views using Snowflake CLI (snow). Use when asked to build or troubleshoot semantic views/semantic layer definitions with CREATE/ALTER SEMANTIC VIEW, to validate semantic-view DDL against Snowflake via CLI, or to guide Snowflake CLI installation and connection setup. | None |
|
||||
| [webapp-testing](../skills/webapp-testing/SKILL.md) | Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs. | `test-helper.js` |
|
||||
|
||||
122
instructions/php-symfony.instructions.md
Normal file
122
instructions/php-symfony.instructions.md
Normal file
@@ -0,0 +1,122 @@
|
||||
---
|
||||
description: "Symfony development standards aligned with official Symfony Best Practices"
|
||||
applyTo: "**/*.php, **/*.yaml, **/*.yml, **/*.xml, **/*.twig"
|
||||
---
|
||||
|
||||
# Symfony Development Instructions
|
||||
|
||||
Instructions for developing Symfony applications following the official Symfony Best Practices and core framework philosophy.
|
||||
|
||||
## Project Context
|
||||
- Symfony (latest stable or LTS)
|
||||
- Default Symfony directory structure
|
||||
- Autowiring and autoconfiguration enabled
|
||||
- Doctrine ORM when persistence is needed
|
||||
- Twig for templating
|
||||
- Symfony Forms, Validator, Security, Messenger as needed
|
||||
- PHPUnit for testing
|
||||
- Attribute-based configuration where supported
|
||||
|
||||
## Project Structure
|
||||
- Use the default Symfony directory structure
|
||||
- Do not create bundles for application code
|
||||
- Organize application code using PHP namespaces
|
||||
- Keep configuration in `config/`, application code in `src/`, templates in `templates/`
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Configuration
|
||||
- Use environment variables for infrastructure-related configuration
|
||||
- Use `.env` files to define environment-specific values
|
||||
- Do not use environment variables to control application behavior
|
||||
|
||||
### Sensitive Configuration
|
||||
- Store secrets (API keys, credentials) using Symfony Secrets
|
||||
- Never commit secrets to the repository
|
||||
|
||||
### Application Configuration
|
||||
- Use parameters in `config/services.yaml` for application behavior configuration
|
||||
- Override parameters per environment only when needed
|
||||
- Prefix parameters with `app.` to avoid collisions
|
||||
- Use short, descriptive parameter names
|
||||
- Use PHP constants for configuration values that rarely change
|
||||
|
||||
## Services & Dependency Injection
|
||||
- Use dependency injection exclusively
|
||||
- Prefer constructor injection
|
||||
- Use autowiring and autoconfiguration by default
|
||||
- Keep services private whenever possible
|
||||
- Avoid accessing services via `$container->get()`
|
||||
- Use YAML as the preferred format for service configuration
|
||||
- Use interfaces where it improves decoupling or clarity
|
||||
|
||||
## Controllers
|
||||
- Extend `AbstractController`
|
||||
- Keep controllers thin and focused on glue code
|
||||
- Do not place business logic in controllers
|
||||
- Use attributes to configure routing, caching, and security
|
||||
- Use dependency injection for services
|
||||
- Use Entity Value Resolvers when convenient and appropriate
|
||||
- Perform complex queries explicitly via repositories when needed
|
||||
|
||||
## Doctrine & Persistence
|
||||
- Use Doctrine entities as plain PHP objects
|
||||
- Define Doctrine mapping using PHP attributes
|
||||
- Use repositories for querying data
|
||||
- Avoid putting business logic in repositories
|
||||
- Use migrations for all schema changes
|
||||
|
||||
## Templates (Twig)
|
||||
- Use snake_case for template names, directories, and variables
|
||||
- Prefix template fragments with an underscore
|
||||
- Keep templates focused on presentation
|
||||
- Avoid business logic in Twig templates
|
||||
- Escape output by default
|
||||
- Avoid using `|raw` unless content is trusted and sanitized
|
||||
|
||||
## Forms
|
||||
- Define forms as PHP classes
|
||||
- Do not build forms directly in controllers
|
||||
- Add form buttons in templates, not in form classes
|
||||
- Define validation constraints on the underlying object
|
||||
- Use a single controller action to render and process each form
|
||||
- Define submit buttons in controllers only when multiple submits are required
|
||||
|
||||
## Validation
|
||||
- Use Symfony Validator constraints
|
||||
- Validate data at application boundaries
|
||||
- Prefer object-level validation over form-only validation when reuse is needed
|
||||
|
||||
## Internationalization
|
||||
- Use XLIFF for translation files
|
||||
- Use translation keys instead of literal content strings
|
||||
- Use descriptive keys that express purpose, not location
|
||||
|
||||
## Security
|
||||
- Prefer a single firewall unless multiple systems are required
|
||||
- Use the auto password hasher
|
||||
- Use voters for complex authorization logic
|
||||
- Avoid complex security expressions in attributes
|
||||
|
||||
## Web Assets
|
||||
- Use AssetMapper to manage web assets
|
||||
- Avoid unnecessary frontend build complexity unless required
|
||||
|
||||
## Asynchronous Processing
|
||||
- Use Symfony Messenger for async and background tasks
|
||||
- Keep message handlers small and focused
|
||||
- Configure failure transports for failed messages
|
||||
|
||||
## Testing
|
||||
- Write functional tests using `WebTestCase`
|
||||
- Add smoke tests to ensure all public URLs respond successfully
|
||||
- Hard-code URLs in functional tests instead of generating routes
|
||||
- Use unit tests where appropriate for isolated logic
|
||||
- Add more specific tests incrementally as the application evolves
|
||||
|
||||
## General Guidelines
|
||||
- Prefer clarity over abstraction
|
||||
- Follow Symfony conventions before introducing custom patterns
|
||||
- Keep configuration explicit and readable
|
||||
- Avoid premature optimization
|
||||
- Use Symfony Demo as a reference implementation
|
||||
647
instructions/vsixtoolkit.instructions.md
Normal file
647
instructions/vsixtoolkit.instructions.md
Normal file
@@ -0,0 +1,647 @@
|
||||
---
|
||||
description: 'Guidelines for Visual Studio extension (VSIX) development using Community.VisualStudio.Toolkit'
|
||||
applyTo: '**/*.cs, **/*.vsct, **/*.xaml, **/source.extension.vsixmanifest'
|
||||
---
|
||||
|
||||
# Visual Studio Extension Development with Community.VisualStudio.Toolkit
|
||||
|
||||
## Scope
|
||||
|
||||
**These instructions apply ONLY to Visual Studio extensions using `Community.VisualStudio.Toolkit`.**
|
||||
|
||||
Verify the project uses the toolkit by checking for:
|
||||
- `Community.VisualStudio.Toolkit.*` NuGet package reference
|
||||
- `ToolkitPackage` base class (not raw `AsyncPackage`)
|
||||
- `BaseCommand<T>` pattern for commands
|
||||
|
||||
**If the project uses raw VSSDK (`AsyncPackage` directly) or the new `VisualStudio.Extensibility` model, do not apply these instructions.**
|
||||
|
||||
## Goals
|
||||
|
||||
- Generate async-first, thread-safe extension code
|
||||
- Use toolkit abstractions (`VS.*` helpers, `BaseCommand<T>`, `BaseOptionModel<T>`)
|
||||
- Ensure all UI respects Visual Studio themes
|
||||
- Follow VSSDK and VSTHRD analyzer rules
|
||||
- Produce testable, maintainable extension code
|
||||
|
||||
## Example Prompt Behaviors
|
||||
|
||||
### ✅ Good Suggestions
|
||||
- "Create a command that opens the current file's containing folder using `BaseCommand<T>`"
|
||||
- "Add an options page with a boolean setting using `BaseOptionModel<T>`"
|
||||
- "Write a tagger provider for C# files that highlights TODO comments"
|
||||
- "Show a status bar progress indicator while processing files"
|
||||
|
||||
### ❌ Avoid
|
||||
- Suggesting raw `AsyncPackage` instead of `ToolkitPackage`
|
||||
- Using `OleMenuCommandService` directly instead of `BaseCommand<T>`
|
||||
- Creating WPF elements without switching to UI thread first
|
||||
- Using `.Result`, `.Wait()`, or `Task.Run` for UI work
|
||||
- Hardcoding colors instead of using VS theme colors
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── Commands/ # Command handlers (menu items, toolbar buttons)
|
||||
├── Options/ # Settings/options pages
|
||||
├── Services/ # Business logic and services
|
||||
├── Tagging/ # ITagger implementations (syntax highlighting, outlining)
|
||||
├── Adornments/ # Editor adornments (IntraTextAdornment, margins)
|
||||
├── QuickInfo/ # QuickInfo/tooltip providers
|
||||
├── SuggestedActions/ # Light bulb actions
|
||||
├── Handlers/ # Event handlers (format document, paste, etc.)
|
||||
├── Resources/ # Images, icons, license files
|
||||
├── source.extension.vsixmanifest # Extension manifest
|
||||
├── VSCommandTable.vsct # Command definitions (menus, buttons)
|
||||
├── VSCommandTable.cs # Auto-generated command IDs
|
||||
└── *Package.cs # Main package class
|
||||
```
|
||||
|
||||
## Community.VisualStudio.Toolkit Patterns
|
||||
|
||||
### Global Usings
|
||||
|
||||
Extensions using the toolkit should have these global usings in the Package file:
|
||||
|
||||
```csharp
|
||||
global using System;
|
||||
global using Community.VisualStudio.Toolkit;
|
||||
global using Microsoft.VisualStudio.Shell;
|
||||
global using Task = System.Threading.Tasks.Task;
|
||||
```
|
||||
|
||||
### Package Class
|
||||
|
||||
```csharp
|
||||
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
|
||||
[InstalledProductRegistration(Vsix.Name, Vsix.Description, Vsix.Version)]
|
||||
[ProvideMenuResource("Menus.ctmenu", 1)]
|
||||
[Guid(PackageGuids.YourExtensionString)]
|
||||
[ProvideOptionPage(typeof(OptionsProvider.GeneralOptions), Vsix.Name, "General", 0, 0, true, SupportsProfiles = true)]
|
||||
public sealed class YourPackage : ToolkitPackage
|
||||
{
|
||||
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
|
||||
{
|
||||
await this.RegisterCommandsAsync();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
Commands use the `[Command]` attribute and inherit from `BaseCommand<T>`:
|
||||
|
||||
```csharp
|
||||
[Command(PackageIds.YourCommandId)]
|
||||
internal sealed class YourCommand : BaseCommand<YourCommand>
|
||||
{
|
||||
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
|
||||
{
|
||||
// Command implementation
|
||||
}
|
||||
|
||||
// Optional: Control command state (enabled, checked, visible)
|
||||
protected override void BeforeQueryStatus(EventArgs e)
|
||||
{
|
||||
Command.Checked = someCondition;
|
||||
Command.Enabled = anotherCondition;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Options Pages
|
||||
|
||||
```csharp
|
||||
internal partial class OptionsProvider
|
||||
{
|
||||
[ComVisible(true)]
|
||||
public class GeneralOptions : BaseOptionPage<General> { }
|
||||
}
|
||||
|
||||
public class General : BaseOptionModel<General>
|
||||
{
|
||||
[Category("Category Name")]
|
||||
[DisplayName("Setting Name")]
|
||||
[Description("Description of the setting.")]
|
||||
[DefaultValue(true)]
|
||||
public bool MySetting { get; set; } = true;
|
||||
}
|
||||
```
|
||||
|
||||
## MEF Components
|
||||
|
||||
### Tagger Providers
|
||||
|
||||
Use `[Export]` and appropriate `[ContentType]` attributes:
|
||||
|
||||
```csharp
|
||||
[Export(typeof(IViewTaggerProvider))]
|
||||
[ContentType("CSharp")]
|
||||
[ContentType("Basic")]
|
||||
[TagType(typeof(IntraTextAdornmentTag))]
|
||||
[TextViewRole(PredefinedTextViewRoles.Document)]
|
||||
internal sealed class YourTaggerProvider : IViewTaggerProvider
|
||||
{
|
||||
[Import]
|
||||
internal IOutliningManagerService OutliningManagerService { get; set; }
|
||||
|
||||
public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
|
||||
{
|
||||
if (textView == null || !(textView is IWpfTextView wpfTextView))
|
||||
return null;
|
||||
|
||||
if (textView.TextBuffer != buffer)
|
||||
return null;
|
||||
|
||||
return wpfTextView.Properties.GetOrCreateSingletonProperty(
|
||||
() => new YourTagger(wpfTextView)) as ITagger<T>;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### QuickInfo Sources
|
||||
|
||||
```csharp
|
||||
[Export(typeof(IAsyncQuickInfoSourceProvider))]
|
||||
[Name("YourQuickInfo")]
|
||||
[ContentType("code")]
|
||||
[Order(Before = "Default Quick Info Presenter")]
|
||||
internal sealed class YourQuickInfoSourceProvider : IAsyncQuickInfoSourceProvider
|
||||
{
|
||||
public IAsyncQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
|
||||
{
|
||||
return textBuffer.Properties.GetOrCreateSingletonProperty(
|
||||
() => new YourQuickInfoSource(textBuffer));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Suggested Actions (Light Bulb)
|
||||
|
||||
```csharp
|
||||
[Export(typeof(ISuggestedActionsSourceProvider))]
|
||||
[Name("Your Suggested Actions")]
|
||||
[ContentType("text")]
|
||||
internal sealed class YourSuggestedActionsSourceProvider : ISuggestedActionsSourceProvider
|
||||
{
|
||||
public ISuggestedActionsSource CreateSuggestedActionsSource(ITextView textView, ITextBuffer textBuffer)
|
||||
{
|
||||
return new YourSuggestedActionsSource(textView, textBuffer);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Threading Guidelines
|
||||
|
||||
### Always switch to UI thread for WPF operations
|
||||
|
||||
```csharp
|
||||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
|
||||
// Now safe to create/modify WPF elements
|
||||
```
|
||||
|
||||
### Background work
|
||||
|
||||
```csharp
|
||||
ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
|
||||
{
|
||||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
|
||||
await VS.Commands.ExecuteAsync("View.TaskList");
|
||||
});
|
||||
```
|
||||
|
||||
## VSSDK & Threading Analyzer Rules
|
||||
|
||||
Extensions should enforce these analyzer rules. Add to `.editorconfig`:
|
||||
|
||||
```ini
|
||||
dotnet_diagnostic.VSSDK*.severity = error
|
||||
dotnet_diagnostic.VSTHRD*.severity = error
|
||||
```
|
||||
|
||||
### Performance Rules
|
||||
| ID | Rule | Fix |
|
||||
|----|------|-----|
|
||||
| **VSSDK001** | Derive from `AsyncPackage` | Use `ToolkitPackage` (derives from AsyncPackage) |
|
||||
| **VSSDK002** | `AllowsBackgroundLoading = true` | Add to `[PackageRegistration]` |
|
||||
|
||||
### Threading Rules (VSTHRD)
|
||||
| ID | Rule | Fix |
|
||||
|----|------|-----|
|
||||
| **VSTHRD001** | Avoid `.Wait()` | Use `await` |
|
||||
| **VSTHRD002** | Avoid `JoinableTaskFactory.Run` | Use `RunAsync` or `await` |
|
||||
| **VSTHRD010** | COM calls require UI thread | `await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync()` |
|
||||
| **VSTHRD100** | No `async void` | Use `async Task` |
|
||||
| **VSTHRD110** | Observe async results | `await task;` or suppress with pragma |
|
||||
|
||||
## Visual Studio Theming
|
||||
|
||||
**All UI must respect VS themes (Light, Dark, Blue, High Contrast)**
|
||||
|
||||
### WPF Theming with Environment Colors
|
||||
|
||||
```xml
|
||||
<!-- MyControl.xaml -->
|
||||
<UserControl x:Class="MyExt.MyControl"
|
||||
xmlns:vsui="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0">
|
||||
<Grid Background="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowBackgroundBrushKey}}">
|
||||
<TextBlock Foreground="{DynamicResource {x:Static vsui:EnvironmentColors.ToolWindowTextBrushKey}}"
|
||||
Text="Hello, themed world!" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
```
|
||||
|
||||
### Toolkit Auto-Theming (Recommended)
|
||||
|
||||
The toolkit provides automatic theming for WPF UserControls:
|
||||
|
||||
```xml
|
||||
<UserControl x:Class="MyExt.MyUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"
|
||||
toolkit:Themes.UseVsTheme="True">
|
||||
<!-- Controls automatically get VS styling -->
|
||||
</UserControl>
|
||||
```
|
||||
|
||||
For dialog windows, use `DialogWindow`:
|
||||
|
||||
```xml
|
||||
<platform:DialogWindow
|
||||
x:Class="MyExt.MyDialog"
|
||||
xmlns:platform="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.15.0"
|
||||
xmlns:toolkit="clr-namespace:Community.VisualStudio.Toolkit;assembly=Community.VisualStudio.Toolkit"
|
||||
toolkit:Themes.UseVsTheme="True">
|
||||
</platform:DialogWindow>
|
||||
```
|
||||
|
||||
### Common Theme Color Tokens
|
||||
|
||||
| Category | Token | Usage |
|
||||
|----------|-------|-------|
|
||||
| **Background** | `EnvironmentColors.ToolWindowBackgroundBrushKey` | Window/panel background |
|
||||
| **Foreground** | `EnvironmentColors.ToolWindowTextBrushKey` | Text |
|
||||
| **Command Bar** | `EnvironmentColors.CommandBarTextActiveBrushKey` | Menu items |
|
||||
| **Links** | `EnvironmentColors.ControlLinkTextBrushKey` | Hyperlinks |
|
||||
|
||||
### Theme-Aware Icons
|
||||
|
||||
Use `KnownMonikers` from the VS Image Catalog for theme-aware icons:
|
||||
|
||||
```csharp
|
||||
public ImageMoniker IconMoniker => KnownMonikers.Settings;
|
||||
```
|
||||
|
||||
In VSCT:
|
||||
```xml
|
||||
<Icon guid="ImageCatalogGuid" id="Settings"/>
|
||||
<CommandFlag>IconIsMoniker</CommandFlag>
|
||||
```
|
||||
|
||||
## Common VS SDK APIs
|
||||
|
||||
### VS Helper Methods (Community.VisualStudio.Toolkit)
|
||||
|
||||
```csharp
|
||||
// Status bar
|
||||
await VS.StatusBar.ShowMessageAsync("Message");
|
||||
await VS.StatusBar.ShowProgressAsync("Working...", currentStep, totalSteps);
|
||||
|
||||
// Solution/Projects
|
||||
Solution solution = await VS.Solutions.GetCurrentSolutionAsync();
|
||||
IEnumerable<SolutionItem> items = await VS.Solutions.GetActiveItemsAsync();
|
||||
bool isOpen = await VS.Solutions.IsOpenAsync();
|
||||
|
||||
// Documents
|
||||
DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync();
|
||||
string text = docView?.TextBuffer?.CurrentSnapshot.GetText();
|
||||
await VS.Documents.OpenAsync(fileName);
|
||||
await VS.Documents.OpenInPreviewTabAsync(fileName);
|
||||
|
||||
// Commands
|
||||
await VS.Commands.ExecuteAsync("View.TaskList");
|
||||
|
||||
// Settings
|
||||
await VS.Settings.OpenAsync<OptionsProvider.GeneralOptions>();
|
||||
|
||||
// Messages
|
||||
await VS.MessageBox.ShowAsync("Title", "Message");
|
||||
await VS.MessageBox.ShowErrorAsync("Extension Name", ex.ToString());
|
||||
|
||||
// Events
|
||||
VS.Events.SolutionEvents.OnAfterOpenProject += OnAfterOpenProject;
|
||||
VS.Events.DocumentEvents.Saved += OnDocumentSaved;
|
||||
```
|
||||
|
||||
### Working with Settings
|
||||
|
||||
```csharp
|
||||
// Read settings synchronously
|
||||
var value = General.Instance.MyOption;
|
||||
|
||||
// Read settings asynchronously
|
||||
var general = await General.GetLiveInstanceAsync();
|
||||
var value = general.MyOption;
|
||||
|
||||
// Write settings
|
||||
General.Instance.MyOption = newValue;
|
||||
General.Instance.Save();
|
||||
|
||||
// Or async
|
||||
general.MyOption = newValue;
|
||||
await general.SaveAsync();
|
||||
|
||||
// Listen for settings changes
|
||||
General.Saved += OnSettingsSaved;
|
||||
```
|
||||
|
||||
### Text Buffer Operations
|
||||
|
||||
```csharp
|
||||
// Get snapshot
|
||||
ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
|
||||
|
||||
// Get line
|
||||
ITextSnapshotLine line = snapshot.GetLineFromLineNumber(lineNumber);
|
||||
string lineText = line.GetText();
|
||||
|
||||
// Create tracking span
|
||||
ITrackingSpan trackingSpan = snapshot.CreateTrackingSpan(span, SpanTrackingMode.EdgeInclusive);
|
||||
|
||||
// Edit buffer
|
||||
using (ITextEdit edit = textBuffer.CreateEdit())
|
||||
{
|
||||
edit.Replace(span, newText);
|
||||
edit.Apply();
|
||||
}
|
||||
|
||||
// Insert at caret position
|
||||
DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync();
|
||||
if (docView?.TextView != null)
|
||||
{
|
||||
SnapshotPoint position = docView.TextView.Caret.Position.BufferPosition;
|
||||
docView.TextBuffer?.Insert(position, "text to insert");
|
||||
}
|
||||
```
|
||||
|
||||
## VSCT Command Table
|
||||
|
||||
### Menu/Command Structure
|
||||
|
||||
```xml
|
||||
<Commands package="YourPackage">
|
||||
<Menus>
|
||||
<Menu guid="YourPackage" id="SubMenu" type="Menu">
|
||||
<Parent guid="YourPackage" id="MenuGroup"/>
|
||||
<Strings>
|
||||
<ButtonText>Menu Name</ButtonText>
|
||||
<CommandName>Menu Name</CommandName>
|
||||
<CanonicalName>.YourExtension.MenuName</CanonicalName>
|
||||
</Strings>
|
||||
</Menu>
|
||||
</Menus>
|
||||
|
||||
<Groups>
|
||||
<Group guid="YourPackage" id="MenuGroup" priority="0x0600">
|
||||
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
|
||||
</Group>
|
||||
</Groups>
|
||||
|
||||
<Buttons>
|
||||
<Button guid="YourPackage" id="CommandId" type="Button">
|
||||
<Parent guid="YourPackage" id="MenuGroup"/>
|
||||
<Icon guid="ImageCatalogGuid" id="Settings"/>
|
||||
<CommandFlag>IconIsMoniker</CommandFlag>
|
||||
<CommandFlag>DynamicVisibility</CommandFlag>
|
||||
<Strings>
|
||||
<ButtonText>Command Name</ButtonText>
|
||||
<CanonicalName>.YourExtension.CommandName</CanonicalName>
|
||||
</Strings>
|
||||
</Button>
|
||||
</Buttons>
|
||||
</Commands>
|
||||
|
||||
<Symbols>
|
||||
<GuidSymbol name="YourPackage" value="{guid-here}">
|
||||
<IDSymbol name="MenuGroup" value="0x0001"/>
|
||||
<IDSymbol name="CommandId" value="0x0100"/>
|
||||
</GuidSymbol>
|
||||
</Symbols>
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Performance
|
||||
|
||||
- Check file/buffer size before processing large documents
|
||||
- Use `NormalizedSnapshotSpanCollection` for efficient span operations
|
||||
- Cache parsed results when possible
|
||||
- Use `ConfigureAwait(false)` in library code
|
||||
|
||||
```csharp
|
||||
// Skip large files
|
||||
if (buffer.CurrentSnapshot.Length > 150000)
|
||||
return null;
|
||||
```
|
||||
|
||||
### 2. Error Handling
|
||||
|
||||
- Wrap external operations in try-catch
|
||||
- Log errors appropriately
|
||||
- Never let exceptions crash VS
|
||||
|
||||
```csharp
|
||||
try
|
||||
{
|
||||
// Operation
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await ex.LogAsync();
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Disposable Resources
|
||||
|
||||
- Implement `IDisposable` on taggers and other long-lived objects
|
||||
- Unsubscribe from events in Dispose
|
||||
|
||||
```csharp
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
_buffer.Changed -= OnBufferChanged;
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Content Types
|
||||
|
||||
Common content types for `[ContentType]` attribute:
|
||||
- `"text"` - All text files
|
||||
- `"code"` - All code files
|
||||
- `"CSharp"` - C# files
|
||||
- `"Basic"` - VB.NET files
|
||||
- `"CSS"`, `"LESS"`, `"SCSS"` - Style files
|
||||
- `"TypeScript"`, `"JavaScript"` - Script files
|
||||
- `"HTML"`, `"HTMLX"` - HTML files
|
||||
- `"XML"` - XML files
|
||||
- `"JSON"` - JSON files
|
||||
|
||||
### 5. Images and Icons
|
||||
|
||||
Use `KnownMonikers` from the VS Image Catalog:
|
||||
|
||||
```csharp
|
||||
public ImageMoniker IconMoniker => KnownMonikers.Settings;
|
||||
```
|
||||
|
||||
In VSCT:
|
||||
```xml
|
||||
<Icon guid="ImageCatalogGuid" id="Settings"/>
|
||||
<CommandFlag>IconIsMoniker</CommandFlag>
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
- Use `[VsTestMethod]` for tests requiring VS context
|
||||
- Mock VS services when possible
|
||||
- Test business logic separately from VS integration
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
| Pitfall | Solution |
|
||||
|---------|----------|
|
||||
| Blocking UI thread | Always use `async`/`await` |
|
||||
| Creating WPF on background thread | Call `SwitchToMainThreadAsync()` first |
|
||||
| Ignoring cancellation tokens | Pass them through async chains |
|
||||
| VSCommandTable.cs mismatch | Regenerate after VSCT changes |
|
||||
| Hardcoded GUIDs | Use `PackageGuids` and `PackageIds` constants |
|
||||
| Swallowing exceptions | Log with `await ex.LogAsync()` |
|
||||
| Missing DynamicVisibility | Required for `BeforeQueryStatus` to work |
|
||||
| Using `.Result`, `.Wait()` | Causes deadlocks; always `await` |
|
||||
| Hardcoded colors | Use VS theme colors (`EnvironmentColors`) |
|
||||
| `async void` methods | Use `async Task` instead |
|
||||
|
||||
## Validation
|
||||
|
||||
Build and verify the extension:
|
||||
|
||||
```bash
|
||||
msbuild /t:rebuild
|
||||
```
|
||||
|
||||
Ensure analyzers are enabled in `.editorconfig`:
|
||||
|
||||
```ini
|
||||
dotnet_diagnostic.VSSDK*.severity = error
|
||||
dotnet_diagnostic.VSTHRD*.severity = error
|
||||
```
|
||||
|
||||
Test in VS Experimental Instance before release.
|
||||
|
||||
## NuGet Packages
|
||||
|
||||
| Package | Purpose |
|
||||
|---------|---------|
|
||||
| `Community.VisualStudio.Toolkit.17` | Simplifies VS extension development |
|
||||
| `Microsoft.VisualStudio.SDK` | Core VS SDK |
|
||||
| `Microsoft.VSSDK.BuildTools` | Build tools for VSIX |
|
||||
| `Microsoft.VisualStudio.Threading.Analyzers` | Threading analyzers |
|
||||
| `Microsoft.VisualStudio.SDK.Analyzers` | VSSDK analyzers |
|
||||
|
||||
## Resources
|
||||
|
||||
- [Community.VisualStudio.Toolkit](https://github.com/VsixCommunity/Community.VisualStudio.Toolkit)
|
||||
- [VS Extensibility Docs](https://learn.microsoft.com/en-us/visualstudio/extensibility/)
|
||||
- [VSIX Community Samples](https://github.com/VsixCommunity/Samples)
|
||||
|
||||
## README and Marketplace Presentation
|
||||
|
||||
A good README works on both GitHub and the VS Marketplace. The Marketplace uses the README.md as the extension's description page.
|
||||
|
||||
### README Structure
|
||||
|
||||
```markdown
|
||||
[marketplace]: https://marketplace.visualstudio.com/items?itemName=Publisher.ExtensionName
|
||||
[repo]: https://github.com/user/repo
|
||||
|
||||
# Extension Name
|
||||
|
||||
[](...)
|
||||
[][marketplace]
|
||||
[][marketplace]
|
||||
|
||||
Download this extension from the [Visual Studio Marketplace][marketplace]
|
||||
or get the [CI build](http://vsixgallery.com/extension/ExtensionId/).
|
||||
|
||||
--------------------------------------
|
||||
|
||||
**Hook line that sells the extension in one sentence.**
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
### Feature 1
|
||||
Description with screenshot...
|
||||
|
||||
## How to Use
|
||||
...
|
||||
|
||||
## License
|
||||
[Apache 2.0](LICENSE)
|
||||
```
|
||||
|
||||
### README Best Practices
|
||||
|
||||
| Element | Guideline |
|
||||
|---------|-----------|
|
||||
| **Title** | Use the same name as `DisplayName` in vsixmanifest |
|
||||
| **Hook line** | Bold, one-sentence value proposition immediately after badges |
|
||||
| **Screenshots** | Place in `/art` folder, use relative paths (`art/image.png`) |
|
||||
| **Image sizes** | Keep under 1MB, 800-1200px wide for clarity |
|
||||
| **Badges** | Version, downloads, rating, build status |
|
||||
| **Feature sections** | Use H3 (`###`) with screenshots for each major feature |
|
||||
| **Keyboard shortcuts** | Format as **Ctrl+M, Ctrl+C** (bold) |
|
||||
| **Tables** | Great for comparing options or listing features |
|
||||
| **Links** | Use reference-style links at top for cleaner markdown |
|
||||
|
||||
### VSIX Manifest (source.extension.vsixmanifest)
|
||||
|
||||
```xml
|
||||
<Metadata>
|
||||
<Identity Id="ExtensionName.guid-here" Version="1.0.0" Language="en-US" Publisher="Your Name" />
|
||||
<DisplayName>Extension Name</DisplayName>
|
||||
<Description xml:space="preserve">Short, compelling description under 200 chars. This appears in search results and the extension tile.</Description>
|
||||
<MoreInfo>https://github.com/user/repo</MoreInfo>
|
||||
<License>Resources\LICENSE.txt</License>
|
||||
<Icon>Resources\Icon.png</Icon>
|
||||
<PreviewImage>Resources\Preview.png</PreviewImage>
|
||||
<Tags>keyword1, keyword2, keyword3</Tags>
|
||||
</Metadata>
|
||||
```
|
||||
|
||||
### Manifest Best Practices
|
||||
|
||||
| Element | Guideline |
|
||||
|---------|-----------|
|
||||
| **DisplayName** | 3-5 words, no "for Visual Studio" (implied) |
|
||||
| **Description** | Under 200 chars, focus on value not features. Appears in search tiles |
|
||||
| **Tags** | 5-10 relevant keywords, comma-separated, helps discoverability |
|
||||
| **Icon** | 128x128 or 256x256 PNG, simple design visible at small sizes |
|
||||
| **PreviewImage** | 200x200 PNG, can be same as Icon or a feature screenshot |
|
||||
| **MoreInfo** | Link to GitHub repo for documentation and issues |
|
||||
|
||||
### Writing Tips
|
||||
|
||||
1. **Lead with benefits, not features** - "Stop wrestling with XML comments" beats "XML comment formatter"
|
||||
2. **Show, don't tell** - Screenshots are more convincing than descriptions
|
||||
3. **Use consistent terminology** - Match terms between README, manifest, and UI
|
||||
4. **Keep the description scannable** - Short paragraphs, bullet points, tables
|
||||
5. **Include keyboard shortcuts** - Users love productivity tips
|
||||
6. **Add a "Why" section** - Explain the problem before the solution
|
||||
68
skills/nuget-manager/SKILL.md
Normal file
68
skills/nuget-manager/SKILL.md
Normal file
@@ -0,0 +1,68 @@
|
||||
---
|
||||
name: nuget-manager
|
||||
description: 'Manage NuGet packages in .NET projects/solutions. Use this skill when adding, removing, or updating NuGet package versions. It enforces using `dotnet` CLI for package management and provides strict procedures for direct file edits only when updating versions.'
|
||||
---
|
||||
|
||||
# NuGet Manager
|
||||
|
||||
## Overview
|
||||
|
||||
This skill ensures consistent and safe management of NuGet packages across .NET projects. It prioritizes using the `dotnet` CLI to maintain project integrity and enforces a strict verification and restoration workflow for version updates.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- .NET SDK installed (typically .NET 8.0 SDK or later, or a version compatible with the target solution).
|
||||
- `dotnet` CLI available on your `PATH`.
|
||||
- `jq` (JSON processor) OR PowerShell (for version verification using `dotnet package search`).
|
||||
|
||||
## Core Rules
|
||||
|
||||
1. **NEVER** directly edit `.csproj`, `.props`, or `Directory.Packages.props` files to **add** or **remove** packages. Always use `dotnet add package` and `dotnet remove package` commands.
|
||||
2. **DIRECT EDITING** is ONLY permitted for **changing versions** of existing packages.
|
||||
3. **VERSION UPDATES** must follow the mandatory workflow:
|
||||
- Verify the target version exists on NuGet.
|
||||
- Determine if versions are managed per-project (`.csproj`) or centrally (`Directory.Packages.props`).
|
||||
- Update the version string in the appropriate file.
|
||||
- Immediately run `dotnet restore` to verify compatibility.
|
||||
|
||||
## Workflows
|
||||
|
||||
### Adding a Package
|
||||
Use `dotnet add [<PROJECT>] package <PACKAGE_NAME> [--version <VERSION>]`.
|
||||
Example: `dotnet add src/MyProject/MyProject.csproj package Newtonsoft.Json`
|
||||
|
||||
### Removing a Package
|
||||
Use `dotnet remove [<PROJECT>] package <PACKAGE_NAME>`.
|
||||
Example: `dotnet remove src/MyProject/MyProject.csproj package Newtonsoft.Json`
|
||||
|
||||
### Updating Package Versions
|
||||
When updating a version, follow these steps:
|
||||
|
||||
1. **Verify Version Existence**:
|
||||
Check if the version exists using the `dotnet package search` command with exact match and JSON formatting.
|
||||
Using `jq`:
|
||||
`dotnet package search <PACKAGE_NAME> --exact-match --format json | jq -e '.searchResult[].packages[] | select(.version == "<VERSION>")'`
|
||||
Using PowerShell:
|
||||
`(dotnet package search <PACKAGE_NAME> --exact-match --format json | ConvertFrom-Json).searchResult.packages | Where-Object { $_.version -eq "<VERSION>" }`
|
||||
|
||||
2. **Determine Version Management**:
|
||||
- Search for `Directory.Packages.props` in the solution root. If present, versions should be managed there via `<PackageVersion Include="Package.Name" Version="1.2.3" />`.
|
||||
- If absent, check individual `.csproj` files for `<PackageReference Include="Package.Name" Version="1.2.3" />`.
|
||||
|
||||
3. **Apply Changes**:
|
||||
Modify the identified file with the new version string.
|
||||
|
||||
4. **Verify Stability**:
|
||||
Run `dotnet restore` on the project or solution. If errors occur, revert the change and investigate.
|
||||
|
||||
## Examples
|
||||
|
||||
### User: "Add Serilog to the WebApi project"
|
||||
**Action**: Execute `dotnet add src/WebApi/WebApi.csproj package Serilog`.
|
||||
|
||||
### User: "Update Newtonsoft.Json to 13.0.3 in the whole solution"
|
||||
**Action**:
|
||||
1. Verify 13.0.3 exists: `dotnet package search Newtonsoft.Json --exact-match --format json` (and parse output to confirm "13.0.3" is present).
|
||||
2. Find where it's defined (e.g., `Directory.Packages.props`).
|
||||
3. Edit the file to update the version.
|
||||
4. Run `dotnet restore`.
|
||||
Reference in New Issue
Block a user