fix: Enable Git version info and fix JSON null handling

- Un-comment the `GenerateGitVersionInformation` target in `Versioning.csproj` to enable version information generation on non-Windows systems.
- Remove the execution command previously used to compile and run the project in `Versioning.csproj`.
- Adjust the path for the generated `gitversion.json` file in `Versioning.csproj`, moving it one directory up.
- Update `Program.cs` to change the handling of null JSON values by assigning an empty string for string type, while keeping other JSON value conversions unchanged.
This commit is contained in:
MSWS
2025-08-06 22:15:35 -07:00
parent 45ad0375e5
commit edeb0e08b8
2 changed files with 4 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ foreach (var property in json.EnumerateObject()) {
break;
case JsonValueKind.Null:
// No const nulls in C#, so use string.Empty or 0 as appropriate — or skip
line = $" // {name} is null and omitted";
line = $" public const string {name} = \"\";"; // Assuming string type
break;
default:
// Skip unexpected structures like arrays/objects

View File

@@ -7,8 +7,7 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- <Target Name="GenerateGitVersionInformation" BeforeTargets="BeforeCompile" Condition="'$(OS)' != 'Windows_NT'">-->
<!-- <Exec Command="dotnet-gitversion '$(ProjectDir)' &gt; '$(ProjectDir)/gitversion.json'" />-->
<!-- <Exec Command="dotnet run &#45;&#45;project 'Versioning/Versioning.csproj'" />-->
<!-- </Target>-->
<Target Name="GenerateGitVersionInformation" BeforeTargets="BeforeCompile" Condition="'$(OS)' != 'Windows_NT'">
<Exec Command="dotnet-gitversion '$(ProjectDir)' &gt; '$(ProjectDir)/../gitversion.json'"/>
</Target>
</Project>