Repository navigation
Restore the built-in VS SDK .pkgdef generation and migrate to it - #85231
Conversation
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.
46a72a9 to
fd8ba62
Compare
This ensures we can build even if we're disabling the VS SDK.
There was a problem hiding this comment.
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_AddPkgDefEntriesFromReferencesand the assembly metadata/GUID tasks even when the generated file is unchanged. The formerGeneratePkgDeftarget 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
PkgDefPackageRegistrationandUseCodeBaseare no longer consumed here. That changes existing projects withUseCodeBase=truefrom a$PackageFolder$CodeBase registration to the built-in attribute's default Assembly registration; for example, SyntaxVisualizer still setsUseCodeBase=truewhile its package has only[PackageRegistration]. Preserve this compatibility or addRegisterUsing=RegistrationMethod.CodeBaseto 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 maintainedCacheTag, but thisProvideSettingsManifestmigration has no replacement value. Consequently, changes torazor.registration.jsonwill 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 maintainedCacheTag; this replacement file contains no corresponding value, andProvideSettingsManifestonly specifies the manifest path. Consequently, changes tocsharpSettings.registration.jsonwill 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 maintainedCacheTag; this replacement file contains no corresponding value, andProvideSettingsManifestonly specifies the manifest path. Consequently, changes toroslynSettings.registration.jsonwill 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 toProvideSettingsManifest, deleting those checks (including the Roslyn check below) leaves the new VSSDK-generated.pkgdefpath 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.pkgdefregistered the Visual Basic project-system shim withIsCacheable=1andIsFreeThreaded=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 maintainedCacheTag; this replacement file contains no corresponding value, andProvideSettingsManifestonly specifies the manifest path. Consequently, changes tovisualBasicSettings.registration.jsonwill 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
left a comment
There was a problem hiding this comment.
Razor LGTM. Hopefully everything still works :)
|
View PR Validation Run triggered by @jasonmalinowski Parameters
|
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