Preserve existing proto files instead of overwriting
All checks were successful
Publish NuGets / build (release) Successful in 39s

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 <noreply@anthropic.com>
This commit is contained in:
David Nguyen 2026-01-22 12:05:45 -05:00
parent 05449b9a28
commit 03041721ca
Signed by: david.nguyen
GPG Key ID: D5FB5A5715829326

View File

@ -67,6 +67,16 @@ public class WriteProtoFileTask : Task
"GeneratedProtoFile.g.cs" "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)) if (!File.Exists(generatedFilePath))
{ {
Log.LogWarning( Log.LogWarning(