Skip to content

Restore the built-in VS SDK .pkgdef generation and migrate to it - #85231

Merged
jasonmalinowski merged 5 commits into
dotnet:mainfrom
jasonmalinowski:vs-sdk-registration
Sep 16, 2026
Merged

jasonmalinowski merged 5 commits into
dotnet:mainfrom
jasonmalinowski:vs-sdk-registration

Conversation

@jasonmalinowski

@jasonmalinowski jasonmalinowski commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Roslyn replaced the built in GeneratePkgDef target with a custom MSBuild target that disabled the RegistrationAttribute-based
system that's standard to the VS SDK. This unfortunately made Roslyn a bit harder to maintain, since it meant we're doing something "different" than the rest of the ecosystem. This PR moves us back to the built-in system while keeping the useful custom parts around, and migrates us to all the attributes that we can.

Microsoft Reviewers: Open in CodeFlow

@jasonmalinowski jasonmalinowski self-assigned this Sep 9, 2026
Roslyn replaced the built in GeneratePkgDef target with a custom
MSBuild target that disabled the RegistrationAttribute-based
system that's standard to the VS SDK. This unfortunately made Roslyn
a bit harder to maintain, since it meant we're doing something
"different" than the rest of the ecosystem. This commit removes
the target that replaced the default, and moves the generation
of pkgdefs that contain service broker services and redirects to their
own targets that can run alongside the VS SDK one.
Using the built-in attribute means we don't have to have any of the
caveats around the CacheTag entries.
Now that we're using registration attributes again, we can migrate
everything that can be set over to them. What's left are things that
aren't supported by the attributes.
This ensures we can build even if we're disabling the VS SDK.
@jasonmalinowski
jasonmalinowski marked this pull request as ready for review September 10, 2026 16:37
Copilot AI lite review requested due to automatic review settings September 10, 2026 16:38
@jasonmalinowski
jasonmalinowski requested a review from a team as a code owner September 10, 2026 16:38
@jasonmalinowski
jasonmalinowski requested a review from a team September 10, 2026 16:38
@jasonmalinowski
jasonmalinowski requested review from a team as code owners September 10, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Moderate registration compatibility, settings-cache invalidation, incremental-build, and VB service-flag issues remain unresolved.

Review tier: Lite
Findings: None

What changed in this PR

Restores built-in Visual Studio SDK .pkgdef generation while retaining custom registration generation where needed.

Changes:

  • Migrates package, language, editor, and settings registrations to SDK attributes.
  • Updates MSBuild targets and VSIX manifests for generated outputs.
  • Removes legacy static registrations while preserving custom registrations.
File Summary Review note
src/​VisualStudio/​VisualBasic/​Impl/​UnifiedSettings/​visualBasicSettings.registration.json Removes obsolete cache-tag guidance. —
src/​VisualStudio/​VisualBasic/​Impl/​PackageRegistration.pkgdef Removes static VB registration. —
src/​VisualStudio/​VisualBasic/​Impl/​Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj Enables SDK generation and extra .pkgdef content. —
src/​VisualStudio/​VisualBasic/​Impl/​Microsoft.VisualStudio.LanguageServices.VisualBasic.Extra.pkgdef Preserves custom VB registrations. Moderate (1 vote): Preserve or generate the settings manifest cache tag.
src/​VisualStudio/​VisualBasic/​Impl/​LanguageService/​VisualBasicPackage.vb Adds SDK registration attributes. Moderate (1 vote): Preserve IsCacheable=1 and IsFreeThreaded=1.
src/​VisualStudio/​VisualBasic/​Impl/​LanguageService/​VisualBasicEditorFactory.vb Adds editor view registration. —
src/​VisualStudio/​VisualBasic/​Impl/​LanguageService/​VisualBasicCodePageEditorFactory.vb Adds designer view registration. —
src/​VisualStudio/​Setup/​source.extension.vsixmanifest Updates generated and extra .pkgdef assets. —
src/​VisualStudio/​Setup/​Roslyn.VisualStudio.Setup.csproj Updates setup output groups and brokered output. —
src/​VisualStudio/​Setup/​PackageRegistration.pkgdef Removes static setup registration. —
src/​VisualStudio/​Setup.ServiceHub/​x64/​source.extension.vsixmanifest Uses brokered-service output. —
src/​VisualStudio/​Setup.ServiceHub/​Directory.Build.targets Updates brokered registration generation. —
src/​VisualStudio/​Setup.ServiceHub/​Directory.Build.props Disables local .pkgdef generation. —
src/​VisualStudio/​Setup.ServiceHub/​arm64/​source.extension.vsixmanifest Uses brokered-service output. —
src/​VisualStudio/​Setup.Dependencies/​source.extension.vsixmanifest Uses assembly-redirect output. —
src/​VisualStudio/​Setup.Dependencies/​Roslyn.VisualStudio.Setup.Dependencies.csproj Disables local .pkgdef generation. —
src/​VisualStudio/​IntegrationTest/​Harness/​IntegrationTestServiceShared/​IntegrationTestServicePackage.cs Adds package and menu attributes. —
src/​VisualStudio/​IntegrationTest/​Harness/​IntegrationTestServiceDev18/​PackageRegistration.pkgdef Removes static registration. —
src/​VisualStudio/​IntegrationTest/​Harness/​IntegrationTestServiceDev18/​Microsoft.VisualStudio.IntegrationTestService.Dev18.csproj Removes custom registration items. —
src/​VisualStudio/​CSharp/​Impl/​UnifiedSettings/​csharpSettings.registration.json Removes obsolete cache-tag guidance. —
src/​VisualStudio/​CSharp/​Impl/​PackageRegistration.pkgdef Removes static C# registration. —
src/​VisualStudio/​CSharp/​Impl/​Microsoft.VisualStudio.LanguageServices.CSharp.Extra.pkgdef Preserves custom C# registrations. Moderate (1 vote): Preserve or generate the settings manifest cache tag.
src/​VisualStudio/​CSharp/​Impl/​Microsoft.VisualStudio.LanguageServices.CSharp.csproj Enables SDK generation and extra .pkgdef content. —
src/​VisualStudio/​CSharp/​Impl/​LanguageService/​CSharpEditorFactory.cs Adds editor view registration. —
src/​VisualStudio/​CSharp/​Impl/​LanguageService/​CSharpCodePageEditorFactory.cs Adds designer view registration. —
src/​VisualStudio/​CSharp/​Impl/​Interactive/​CSharpVsInteractiveWindowPackage.cs Adds interactive-window registration attributes. —
src/​VisualStudio/​CSharp/​Impl/​CSharpPackage.cs Adds SDK registration attributes. —
src/​VisualStudio/​Core/​Test.Next/​UnifiedSettings/​UnifiedSettingsTests.cs Removes static cache-tag verification. Nit (1 vote): Add an output-level test for generated settings registration and cache tags.
src/​VisualStudio/​Core/​Test.Next/​Roslyn.VisualStudio.Next.UnitTests.csproj Removes embedded static .pkgdef files. —
src/​VisualStudio/​Core/​Def/​UnifiedSettings/​roslynSettings.registration.json Removes obsolete cache-tag guidance. —
src/​VisualStudio/​Core/​Def/​RoslynPackage.cs Adds package and settings registration attributes. —
src/​VisualStudio/​Core/​Def/​PackageRegistration.pkgdef Removes static core registration. —
src/​VisualStudio/​Core/​Def/​Microsoft.VisualStudio.LanguageServices.Extra.pkgdef Preserves custom core registrations. Moderate (1 vote): Preserve or generate the settings manifest cache tag.
src/​VisualStudio/​Core/​Def/​Microsoft.VisualStudio.LanguageServices.csproj Converts custom registrations to VSIX content. —
src/​RoslynSdk/​VisualStudio.Roslyn.SDK/​SyntaxVisualizer/​Roslyn.SyntaxVisualizer.Extension/​Roslyn.SyntaxVisualizer.Extension.csproj Removes custom registration items. —
src/​RoslynSdk/​VisualStudio.Roslyn.SDK/​SyntaxVisualizer/​Roslyn.SyntaxVisualizer.Extension/​PackageRegistration.pkgdef Removes static registration. —
src/​RoslynSdk/​VisualStudio.Roslyn.SDK/​Roslyn.SDK/​source.extension.vsixmanifest Uses assembly-redirect output. —
src/​RoslynSdk/​VisualStudio.Roslyn.SDK/​Roslyn.SDK/​Roslyn.SDK.csproj Disables local .pkgdef generation. —
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​source.extension.vsixmanifest Adds generated registration assets. —
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​RazorPackage.cs Adds SDK registration attributes. Moderate (1 vote): Preserve or generate the settings manifest cache tag.
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​PackageRegistration.pkgdef Removes static registration. —
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​Microsoft.VisualStudio.RazorExtension.Custom.pkgdef Retains custom registrations. —
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​Microsoft.VisualStudio.RazorExtension.csproj Enables SDK generation and product versioning. —
src/​Razor/​src/​Razor/​src/​Microsoft.VisualStudio.RazorExtension/​Directory.Build.targets Includes generated registrations in packaging. —
src/​LanguageServer/​Protocol/​LspOptionsStorage.cs Updates registration-file references. —
src/​ExpressionEvaluator/​Package/​source.extension.vsixmanifest Uses assembly-redirect output. —
src/​ExpressionEvaluator/​Package/​ExpressionEvaluatorPackage.csproj Disables local .pkgdef generation. —
src/​Compilers/​Extension/​source.extension.vsixmanifest Adds assembly-redirect output. —
src/​Compilers/​Extension/​Roslyn.Compilers.Extension.csproj Removes custom package registration items. —
src/​Compilers/​Extension/​PackageRegistration.pkgdef Removes static registration. —
src/​Compilers/​Extension/​CompilerPackage.cs Adds package and autoload attributes. —
eng/​targets/​VisualStudio.targets Adds generated registration output groups. —
eng/​targets/​Imports.targets Generates product-version constants. —
eng/​targets/​GeneratePkgDef.targets Splits redirect and brokered-service generation. Moderate (1 vote): Restore incremental Inputs/Outputs tracking and preserve UseCodeBase compatibility.
Suppressed comments (8)

eng/targets/GeneratePkgDef.targets:86

  • These entry targets have no Inputs/Outputs, so each VSIX/output-group evaluation reruns _AddPkgDefEntriesFromReferences and the assembly metadata/GUID tasks even when the generated file is unchanged. The former GeneratePkgDef target had incremental inputs and outputs; retain equivalent up-to-date tracking here (while still exposing the generated item to the output-group target) to avoid repeating this work on every build.
  <Target Name="GenerateAssemblyRedirectsPkgDef"
          DependsOnTargets="_SetGeneratePkgDefInputsOutputs;_AddPkgDefEntriesFromReferences;_GenerateAssemblyRedirectsPkgDef"
          Condition="'$(DesignTimeBuild)' != 'true'" />

eng/targets/GeneratePkgDef.targets:8

  • PkgDefPackageRegistration and UseCodeBase are no longer consumed here. That changes existing projects with UseCodeBase=true from a $PackageFolder$ CodeBase registration to the built-in attribute's default Assembly registration; for example, SyntaxVisualizer still sets UseCodeBase=true while its package has only [PackageRegistration]. Preserve this compatibility or add RegisterUsing=RegistrationMethod.CodeBase to every affected package, including EditorConfig Command.
    Generates assembly redirects and brokered-service registrations in separate pkgdef
    files, alongside the VSSDK's attribute-based GeneratePkgDef output.
    The following PkgDef* item groups are recognized:

src/Razor/src/Razor/src/Microsoft.VisualStudio.RazorExtension/RazorPackage.cs:48

  • The deleted Razor package registration contained the SettingsManifests\{13b72f58-279e-49e0-a56d-296be02f0805} entry's manually maintained CacheTag, but this ProvideSettingsManifest migration has no replacement value. Consequently, changes to razor.registration.json will not invalidate the cached manifest and updated options can be ignored. Preserve or generate a changing cache tag as part of this migration.
[ProvideSettingsManifest(PackageRelativeManifestFile = @"UnifiedSettings\razor.registration.json")]

src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.Extra.pkgdef:1

  • Deleting the old package registration removed the SettingsManifests\{13c3bbb4-f18f-4111-9f54-a0fb010d9194} entry's manually maintained CacheTag; this replacement file contains no corresponding value, and ProvideSettingsManifest only specifies the manifest path. Consequently, changes to csharpSettings.registration.json will not invalidate the cached manifest and updated options can be ignored. Preserve or generate a changing cache tag (and its verification) as part of this migration.
[$RootKey$\Languages\Language Services\CSharp]

src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.Extra.pkgdef:1

  • Deleting the old package registration removed the SettingsManifests\{6cf2e545-6109-4730-8883-cf43d7aec3e1} entry's manually maintained CacheTag; this replacement file contains no corresponding value, and ProvideSettingsManifest only specifies the manifest path. Consequently, changes to roslynSettings.registration.json will not invalidate the cached manifest and updated options can be ignored. Preserve or generate a changing cache tag (and its verification) as part of this migration.
// Register Hot Reload brokered service with the debugger.

src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs:140

  • Could this retain an end-to-end assertion for the generated settings registration? The removed tests compared each JSON's hash with its CacheTag; after moving to ProvideSettingsManifest, deleting those checks (including the Roslyn check below) leaves the new VSSDK-generated .pkgdef path untested, so a broken or missing cache tag would not be caught. Please add a build/output-level test for the generated registration rather than dropping this coverage.
    src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb:53
  • The previous PackageRegistration.pkgdef registered the Visual Basic project-system shim with IsCacheable=1 and IsFreeThreaded=1. This attribute changes both flags to false, so the migrated registration no longer preserves the shell's service-resolution contract; keep these values true as before.
    src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.Extra.pkgdef:1
  • Deleting the old package registration removed the SettingsManifests\{574fc912-f74f-4b4e-92c3-f695c208a2bb} entry's manually maintained CacheTag; this replacement file contains no corresponding value, and ProvideSettingsManifest only specifies the manifest path. Consequently, changes to visualBasicSettings.registration.json will not invalidate the cached manifest and updated options can be ignored. Preserve or generate a changing cache tag (and its verification) as part of this migration.

@davidwengier davidwengier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Razor LGTM. Hopefully everything still works :)

@dotnet dotnet deleted a comment from azure-pipelines Bot Sep 14, 2026
@dotnet dotnet deleted a comment from github-actions Bot Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

View PR Validation Run triggered by @jasonmalinowski

Parameters
  • Validation Type: pr-val
  • Pipeline ID: 8972
  • Pipeline Version: main
  • PR Number: 85231
  • Commit SHA: 609530e063f800c0b167c10d9b4cba1fd7cc8cc5
  • Source Branch: vs-sdk-registration
  • Target Branch: main
  • Build ID: 15317554

@jasonmalinowski
jasonmalinowski merged commit 3f11534 into dotnet:main Sep 16, 2026
26 checks passed
@jasonmalinowski
jasonmalinowski deleted the vs-sdk-registration branch September 16, 2026 17:05
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Sep 16, 2026
@jjonescz jjonescz removed this from the Next milestone Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants