PropertyGroup
Eintrag zuletzt aktualisiert am: 15.04.2026
In einer
.NET-Projektdatei (
.csproj/.vbproj/.vcxproj) ist
PropertyGroup ein zentrales Element. Es dient dazu, Eigenschaften (Properties) für den Build mit
MSBuild bzw. dotnet build festzulegen.
Eine
PropertyGroup enthält Schlüssel-Wert-Paare, die das Verhalten des Builds steuern.
Man kann mehrere
PropertyGroup-Elemente in einer Datei verwenden.
Beispiel<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>MyApp</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
</PropertyGroup>
</Project>
Jede Zeile innerhalb von PropertyGroup ist eine Property:- TargetFramework: Zielplattform (.NET-Version)
- OutputType: Exe oder Library
- RootNamespace: Default-Namespace
- ImplicitUsings → automatische using-Statements
- Nullable → Nullable Reference Types aktivieren
- LangVersion → C#-Version (z.B. 15, latest, preview)
BedingungenPropertyGroup-Elemente können Bedingungen haben
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<Optimize>true</Optimize>
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
<DefineConstants>NET9</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0'">
<DefineConstants>NET10</DefineConstants>
<LangVersion>preview</LangVersion>
</PropertyGroup>