Skip to content

Add support for non-string constants #150

@kzu

Description

@kzu

Discussed in #103

Originally posted by rdeago May 19, 2022
I'll let code speak for me:

  <PropertyGroup>

    <!-- This still works, of course -->
    <Constant Name="Greeting" Value="Howdy!" />

    <!-- Constant type can be specified -->
    <Constant Name="Foo" Type="string" Value="Bar" />

    <!-- Int32, Integer (for the sake of VB projects) and int are all valid and map to System.Int32 -->
    <Constant Name="Answer" Type="int" Value="42" />

    <!-- Other numeric types work similarly -->
    <Constant Name="LongAnswer" Type="Int64" Value="42" />

    <!-- DateTime (and maybe TimeSpan, DateOnly, TimeOnly) may be supported too -->
    <Constant Name="BuildTime" Type="DateTime" Value="$([System.DateTime]::Now.ToString("O"))" />

  </PropertyGroup>

If this looks interesting, I can have a PR ready in a few days.

Back this issue
Back this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions