Skip to content

Commit 200d85a

Browse files
vbfoxenricosada
authored andcommitted
Only write the targets file if it changed
Fixes #13
1 parent 08f347a commit 200d85a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/dotnet-proj-info/Inspect.fs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,20 @@ let writeTargetFile log templates targetFileDestPath =
114114
</Project>
115115
"""
116116

117-
log (sprintf "writing helper target file in '%s'" targetFileDestPath)
118-
File.WriteAllText(targetFileDestPath, targetFileTemplate.Trim())
117+
let targetFileOnDisk =
118+
if File.Exists(targetFileDestPath) then
119+
try
120+
Some (File.ReadAllText targetFileDestPath)
121+
with
122+
| _ -> None
123+
else
124+
None
125+
126+
let newTargetFile = targetFileTemplate.Trim()
127+
128+
if targetFileOnDisk <> Some newTargetFile then
129+
log (sprintf "writing helper target file in '%s'" targetFileDestPath)
130+
File.WriteAllText(targetFileDestPath, newTargetFile)
119131

120132
Ok targetFileDestPath
121133

0 commit comments

Comments
 (0)