|
3 | 3 | using JetBrains.Annotations; |
4 | 4 | using PostSharp.Engineering.BuildTools.Build; |
5 | 5 | using PostSharp.Engineering.BuildTools.ContinuousIntegration.Model; |
| 6 | +using PostSharp.Engineering.BuildTools.Utilities; |
6 | 7 | using System; |
7 | 8 | using System.Collections.Generic; |
8 | 9 | using System.IO; |
@@ -66,22 +67,24 @@ void Add( ContainerComponent c ) |
66 | 67 |
|
67 | 68 | var dockerfilePath = Path.Combine( context.RepoDirectory, "Dockerfile" ); |
68 | 69 | context.Console.WriteMessage( $"Writing '{dockerfilePath}'." ); |
69 | | - using var dockerfile = File.CreateText( dockerfilePath ); |
| 70 | + using var dockerfileContent = new StringWriter(); |
70 | 71 |
|
71 | 72 | foreach ( var component in orderedComponents ) |
72 | 73 | { |
73 | 74 | context.Console.WriteMessage( $"Processing container component '{component.Name}'." ); |
74 | 75 |
|
75 | 76 | if ( component.Kind != ContainerComponentKind.Prolog ) |
76 | 77 | { |
77 | | - dockerfile.WriteLine(); |
78 | | - dockerfile.WriteLine(); |
79 | | - dockerfile.WriteLine( $"# {component.Name}" ); |
| 78 | + dockerfileContent.WriteLine(); |
| 79 | + dockerfileContent.WriteLine(); |
| 80 | + dockerfileContent.WriteLine( $"# {component.Name}" ); |
80 | 81 | } |
81 | 82 |
|
82 | 83 | component.PopulateContextDirectory( context, contextDirectory ); |
83 | | - component.WriteDockerfile( dockerfile ); |
| 84 | + component.WriteDockerfile( dockerfileContent ); |
84 | 85 | } |
| 86 | + |
| 87 | + TextFileHelper.WriteIfDifferent( dockerfilePath, dockerfileContent.ToString(), context ); |
85 | 88 |
|
86 | 89 | return true; |
87 | 90 | } |
|
0 commit comments