@@ -617,15 +617,23 @@ export class RoslynLanguageServer {
617
617
? path . join ( context . extension . extensionPath , '.razor' )
618
618
: razorOptions . razorServerPath ;
619
619
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 ;
621
628
622
629
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 ' )
625
632
) ;
626
633
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' )
629
637
) ;
630
638
631
639
// Get the brokered service pipe name from C# Dev Kit (if installed).
0 commit comments