From a005b40022e9eab339a4cf480c6a605edba2de90 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 15 Aug 2020 23:19:27 -0700 Subject: [PATCH] Build updates Use the version in the .csproj if there is no local git repository. Always use Windows line endings in codegen output. Update build dependency versions. We're still using GitVersion 5.1.3 because of https://github.com/nuke-build/nuke/issues/509. --- DotnetCliVersion.txt | 2 +- build/Build.cs | 14 +++++++++++++- build/CodeGen/ResultCodegen.cs | 6 ++++++ build/_build.csproj | 6 +++--- src/LibHac/LibHac.csproj | 2 +- tests/LibHac.Tests/LibHac.Tests.csproj | 4 ++-- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/DotnetCliVersion.txt b/DotnetCliVersion.txt index 4ba19403..bbe838d1 100644 --- a/DotnetCliVersion.txt +++ b/DotnetCliVersion.txt @@ -1 +1 @@ -3.1.300 \ No newline at end of file +3.1.401 \ No newline at end of file diff --git a/build/Build.cs b/build/Build.cs index 42be3f9b..95c88582 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -104,12 +104,19 @@ namespace LibHacBuild } catch (Exception e) { - Logger.Error(e); + if (!e.Message.Contains("not a git repository", StringComparison.OrdinalIgnoreCase)) + { + Logger.Error(e); + } } if (gitRepository == null || gitVersion == null) { Logger.Normal("Unable to read Git version."); + + VersionString = GetCsprojVersion(); + Logger.Normal($"Using version from .csproj: {VersionString}"); + return; } @@ -656,5 +663,10 @@ namespace LibHacBuild return pwd.ToString(); } + + public string GetCsprojVersion() + { + return XmlTasks.XmlPeekSingle(LibHacProject.Path, "/Project/PropertyGroup/VersionPrefix", null); + } } } diff --git a/build/CodeGen/ResultCodegen.cs b/build/CodeGen/ResultCodegen.cs index 565d533d..184ad316 100644 --- a/build/CodeGen/ResultCodegen.cs +++ b/build/CodeGen/ResultCodegen.cs @@ -321,6 +321,12 @@ namespace LibHacBuild.CodeGen hasBom = oldFile.AsSpan(0, 3).SequenceEqual(bom); } + // Make line endings the same on Windows and Unix + if (Environment.NewLine == "\n") + { + text = text.Replace("\n", "\r\n"); + } + byte[] newFile = (hasBom ? bom : new byte[0]).Concat(Encoding.UTF8.GetBytes(text)).ToArray(); if (oldFile?.SequenceEqual(newFile) == true) diff --git a/build/_build.csproj b/build/_build.csproj index e852b673..8e372242 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/src/LibHac/LibHac.csproj b/src/LibHac/LibHac.csproj index a4920296..e9e23fad 100644 --- a/src/LibHac/LibHac.csproj +++ b/src/LibHac/LibHac.csproj @@ -44,7 +44,7 @@ - + diff --git a/tests/LibHac.Tests/LibHac.Tests.csproj b/tests/LibHac.Tests/LibHac.Tests.csproj index 7a208ee4..b298de9c 100644 --- a/tests/LibHac.Tests/LibHac.Tests.csproj +++ b/tests/LibHac.Tests/LibHac.Tests.csproj @@ -7,11 +7,11 @@ - + - +