Files
Electron.NET/nuke/CommonPropsParser.cs
softworkz bef7a42fbb Update nuke build with the following changes:
- Remove obsolete sample targets
- Restore and build solution (.Lean) instead of projects
- Read version from common.props, compare with latest changelog version
  and fail if not equal
- Keep PostFix separate from version (AssemblyVersion may not have
  a postfix), so the postfix will go into the package version and
  file name as well as the informational version (visible in file
  properties dialog on Windows)
- Add "ElectronNET.Core " as prefix to GitHub release names (to
  disambiguate with earlier versions)
2025-10-14 00:19:50 +02:00

33 lines
800 B
C#

using System;
using System.Linq;
using System.Xml.Linq;
/// <summary>
/// Parses a version from an MSBuild .props file (XML).
/// </summary>
public sealed class CommonPropsParser
{
/// <summary>
/// Initializes a new instance of the <see cref="ReleaseNotesParser"/> class.
/// </summary>
public CommonPropsParser()
{
}
public Version Parse(string propsPath)
{
var doc = XDocument.Load(propsPath);
var versionElement = doc
.Descendants()
.FirstOrDefault(e => e.Name.LocalName == "Version");
if (Version.TryParse(versionElement?.Value.Trim(), out var version))
{
version = new Version(version.Major, version.Minor, version.Build);
return version;
}
return null;
}
}