Skip to content

Commit

Permalink
Merge pull request #280 from AvaloniaUI/directory-packages
Browse files Browse the repository at this point in the history
Optional Directory.Packages.props (enabled by default)
  • Loading branch information
maxkatz6 authored Nov 15, 2024
2 parents 11d9a54 + 6028455 commit 1f69a9c
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 9 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ steps:
displayName: 'Use .NET SDK'
inputs:
packageType: 'sdk'
version: 8.0.100
version: 9.0.100
- task: DotNetCoreCLI@2
displayName: 'Pack Templates'
inputs:
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ Available parameters:

*By default*: false

``-cpm``

*Description*: Defines if your app will Central Package Management (CPM). If disabled, Directory.Build.props will be created with shared Avalonia version.

*Options*: **true**, **false**

*By default*: true

# Creating a new Window

To create a new `Window` called `MyNewWindow`, in the namespace `MyApp` run:
Expand Down
4 changes: 4 additions & 0 deletions templates/csharp/xplat/.template.config/dotnetcli.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
},
"RemoveViewLocator": {
"longName": "remove-view-locator"
},
"UseCentralPackageManagement": {
"longName": "cpm",
"shortName": "cpm"
}
},
"usageExamples": [
Expand Down
7 changes: 7 additions & 0 deletions templates/csharp/xplat/.template.config/ide.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"text": "Remove View Locator"
},
"isVisible": true
},
{
"id": "UseCentralPackageManagement",
"name": {
"text": "Use Central Package Management (CPM)"
},
"isVisible": true
}
]
}
19 changes: 19 additions & 0 deletions templates/csharp/xplat/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -100,6 +107,18 @@
"exclude": [
"AvaloniaTest/App.RemoveViewLocator.axaml"
]
},
{
"condition": "(UseCentralPackageManagement)",
"exclude": [
"Directory.Build.props"
]
},
{
"condition": "(!UseCentralPackageManagement)",
"exclude": [
"Directory.Packages.props"
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
<TargetFramework>FrameworkParameter-browser</TargetFramework>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.Browser" />
<!--#else -->
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
<!--#endif -->
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
</PropertyGroup>

<ItemGroup>
<!--#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" >
<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="AvaloniaVersionTemplateParameter">
<PackageReference Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
<!--#endif -->
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
</PropertyGroup>

<ItemGroup>
<!--#if (UseCentralPackageManagement) -->
<PackageReference Include="Avalonia.iOS" />
<!--#else -->
<PackageReference Include="Avalonia.iOS" Version="$(AvaloniaVersion)" />
<!--#endif -->
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions templates/csharp/xplat/AvaloniaTest.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Android", "Ava
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DA99C4E-89E3-4049-9C22-0A7EC60D83D8}"
ProjectSection(SolutionItems) = preProject
#if (UseCentralPackageManagement)
Directory.Build.props = Directory.Build.props
#else
Directory.Build.props = Directory.Build.props
#endif
EndProjectSection
EndProject
Global
Expand Down
20 changes: 18 additions & 2 deletions templates/csharp/xplat/AvaloniaTest/AvaloniaTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)" />
<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>
Expand All @@ -26,5 +41,6 @@
<!--#elif (CommunityToolkitChosen)-->
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<!--#endif -->
<!--#endif -->
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion templates/csharp/xplat/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<AvaloniaVersion>AvaloniaVersionTemplateParameter</AvaloniaVersion>
</PropertyGroup>
</Project>
27 changes: 27 additions & 0 deletions templates/csharp/xplat/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<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)" />
<!--#if (ReactiveUIToolkitChosen) -->
<PackageVersion Include="Avalonia.ReactiveUI" Version="$(AvaloniaVersion)" />
<!--#elif (CommunityToolkitChosen)-->

<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<!--#endif -->

<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>FrameworkParameter-ios</TargetFramework>
<SupportedOSPlatformVersion>13.0</SupportedOSPlatformVersion>
<ProvisioningType>manual</ProvisioningType>
<Nullable>enable</Nullable>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>

<!-- These properties need to be set in order to run on a real iDevice -->
Expand Down
3 changes: 1 addition & 2 deletions templates/fsharp/xplat/AvaloniaTest/AvaloniaTest.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>FrameworkParameter</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<!--#if (UseCompiledBindings) -->
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
Expand All @@ -28,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>
Expand Down
3 changes: 3 additions & 0 deletions tests/build-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f69a9c

Please sign in to comment.