public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path) { return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync( path, lockedToken => { var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path)); return lockFile; }, CancellationToken.None)); }
public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path) { return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync( path, lockedToken => { if (!File.Exists(path)) { throw new GracefulException(string.Join( Environment.NewLine, string.Format(Resources.GetString("FileNotFound"), path), Resources.GetString("ProjectNotRestoredOrRestoreFailed"))); } var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path), Resources.GetString("CouldNotAccessAssetsFile")); return lockFile; }, CancellationToken.None)); }
public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path) { if (!File.Exists(path)) { throw new GracefulException(string.Join( Environment.NewLine, $"File not found `{path}`.", "The project may not have been restored or restore failed - run `dotnet restore`")); } return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync( path, lockedToken => { var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path)); return lockFile; }, CancellationToken.None)); }
public static async Task <LockFile> ReadWithLock(this LockFileFormat subject, string path) { if (!File.Exists(path)) { throw new GracefulException(string.Join( Environment.NewLine, string.Format(LocalizableStrings.FileNotFound, path), LocalizableStrings.ProjectNotRestoredOrRestoreFailed)); } return(await ConcurrencyUtilities.ExecuteWithFileLockedAsync( path, lockedToken => { var lockFile = FileAccessRetrier.RetryOnFileAccessFailure(() => subject.Read(path)); return lockFile; }, CancellationToken.None)); }