write version files without newlines

This commit is contained in:
goat 2022-12-10 17:21:22 +01:00
parent 4f74b7401a
commit d3797e2ff6
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -112,29 +112,25 @@
<Target Name="GetGitHash" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)' == '' AND '$(Configuration)' == 'Release'"> <Target Name="GetGitHash" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)' == '' AND '$(Configuration)' == 'Release'">
<PropertyGroup> <PropertyGroup>
<!-- temp file for the git version (lives in "obj" folder)-->
<VerFile>$(IntermediateOutputPath)gitver</VerFile>
<VerFileClientStructs>$(IntermediateOutputPath)csver</VerFileClientStructs>
<TempVerFile>$(OutputPath)TEMP_gitver.txt</TempVerFile> <TempVerFile>$(OutputPath)TEMP_gitver.txt</TempVerFile>
</PropertyGroup> </PropertyGroup>
<!-- write the hash to the temp file.-->
<Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))&quot; describe --long --always --dirty &gt; $(VerFile)" />
<Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))\..\lib\FFXIVClientStructs&quot; describe --long --always --dirty &gt; $(VerFileClientStructs)" />
<Exec Command="type $(VerFile) &gt; $(TempVerFile)" />
<!-- read the version into the GitVersion itemGroup--> <!-- write the hash to the temp file.-->
<ReadLinesFromFile File="$(VerFile)"> <Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))&quot; describe --long --always --dirty" ConsoleToMSBuild="true">
<Output TaskParameter="Lines" ItemName="GitVersion" /> <Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitDescribeOutput" />
</ReadLinesFromFile> </Exec>
<ReadLinesFromFile File="$(VerFileClientStructs)"> <Exec Command="git -C &quot;$(ProjectDir.Replace('\','\\'))\..\lib\FFXIVClientStructs&quot; describe --long --always --dirty" ConsoleToMSBuild="true">
<Output TaskParameter="Lines" ItemName="GitVersionClientStructs" /> <Output TaskParameter="ConsoleOutput" PropertyName="ClientStructsGitDescribeOutput" />
</ReadLinesFromFile> </Exec>
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.--> <!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
<PropertyGroup> <PropertyGroup>
<BuildHash>@(GitVersion)</BuildHash> <BuildHash>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitDescribeOutput), @"\t|\n|\r", ""))</BuildHash>
<BuildHashClientStructs>@(GitVersionClientStructs)</BuildHashClientStructs> <BuildHashClientStructs>$([System.Text.RegularExpressions.Regex]::Replace($(ClientStructsGitDescribeOutput), @"\t|\n|\r", ""))</BuildHashClientStructs>
</PropertyGroup> </PropertyGroup>
<!-- Looks like this is the only way to write a file without a carriage return in msbuild... -->
<Exec Command="echo|set /P =&quot;$(BuildHash)&quot; &gt; $(TempVerFile)" IgnoreExitCode="true"/>
</Target> </Target>
<Target Name="WriteGitHash" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'"> <Target Name="WriteGitHash" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- names the obj/.../CustomAssemblyInfo.cs file --> <!-- names the obj/.../CustomAssemblyInfo.cs file -->