Skip to content

Commit 8fc241e

Browse files
committed
Create AutoUpdatedVersions.props if it does not exist.
1 parent f667a91 commit 8fc241e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/PostSharp.Engineering.BuildTools/Build/Files/AutoUpdatedVersionsFile.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,24 @@ public static bool TryWrite(
9090

9191
// Load XML.
9292
var thisAutoUpdatedVersionsFilePath = Path.Combine( context.RepoDirectory, context.Product.AutoUpdatedVersionsFilePath );
93-
var thisAutoUpdatedVersionsDocument = XDocument.Load( thisAutoUpdatedVersionsFilePath, LoadOptions.PreserveWhitespace );
94-
var thisAutoUpdatedVersionsPropertyGroupElement = thisAutoUpdatedVersionsDocument.Root!.Element( "PropertyGroup" )!;
9593

94+
XDocument thisAutoUpdatedVersionsDocument;
95+
96+
XElement thisAutoUpdatedVersionsPropertyGroupElement;
97+
98+
if ( File.Exists( thisAutoUpdatedVersionsFilePath ) )
99+
{
100+
thisAutoUpdatedVersionsDocument = XDocument.Load( thisAutoUpdatedVersionsFilePath, LoadOptions.PreserveWhitespace );
101+
thisAutoUpdatedVersionsPropertyGroupElement = thisAutoUpdatedVersionsDocument.Root!.Element( "PropertyGroup" )!;
102+
}
103+
else
104+
{
105+
thisAutoUpdatedVersionsDocument = new XDocument();
106+
thisAutoUpdatedVersionsDocument.Add( new XElement( "Project" ) );
107+
thisAutoUpdatedVersionsPropertyGroupElement = new XElement( "PropertyGroup" );
108+
thisAutoUpdatedVersionsDocument.Root!.Add( thisAutoUpdatedVersionsPropertyGroupElement );
109+
}
110+
96111
// Update dependency versions.
97112
var errors = 0;
98113
string? inheritedMainVersion = null;

0 commit comments

Comments
 (0)