@@ -617,15 +617,23 @@ export class RoslynLanguageServer {
617617 ? path . join ( context . extension . extensionPath , '.razor' )
618618 : razorOptions . razorServerPath ;
619619
620- args . push ( '--razorSourceGenerator' , path . join ( razorPath , 'Microsoft.CodeAnalysis.Razor.Compiler.dll' ) ) ;
620+ let razorComponentPath = '' ;
621+ getComponentPaths ( 'razorExtension' , languageServerOptions ) . forEach ( ( extPath ) => {
622+ additionalExtensionPaths . push ( extPath ) ;
623+ razorComponentPath = path . dirname ( extPath ) ;
624+ } ) ;
625+
626+ // If cohosting is enabled we get the source generator from the razor component path
627+ const razorSourceGeneratorPath = razorOptions . cohostingEnabled ? razorComponentPath : razorPath ;
621628
622629 args . push (
623- '--razorDesignTimePath ' ,
624- path . join ( razorPath , 'Targets' , ' Microsoft.NET.Sdk. Razor.DesignTime.targets ')
630+ '--razorSourceGenerator ' ,
631+ path . join ( razorSourceGeneratorPath , 'Microsoft.CodeAnalysis. Razor.Compiler.dll ' )
625632 ) ;
626633
627- getComponentPaths ( 'razorExtension' , languageServerOptions ) . forEach ( ( path ) =>
628- additionalExtensionPaths . push ( path )
634+ args . push (
635+ '--razorDesignTimePath' ,
636+ path . join ( razorPath , 'Targets' , 'Microsoft.NET.Sdk.Razor.DesignTime.targets' )
629637 ) ;
630638
631639 // Get the brokered service pipe name from C# Dev Kit (if installed).
0 commit comments