protected override async Task OnProjectChangedAsync() { await ExecuteWithLockAsync(async() => { var referencedAssemblies = await DotNetProject.GetReferencedAssemblies(ConfigurationSelector.Default); var mvcReference = referencedAssemblies.FirstOrDefault(IsMvcAssembly); var projectProperties = DotNetProject.MSBuildProject.EvaluatedProperties; if (TryGetIntermediateOutputPath(projectProperties, out var intermediatePath)) { var projectConfigurationFile = Path.Combine(intermediatePath, _languageServerFeatureOptions.ProjectConfigurationFileName); ProjectConfigurationFilePathStore.Set(DotNetProject.FileName.FullPath, projectConfigurationFile); } if (mvcReference is null) { // Ok we can't find an MVC version. Let's assume this project isn't using Razor then. await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false); return; } var version = GetAssemblyVersion(mvcReference.FilePath); if (version is null) { // Ok we can't find an MVC version. Let's assume this project isn't using Razor then. await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false); return; } var configuration = FallbackRazorConfiguration.SelectConfiguration(version); var hostProject = new HostProject(DotNetProject.FileName.FullPath, configuration, rootNamespace: null); await UpdateHostProjectUnsafeAsync(hostProject).ConfigureAwait(false); }); }
protected override async Task OnProjectChangedAsync() { await ExecuteWithLockAsync(async() => { var projectProperties = DotNetProject.MSBuildProject.EvaluatedProperties; var projectItems = DotNetProject.MSBuildProject.EvaluatedItems; if (TryGetIntermediateOutputPath(projectProperties, out var intermediatePath)) { var projectConfigurationFile = Path.Combine(intermediatePath, _languageServerFeatureOptions.ProjectConfigurationFileName); ProjectConfigurationFilePathStore.Set(DotNetProject.FileName.FullPath, projectConfigurationFile); } if (TryGetConfiguration(projectProperties, projectItems, out var configuration)) { TryGetRootNamespace(projectProperties, out var rootNamespace); var hostProject = new HostProject(DotNetProject.FileName.FullPath, configuration, rootNamespace); await UpdateHostProjectUnsafeAsync(hostProject).ConfigureAwait(false); UpdateDocuments(hostProject, projectItems); } else { // Ok we can't find a configuration. Let's assume this project isn't using Razor then. await UpdateHostProjectUnsafeAsync(null).ConfigureAwait(false); } }); }