protected async Task Publish() { using (var operation = _log.OnEnterAndConfirmOnExit()) { operation.Info("Publishing package {name}", Name); var publishInProgress = Interlocked.Increment(ref publishCount) > 1; await _publishSemaphore.WaitAsync(); if (publishInProgress) { operation.Info("Skipping publish for package {name}", Name); return; } CommandLineResult result; using (Disposable.Create(() => _publishSemaphore.Release())) { operation.Info("Publishing workspace in {directory}", Directory); result = await new Dotnet(Directory) .Publish("--no-dependencies --no-restore --no-build"); } result.ThrowOnFailure(); operation.Info("Workspace published"); operation.Succeed(); PublicationTime = Clock.Current.Now(); Interlocked.Exchange(ref publishCount, 0); } }
public override async Task FullBuild() { using (var operation = Log.OnEnterAndConfirmOnExit()) { try { operation.Info("Building package {name}", Name); // When a build finishes, buildCount is reset to 0. If, when we increment // the value, we get a value > 1, someone else has already started another // build var buildInProgress = Interlocked.Increment(ref buildCount) > 1; await _buildSemaphore.WaitAsync(); using (Disposable.Create(() => _buildSemaphore.Release())) { if (buildInProgress) { operation.Info("Skipping build for package {name}", Name); return; } using (await FileLock.TryCreateAsync(Directory)) { await DotnetBuild(); } } operation.Info("Workspace built"); operation.Succeed(); } catch (Exception exception) { operation.Error("Exception building workspace", exception); } var binLog = this.FindLatestBinLog(); await binLog.WaitForFileAvailable(); await LoadDesignTimeBuildFromBuildLogFile(this, binLog); Interlocked.Exchange(ref buildCount, 0); } }
public override async Task FullBuild() { using (var operation = Log.OnEnterAndConfirmOnExit()) { try { operation.Info("Attempting building package {name}", Name); var buildInProgress = _buildSemaphore.CurrentCount == 0; await _buildSemaphore.WaitAsync(); using (Disposable.Create(() => _buildSemaphore.Release())) { if (buildInProgress) { operation.Info("Skipping build for package {name}", Name); return; } using (await FileLock.TryCreateAsync(Directory)) { await DotnetBuild(); } } operation.Info("Workspace built"); operation.Succeed(); } catch (Exception exception) { operation.Error("Exception building workspace", exception); } var binLog = this.FindLatestBinLog(); await binLog.WaitForFileAvailable(); await LoadDesignTimeBuildFromBuildLogFile(this, binLog); } }