summaryrefslogtreecommitdiff
path: root/modules/mono/editor/GodotTools/GodotTools.Shared/GenerateGodotNupkgsVersions.targets
blob: 37bd4a0be0762c58b48c49b762bfa607b212214d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<Project>
  <!-- Generate C# file with the version of all the nupkgs bundled with Godot -->

  <Target Name="SetPropertiesForGenerateGodotNupkgsVersions">
    <PropertyGroup>
      <GeneratedGodotNupkgsVersionsFile>$(IntermediateOutputPath)GodotNupkgsVersions.g.cs</GeneratedGodotNupkgsVersionsFile>
    </PropertyGroup>
  </Target>

  <Target Name="GenerateGodotNupkgsVersionsFile"
          DependsOnTargets="_GenerateGodotNupkgsVersionsFile"
          BeforeTargets="PrepareForBuild;CompileDesignTime;BeforeCompile;CoreCompile">
    <ItemGroup>
      <Compile Include="$(GeneratedGodotNupkgsVersionsFile)" />
      <FileWrites Include="$(GeneratedGodotNupkgsVersionsFile)" />
    </ItemGroup>
  </Target>
  <Target Name="_GenerateGodotNupkgsVersionsFile"
          DependsOnTargets="SetPropertiesForGenerateGodotNupkgsVersions"
          Inputs="$(MSBuildProjectFile);$(MSBuildThisFileDirectory);$(MSBuildProjectFile)\..\..\..\SdkPackageVersions.props"
          Outputs="$(GeneratedGodotNupkgsVersionsFile)">
    <PropertyGroup>
      <GenerateGodotNupkgsVersionsCode><![CDATA[
namespace $(RootNamespace)
{
    public class GeneratedGodotNupkgsVersions
    {
        public const string GodotNETSdk = "$(PackageVersion_Godot_NET_Sdk)"%3b
        public const string GodotSourceGenerators = "$(PackageVersion_Godot_SourceGenerators)"%3b
        public const string GodotSharp = "$(PackageVersion_GodotSharp)"%3b
    }
}
]]></GenerateGodotNupkgsVersionsCode>
    </PropertyGroup>
    <WriteLinesToFile Lines="$(GenerateGodotNupkgsVersionsCode)"
                      File="$(GeneratedGodotNupkgsVersionsFile)"
                      Overwrite="True" WriteOnlyWhenDifferent="True" />
  </Target>
</Project>