diff --git a/csharp/scripts/stubs/helpers.py b/csharp/scripts/stubs/helpers.py
index ce663bac4e8..33b8f2663f8 100644
--- a/csharp/scripts/stubs/helpers.py
+++ b/csharp/scripts/stubs/helpers.py
@@ -77,6 +77,14 @@ class Generator:
self.projectNameIn, '--output', self.projectDirIn])
remove_files(self.projectDirIn, '.cs')
+ # Clear possibly inherited Directory.Build.props and Directory.Build.targets:
+ with open(os.path.join(self.workDir, 'Directory.Build.props'), 'w') as f:
+ f.write('\n')
+ f.write('\n')
+ with open(os.path.join(self.workDir, 'Directory.Build.targets'), 'w') as f:
+ f.write('\n')
+ f.write('\n')
+
def run_cmd(self, cmd, msg="Failed to run command"):
run_cmd_cwd(cmd, self.workDir, msg)