TzData.Runtime.AutoInit 1.0.0

dotnet add package TzData.Runtime.AutoInit --version 1.0.0
                    
NuGet\Install-Package TzData.Runtime.AutoInit -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TzData.Runtime.AutoInit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TzData.Runtime.AutoInit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TzData.Runtime.AutoInit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TzData.Runtime.AutoInit --version 1.0.0
                    
#r "nuget: TzData.Runtime.AutoInit, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TzData.Runtime.AutoInit@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TzData.Runtime.AutoInit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TzData.Runtime.AutoInit&version=1.0.0
                    
Install as a Cake Tool

TzData.Runtime.AutoInit

Opt-in companion package for TzData.Runtime. It injects a module initializer into executable projects so TzDataRuntime.Configure() runs before Main — no startup code needed.

<ItemGroup>
  <PackageReference Include="TzData.Runtime.AutoInit" Version="1.0.0" />
</ItemGroup>

The initializer only sets TZDIR when it is not already set; it does not set TZ. If you need a non-UTC local zone, call TzDataRuntime.Configure(defaultTimeZoneId: "...") yourself, or set TZ in the environment.

Guarantees and limits

  • Injected only when OutputType is Exe or WinExe. Libraries do not get the initializer, because a library may load after the app has already used TimeZoneInfo.
  • Runs once, synchronously, before Main, for the app assembly.
  • Exceptions are swallowed: a missing data folder never prevents the app from starting (TimeZoneInfo then behaves as if tzdata were absent).
  • Windows: Configure() returns false; nothing changes.

Disable

<PropertyGroup>
  <TzDataRuntimeAutoInit>false</TzDataRuntimeAutoInit>
</PropertyGroup>

Then call TzDataRuntime.Configure() at startup yourself.

How it works

The package ships:

  • buildTransitive/TzData.Runtime.AutoInit.targets — adds the injected source only for executable projects;
  • content/TzDataAutoInit.cs — the module initializer that calls TzDataRuntime.Configure().

The package depends on TzData.Runtime so the API and the tzdata folder are available.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
1.0.0 89 11/20/2026