protected override async Task OnProjectChangedAsync() { ForegroundDispatcher.AssertBackgroundThread(); await ExecuteWithLockAsync(async() => { var referencedAssemblies = await DotNetProject.GetReferencedAssemblies(ConfigurationSelector.Default); var mvcReference = referencedAssemblies.FirstOrDefault(IsMvcAssembly); if (mvcReference == 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 == 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); await UpdateHostProjectUnsafeAsync(hostProject).ConfigureAwait(false); }); }
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); }); }