private static Project LoadProject(string projectFile) { var toolsPath = EnvironmentUtils.NetCoreRuntimePath; var globalProperties = EnvironmentUtils.GetCoreGlobalProperties(projectFile, toolsPath); var projectCollection = new ProjectCollection(globalProperties); projectCollection.AddToolset(new Toolset(ToolLocationHelper.CurrentToolsVersion, toolsPath, projectCollection, string.Empty)); Environment.SetEnvironmentVariable("MSBuildExtensionsPath", EnvironmentUtils.NetCoreRuntimePath); Environment.SetEnvironmentVariable("MSBuildSDKsPath", EnvironmentUtils.MSBuildSDKsPath); Environment.SetEnvironmentVariable("MSBuildEnableWorkloadResolver", bool.FalseString); // NET 6.0 + // TODO: Make properly async var fileContents = new StringReader(File.ReadAllText(projectFile)); // read {projectFile} separately in order to avoid locking it on FS var xmlReader = XmlReader.Create(fileContents, XmlSettings); var projectRoot = ProjectRootElement.Create(xmlReader, projectCollection); // In order to have it accessible from MSBuild projectRoot.FullPath = projectFile; var properties = new Dictionary <string, string>() { // In order not to build the dependent projects { "DesignTimeBuild", "true" }, }; //Project project = projectCollection.LoadProject(projectPath); return(new Project(projectRoot, properties, toolsVersion: null, projectCollection: projectCollection)); }
private static async Task MainAsync(string[] args) { await EnvironmentUtils.InitializeAsync(); var options = ServerOptions.ParseFromArguments(args); var requestReader = new MessageReader(Console.OpenStandardInput()); var messageWriter = new MessageWriter(Console.OpenStandardOutput()); AssemblyLoadContext.Default.Resolving += Assembly_Resolving; var server = new PhpLanguageServer(options, requestReader, messageWriter); await server.Run(); }