private async Task <AnalyzerResult> LoadResultOrCleanAsync() { using (await DirectoryAccessor.TryLockAsync()) { var binLog = this.FindLatestBinLog(); if (binLog != null) { var results = await TryLoadAnalyzerResultsAsync(binLog); var result = results?.FirstOrDefault(p => p.ProjectFilePath == _projectFile.FullName); var didCompile = DidPerformCoreCompile(result); if (result != null) { if (result.Succeeded && didCompile) { return(result); } } } binLog?.DoWhenFileAvailable(() => binLog.Delete()); var toClean = Directory.GetDirectories("obj"); foreach (var directoryInfo in toClean) { directoryInfo.Delete(true); } return(null); } }
private async Task <AnalyzerResult> BuildProjectAsync(AnalyzerResult result) { if (result != null) { return(result); } using (await DirectoryAccessor.TryLockAsync()) { using (var operation = Log.OnEnterAndConfirmOnExit()) { try { operation.Info("Building package {name}", Name); await DotnetBuild(); operation.Info("Workspace built"); operation.Succeed(); } catch (Exception exception) { operation.Error("Exception building workspace", exception); throw; } var binLog = this.FindLatestBinLog(); if (binLog == null) { throw new InvalidOperationException("Failed to build"); } var results = await TryLoadAnalyzerResultsAsync(binLog); if (results?.Count == 0) { throw new InvalidOperationException("The build log seems to contain no solutions or projects"); } result = results?.FirstOrDefault(p => p.ProjectFilePath == _projectFile.FullName); if (result?.Succeeded == true) { return(result); } throw new InvalidOperationException("Failed to build"); } } }
private async Task <IAnalyzerResult> BuildProjectAsync(IAnalyzerResult result) { if (result != null) { return(result); } using (await DirectoryAccessor.TryLockAsync()) { { await DotnetBuild(); var binLog = this.FindLatestBinLog(); if (binLog == null) { throw new InvalidOperationException("Failed to build"); } var results = await TryLoadAnalyzerResultsAsync(binLog); if (results?.Count == 0) { throw new InvalidOperationException("The build log seems to contain no solutions or projects"); } result = results?.FirstOrDefault(p => p.ProjectFilePath == _projectFile.FullName); if (result?.Succeeded == true) { return(result); } throw new InvalidOperationException("Failed to build"); } } }