From 03041721cabda1c7b5b87918a7fd1c718192a43c Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 22 Jan 2026 12:05:45 -0500 Subject: [PATCH] Preserve existing proto files instead of overwriting If a proto file already exists (committed to repo), don't overwrite it with a placeholder. This allows first-time builds to work correctly when the proto file is already in the repository. Co-Authored-By: Claude Opus 4.5 --- Svrnty.CQRS.Grpc.Generators/WriteProtoFileTask.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Svrnty.CQRS.Grpc.Generators/WriteProtoFileTask.cs b/Svrnty.CQRS.Grpc.Generators/WriteProtoFileTask.cs index 3650f86..894b1c6 100644 --- a/Svrnty.CQRS.Grpc.Generators/WriteProtoFileTask.cs +++ b/Svrnty.CQRS.Grpc.Generators/WriteProtoFileTask.cs @@ -67,6 +67,16 @@ public class WriteProtoFileTask : Task "GeneratedProtoFile.g.cs" ); + // Check if proto file already exists (committed to repo or from previous build) + var existingProtoPath = Path.Combine(ProjectDirectory, OutputDirectory, ProtoFileName); + if (File.Exists(existingProtoPath) && !File.Exists(generatedFilePath)) + { + Log.LogMessage(MessageImportance.High, + $"Svrnty.CQRS.Grpc: Using existing proto file at {existingProtoPath}. " + + "To regenerate, delete the file and build twice."); + return true; + } + if (!File.Exists(generatedFilePath)) { Log.LogWarning(