@@ -585,13 +585,14 @@ def set_up_csharp_options(self, project_dir: Path, run_options: Dict[str, Any],
585585 "mode" : "rw"
586586 }
587587
588+ framework_ver = self ._docker_manager .get_image_label (image , 'target_framework' ,
589+ DEFAULT_LEAN_DOTNET_FRAMEWORK )
590+
588591 # Ensure all .csproj files refer to the version of LEAN in the Docker container
589592 csproj_temp_dir = self ._temp_manager .create_temporary_directory ()
590593 for path in compile_root .rglob ("*.csproj" ):
591- self ._ensure_csproj_uses_correct_lean (compile_root , path , csproj_temp_dir , run_options )
594+ self ._ensure_csproj_is_valid (compile_root , path , csproj_temp_dir , run_options , framework_ver )
592595
593- framework_ver = self ._docker_manager .get_image_label (image , 'target_framework' ,
594- DEFAULT_LEAN_DOTNET_FRAMEWORK )
595596 # Set up the MSBuild properties
596597 msbuild_properties = {
597598 "Configuration" : "Release" if release else "Debug" ,
@@ -601,8 +602,6 @@ def set_up_csharp_options(self, project_dir: Path, run_options: Dict[str, Any],
601602 "GenerateAssemblyInfo" : "false" ,
602603 "GenerateTargetFrameworkAttribute" : "false" ,
603604 "AppendTargetFrameworkToOutputPath" : "false" ,
604- "AutoGenerateBindingRedirects" : "true" ,
605- "GenerateBindingRedirectsOutputType" : "true" ,
606605 "AutomaticallyUseReferenceAssemblyPackages" : "false" ,
607606 "CopyLocalLockFileAssemblies" : "true" ,
608607 "PathMap" : f"/LeanCLI={ str (compile_root )} " ,
@@ -770,11 +769,12 @@ def _get_csharp_compile_root(self, project_dir: Path) -> Path:
770769
771770 return project_dir
772771
773- def _ensure_csproj_uses_correct_lean (self ,
774- compile_root : Path ,
775- csproj_path : Path ,
776- temp_dir : Path ,
777- run_options : Dict [str , Any ]) -> None :
772+ def _ensure_csproj_is_valid (self ,
773+ compile_root : Path ,
774+ csproj_path : Path ,
775+ temp_dir : Path ,
776+ run_options : Dict [str , Any ],
777+ net_framework : str ) -> None :
778778 """Ensures a C# project is compiled using the version of LEAN in the Docker container.
779779
780780 When a .csproj file refers to the NuGet version of LEAN,
@@ -791,6 +791,18 @@ def _ensure_csproj_uses_correct_lean(self,
791791 csproj = self ._xml_manager .parse (csproj_path .read_text (encoding = "utf-8" ))
792792 include_added = False
793793
794+ if net_framework :
795+ target_framework_iter = csproj .iter ("TargetFramework" )
796+ if target_framework_iter :
797+ target_frameworks = [framework .text for framework in target_framework_iter ]
798+ if target_frameworks :
799+ if net_framework not in target_frameworks :
800+ raise RuntimeError (f"This project is targeting { target_frameworks [0 ].replace ('net' , 'Net ' )} "
801+ f" and { net_framework .replace ('net' , 'Net ' )} is required. Please"
802+ f" update the \" Target Framework\" project setting in VSCode to"
803+ f" the new SDK or modify the csproj file directly to "
804+ f"\" <TargetFramework>{ net_framework } </TargetFramework>\" ." )
805+
794806 for package_reference in csproj .iter ("PackageReference" ):
795807 if not package_reference .get ("Include" , "" ).lower ().startswith ("quantconnect." ):
796808 continue
0 commit comments