Credfeto.Version.Information.Generator by Mark Ridgwell
Nuget / site data
Details
Info
Name: Credfeto.Version.Information.Generator
Source code generator for versioning.
Author: Mark Ridgwell
NuGet: https://www.nuget.org/packages/Credfeto.Version.Information.Generator/
You can find more details at https://github.com/credfeto/credfeto-version-constants-generator
Source : https://github.com/credfeto/credfeto-version-constants-generator
Original Readme
credfeto-version-constants-generator
Source generator for embedding build information as compile time constants in C# projects.
Usage
Add the following to your project file:
<ItemGroup>
<PackageReference Include="Credfeto.Version.Information.Generator" Version="1.0.2.16" PrivateAssets="All"
ExcludeAssets="runtime"/>
</ItemGroup>
This generates a class called VersionInformation
in the root namespace of the project with the following properties
taken from properties in the project file:
internal static class VersionInformation
{
public const string Version = "0.0.0.1-test";
public const string Product = "Credfeto.Version.Information.Example.Tests";
public const string Company = "Example Company";
public const string Copyright = "Copyright © Example Company 2024";
}
Controlled by the following properties:
<PropertyGroup>
<Company>Example Company</Company>
<Copyright>Copyright © Example Company 2024</Copyright>
</PropertyGroup>
- Version comes from the
AssemblyInformationalVersion
that can be set using the/p:Version=0.0.1-test
command line argument to MSBuild. or a<Version>
property in the project file. - Product comes from the Root Namespace property for the assembly.
Build Status
Branch | Status |
---|---|
main | |
release |
Changelog
View changelog
Contributors
About
Embedding build information as compile time constants in C# projects.
How to use
Example ( source csproj, source files )
- CSharp Project
- Program.cs
This is the CSharp Project that references Credfeto.Version.Information.Generator
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<PropertyGroup>
<!-- this is the code to start RSCG -->
<Version>2024.11.15.450</Version>
<Company>AOM</Company>
<Copyright>MIT</Copyright>
<Product>Info Test</Product>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Credfeto.Version.Information.Generator" Version="1.0.2.16" PrivateAssets="All"
ExcludeAssets="runtime"/>
</ItemGroup>
</Project>
This is the use of Credfeto.Version.Information.Generator in Program.cs
Console.WriteLine(Info.VersionInformation.Version);
Console.WriteLine(Info.VersionInformation.Product);
Generated Files
Those are taken from $(BaseIntermediateOutputPath)\GX
- Info.VersionInformation.generated.cs
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version: Current
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.CodeDom.Compiler;
namespace Info;
[GeneratedCode(tool: "Credfeto.Version.Information.Generator", version: "1.0.2.16")]
internal static class VersionInformation
{
public const string Version = "2024.11.15.450";
public const string Product = "Info";
public const string Company = "AOM";
public const string Copyright = "MIT";
}
Usefull
Download Example (.NET C# )
Share Credfeto.Version.Information.Generator
https://ignatandrei.github.io/RSCG_Examples/v2/docs/Credfeto.Version.Information.Generator