Properties
The MSBuild properties described on this page are used by the Zig SDK. These properties can all be set in PropertyGroups in your project file. Most of them should have sensible defaults for new projects; a few (such as TreatWarningsAsErrors and SymbolVisibility) have defaults that are not quite as sensible for unfortunate historical reasons.
Project Setup
AssemblyName: Name of the project. By default, this is set to the file name of the project file. Used to compute the final binary name (e.g.foobecomeslibfoo.so).OutputType(Exe,WinExe,Library): Output binary type. When targeting Windows and building executables,ExeandWinExewill target the CUI and GUI subsystems, respectively. Defaults toLibrary.IsTestable(true,false): Enable/disabledotnet testfor Zig projects. Defaults totrue.IsPackable(true,false): Enable/disabledotnet pack. Defaults totrue.IsPublishable(true,false): Enable/disabledotnet publish. Defaults totrue.DefaultSources(true,false): Enable/disable defaultCompileitem includes. Defaults totrue.Deterministic(true,false): Enable/disable deterministic builds. Among other things, this will try to prevent the compiler from using absolute paths and will prevent usage of certain problematic language features like__TIME__. Defaults totrue.EditorSupport(true,false): Enable/disable editor support. For C/C++ projects, this means generating acompile_commands.jsoncompilation database inIntermediateOutputPath. Defaults totrue.FormatOnBuild(true,false): Enable/disable formatting source code into canonical style on build in Zig projects. Defaults tofalse.
Package Information
Product: Human-friendly product name for the package. Defaults to the value ofAssemblyName.Authors: A list of package authors. Defaults to the value ofAssemblyName.Description: Brief description of the package. Defaults toPackage Description.Version: Package version in Semantic Versioning 2.0.0 form. Defaults to1.0.0.Copyright: Copyright notice for the package. Unset by default.PackageLicenseExpression: SPDX license identifier for the package. Unset by default.PackageProjectUrl: Website URL associated with the package. Unset by default.RepositoryUrl: Source code repository URL for the package. Unset by default.
Preprocessor
PublicHeadersPath: Can be set to a directory containing public C/C++ headers. These headers will be included in the NuGet package and will flow to dependent projects. This directory will also be treated as anIncludeDirectory. Unset by default.DefineConstants: A comma-separated list of preprocessor macros to define. Each entry can be a simple name or an assignment of the formNAME=VALUE. These macros are passed to the compiler with the-Dflag. Note that this applies to Zig as well, not just C/C++.CompilerDefines(true,false): Enable/disable adding some implicitDefineConstantsmacros that describe the Zig compiler version. Defaults totrue.PlatformDefines(true,false): Enable/disable adding some implicitDefineConstantsmacros that describe the target platform characteristics. Defaults totrue.ConfigurationDefines(true,false): Enable/disable adding some implicitDefineConstantsmacros that describe the build configuration (Debug,ReleaseFast, etc). Defaults totrue.PackageDefines(true,false): Enable/disable adding some implicitDefineConstantsmacros that describe the project being built. Defaults totrue.
Language Features
ZigVersion(major.minor.patch): The version of the Zig compiler toolset to use. Defaults to the latest version known to the Zig SDK package that is in use.LanguageStandard: The language standard used for C/C++ projects. Passed to Clang's-stdflag. Defaults to the latest standards known to the compiler version thatZigVersiondefaults to.AccessControl(true,false): Enable/disable access control in C++ projects. Defaults totrue.BlockExtensions(true,false): Enable/disable Clang's block language extensions. Defaults tofalse.CxxExceptions(true,false): Enable/disable C++ exceptions. In C projects, this controls whether the C code will be unwindable by C++ exceptions. Defaults totrue.AsyncExceptions(true,false): Enable/disable the ability to catch SEH exceptions with standardtry/catchstatements. This only applies when targeting Windows. Defaults tofalse.CxxReflection(true,false): Enable/disable generating C++ run-time type information. This feature is required for some uses ofdynamic_cast. Defaults totrue.MicrosoftExtensions(true,false): Enable/disable a variety of Microsoft C/C++ extensions. Defaults tofalse, but note that the compiler itself always enables some parts of this when targeting Windows as Win32 headers require it.NoEntryPoint(true,false): Enable/disable the omission of an entry point function when building executables. Defaults tofalse.UnicodeEnvironment(true,false): Enable/disable compiling for a Unicode environment when targeting Windows in C/C++ projects. This causes theUNICODEand_UNICODEmacros to be defined, and makes it so thatwmainandwWinMainentry point functions must be used when building executables. Defaults tofalse.
Static Analysis
EnforceCodeStyleInBuild(true,false): Enable/disable checking that source code is in the canonical style during build in Zig projects. Defaults tofalse.BufferAnalysis(true,false): Enable/disable static analysis with unsafe buffer annotations in C/C++ projects. Defaults tofalse.ConsumptionAnalysis(true,false): Enable/disable static analysis with consumption and type state annotations in C/C++ projects. Defaults totrue.DocumentationAnalysis(true,false): Enable/disable Doxygen documentation comment checking in C/C++ projects. Defaults tofalse.NullabilityAnalysis(true,false): Enable/disable static analysis with nullability annotations in C/C++ projects. Defaults totrue.TagAnalysis(true,false): Enable/disable static analysis with type tag annotations in C/C++ projects. Defaults totrue.ThreadingAnalysis(true,false): Enable/disable static analysis with thread safety annotations in C/C++ projects. Defaults totrue.TrustAnalysis(true,false): Enable/disable static analysis with trusted computing base annotations in C/C++ projects. Defaults totrue.WarningLevel(0-4): How aggressively the compiler should analyze C/C++ projects for potentially problematic code.0disables warnings completely;4enables all warnings, including a few controversial ones. Defaults to3.DisableWarnings: A comma-separated list of warning names (e.g.cast-align) to disable in C/C++ projects. Unset by default.TreatWarningsAsErrors(true,false): Enable/disable reporting warnings as errors in C/C++ projects. Defaults tofalse.
Code Generation
Configuration(Debug,Release): Specifies the overarching configuration. WhenReleaseis specified,ReleaseModecomes into effect. Defaults toDebug. Usually specified by the user as e.g.dotnet build -c Release.DebugSymbols(true,false): Enable/disable emitting debug symbols. Defaults totrueifConfigurationisDebug; otherwise,false.ReleaseMode(Fast,Safe,Small): The build mode to use whenConfigurationis set toRelease. Defaults toFast.ExecutionModel(Command,Reactor): Specifies the execution model to use when building WebAssembly executables. Defaults toCommand.FastMath(true,false): Enable/disable certain lossy floating point optimizations that may not be standards-compliant. Defaults tofalse.LinkTimeOptimization(true,false): Enable/disable link-time optimization. Defaults tofalse.SymbolExports(Used,All): Specifies whether to export all public symbols or only those that are needed to link successfully. This only applies when building executables. Defaults toUsed.SymbolVisibility(Default,Hidden): Specifies the symbol visibility in C/C++ projects when__attribute__((visibility(...)))is not specified.Default(the default 😉) means public, whileHiddenmeans private.AllowUndefinedSymbols(true,false): Enable/disable permitting undefined symbols when linking. This usually only applies when building libraries. Defaults tofalse.EagerBinding(true,false): Enable/disable eager binding of symbols when performing dynamic linking at run time. Eager binding has security benefits, especially in combination withRelocationHardening. It is also more reliable if calling external functions from signal handlers. Defaults totrue.RelocationHardening(true,false): Enable/disable marking relocations as read-only. This has security benefits, especially in combination withEagerBinding. Defaults totrue.ImageBase: The location in memory that the binary should be loaded at. Only takes effect at run time ifDynamicImageBaseisfalse. Unset by default.DynamicImageBase(true,false): Enable/disable ASLR, i.e. randomization of the image base at run time. This only applies when targeting Windows. Defaults totrue.StackSize: Sets the stack size for the main thread. This only applies when building executables. Unset by default.Sanitizers: A semicolon-separated list of sanitizers to instrument code with. Currently, onlythreadis supported. Unset by default.
Cross-Compilation
RuntimeIdentifier: Specifies the runtime identifier (i.e. platform) to target. When unset,BuildandCleanwill run for all runtime identifiers specified inRuntimeIdentifiers. Usually specified by the user as e.g.dotnet build -r linux-x64. Unset by default.RuntimeIdentifiers: A semicolon-separated list of runtime identifiers that the project supports. All targets in this list will be cross-compiled as necessary. Defaults to all targets that the Zig compiler has known-good support for.UseMicrosoftAbi(true,false): Enable/disable using the Microsoft ABI when targeting Windows. This may be necessary when linking to static libraries containing C++ code that was compiled for the Microsoft ABI. Note that it is currently not possible to cross-compile from non-Windows platforms when using the Microsoft ABI. Unset by default.UseEmulator(true,false): Enable/disable usage of an appropriate binary emulator when cross-compiling. Defaults totrue.
Last updated