Add UseCentralPackageManagement parameter

This commit is contained in:
Max Katz 2024-11-14 19:11:47 -08:00
Родитель fdab8fa640
Коммит 02ff846059
12 изменённых файлов: 100 добавлений и 6 удалений

Просмотреть файл

@ -15,6 +15,10 @@
},
"RemoveViewLocator": {
"longName": "remove-view-locator"
},
"UseCentralPackageManagement": {
"longName": "cpm",
"shortName": "cpm"
}
},
"usageExamples": [

Просмотреть файл

@ -29,6 +29,13 @@
"text": "Remove View Locator"
},
"isVisible": true
},
{
"id": "UseCentralPackageManagement",
"name": {
"text": "Use Central Package Management (CPM)"
},
"isVisible": true
}
]
}

Просмотреть файл

@ -77,6 +77,13 @@
"displayName": "Remove Avalonia ViewLocator",
"defaultValue": "false"
},
"UseCentralPackageManagement": {
"type": "parameter",
"description": "Defines if your app will Central Package Management (CPM). If disabled, Directory.Build.props will be created with shared Avalonia version.",
"datatype": "bool",
"displayName": "Use Central Package Management (CPM)",
"defaultValue": "true"
},
"HostIdentifier": {
"type": "bind",
"binding": "HostIdentifier"
@ -100,6 +107,18 @@
"exclude": [
"AvaloniaTest/App.RemoveViewLocator.axaml"
]
},
{
"condition": "(UseCentralPackageManagement)",
"exclude": [
"Directory.Build.props"
]
},
{
"condition": "(!UseCentralPackageManagement)",
"exclude": [
"Directory.Packages.props"
]
}
]
}

Просмотреть файл

@ -18,8 +18,13 @@
</ItemGroup>
<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.Android" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" />
<!--#else -->
<PackageReference Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
<!--#endif -->
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -7,7 +7,11 @@
</PropertyGroup>
<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.Browser" />
<!--#else -->
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<!--#endif -->
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,12 +13,21 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.Desktop" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="AvaloniaVersionTemplateParameter">
<PackageReference Include="Avalonia.Diagnostics" >
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<!--#else -->
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<!--#endif -->
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -7,7 +7,11 @@
</PropertyGroup>
<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.iOS" />
<!--#else -->
<PackageReference Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
<!--#endif -->
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -13,11 +13,26 @@
</ItemGroup>
<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia" />
<PackageReference Include="Avalonia.Themes.Fluent" />
<PackageReference Include="Avalonia.Fonts.Inter" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<!--#if (ReactiveUIToolkitChosen) -->
<PackageReference Include="Avalonia.ReactiveUI" />
<!--#elif (CommunityToolkitChosen)-->
<PackageReference Include="CommunityToolkit.Mvvm" />
<!--#endif -->
<!--#else -->
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="AvaloniaVersionTemplateParameter">
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
@ -26,5 +41,6 @@
<!--#elif (CommunityToolkitChosen)-->
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<!--#endif -->
<!--#endif -->
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,23 @@
<Project>
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<AvaloniaVersion>11.1.0</AvaloniaVersion>
</PropertyGroup>
<ItemGroup>
<!-- Avalonia packages -->
<!-- Important: keep version in sync! -->
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Android" Version="$(AvaloniaVersion)" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
</ItemGroup>
</Project>

Просмотреть файл

@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="AvaloniaVersionTemplateParameter">
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>

Просмотреть файл

@ -27,7 +27,7 @@
<PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="AvaloniaVersionTemplateParameter">
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>

Просмотреть файл

@ -130,7 +130,10 @@ Create-And-Build "avalonia.mvvm" "AvaloniaMvvm" "C#" "cb" "false" $binlog
Create-And-Build "avalonia.mvvm" "AvaloniaMvvm" "C#" "rvl" "true" $binlog
Create-And-Build "avalonia.mvvm" "AvaloniaMvvm" "C#" "rvl" "false" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "f" "net8.0" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "f" "net9.0" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "cpm" "true" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "cpm" "false" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "av" "11.2.1" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "m" "ReactiveUI" $binlog
Create-And-Build "avalonia.xplat" "AvaloniaXplat" "C#" "m" "CommunityToolkit" $binlog