NetEscapades.ProjectInfo
0.1.0-beta4
dotnet add package NetEscapades.ProjectInfo --version 0.1.0-beta4
NuGet\Install-Package NetEscapades.ProjectInfo -Version 0.1.0-beta4
<PackageReference Include="NetEscapades.ProjectInfo" Version="0.1.0-beta4" />
<PackageVersion Include="NetEscapades.ProjectInfo" Version="0.1.0-beta4" />
<PackageReference Include="NetEscapades.ProjectInfo" />
paket add NetEscapades.ProjectInfo --version 0.1.0-beta4
#r "nuget: NetEscapades.ProjectInfo, 0.1.0-beta4"
#:package NetEscapades.ProjectInfo@0.1.0-beta4
#addin nuget:?package=NetEscapades.ProjectInfo&version=0.1.0-beta4&prerelease
#tool nuget:?package=NetEscapades.ProjectInfo&version=0.1.0-beta4&prerelease
NetEscapades.ProjectInfo
NetEscapades.ProjectInfo is a small source generator that echoes values from your project file into a generated ProjectInfo class, as const string values or as ReadOnlySpan<byte> UTF-8 literals.
Adding NetEscapades.ProjectInfo to your project
Add the package to your application using
dotnet add package NetEscapades.ProjectInfo
You can mark the package as PrivateAssets="all", as nothing from it is needed at runtime.
Usage
Declare the values you want in your .csproj file:
<ItemGroup>
<ProjectInfoString Include="Version" Value="1.2.3" />
<ProjectInfoUtf8 Include="VersionBytes" Value="4.5.6" />
</ItemGroup>
This generates the following class:
#nullable enable
internal static partial class ProjectInfo
{
public const string Version = "1.2.3";
public static global::System.ReadOnlySpan<byte> VersionBytes => "4.5.6"u8;
}
ProjectInfoStringgenerates apublic const string.ProjectInfoUtf8generates aReadOnlySpan<byte>property using a"..."u8literal. This requires C# 11 or later (and a target that hasReadOnlySpan<byte>, e.g. the System.Memory package on .NET Framework).- The item name (
Version) is the member name, and theValuemetadata is the value (an empty or missingValuegenerates""). Nothing is generated if you don't declare any items.
The class is generated in your project's <RootNamespace> if one is set, otherwise in the global namespace. It is internal and partial by default; set <ProjectInfoVisibility>public</ProjectInfoVisibility> to make it public.
Diagnostics
Invalid items are reported as errors and skipped; other items are still generated.
| ID | Meaning |
|---|---|
| NEPI001 | The item name is not a valid C# identifier (or is ProjectInfo) |
| NEPI002 | The item name is defined more than once (the first definition wins) |
| NEPI003 | No longer used: an empty Value generates an empty string |
| NEPI004 | ProjectInfoUtf8 is used with a language version lower than C# 11 |
| NEPI005 | An item could not be read: values containing a back-quote (`) are not supported |
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta4 | 1,936 | 10/30/2026 |
| 0.1.0-beta3 | 64,519 | 10/26/2026 |
| 0.1.0-beta2 | 381 | 10/22/2026 |
| 0.1.0-beta1 | 56 | 10/22/2026 |
## 0.1.0-beta4
### Fixes
* Allow empty `Value`s, which generate an empty string (`""` / `""u8`) instead of reporting NEPI003. NEPI003 is no longer used.
## 0.1.0-beta3
### Fixes
* Fix builds failing on MSBuild versions earlier than 18.3 (e.g. the .NET 7, 8 and 9 SDKs), which don't allow `System.Uri` in property functions.
## 0.1.0-beta2
### Fixes
* Fix NEPI001 (empty item name) when only one of `<ProjectInfoString>` or `<ProjectInfoUtf8>` is declared
## 0.1.0-beta1
### Features
* Add `<ProjectInfoString>` and `<ProjectInfoUtf8>` items, which are echoed into a generated `ProjectInfo` class as `const string` values and `ReadOnlySpan<byte>` UTF-8 literals
* Add the `ProjectInfoVisibility` MSBuild property to make the generated class `public`
* Add diagnostics NEPI001-NEPI005 for invalid items
See https://github.com/andrewlock/NetEscapades.ProjectInfo/blob/main/CHANGELOG.md#v010-beta4 for more details.