Skip to content

Commit

Permalink
Merge pull request #512 from AndreasReitberger/511-improve-maui-packa…
Browse files Browse the repository at this point in the history
…ging-for-nuget

Create PackMauiAssets.targets
  • Loading branch information
AndreasReitberger authored Jun 6, 2024
2 parents b7e90d5 + cb29383 commit 0f2552f
Show file tree
Hide file tree
Showing 6 changed files with 215 additions and 20 deletions.
119 changes: 119 additions & 0 deletions PackMauiAssets.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>

<PropertyGroup>
<PackMauiItems Condition="'$(PackMauiItems)' == ''">true</PackMauiItems>
<!-- Defaults to '$(PackageId).targets' if no path was specified -->
<PackMauiItemsTargetsFileName Condition="'$(PackMauiItemsTargetsFileName)' == ''"></PackMauiItemsTargetsFileName>
<PackMauiItemsExcludes>**\.DS_Store</PackMauiItemsExcludes>
</PropertyGroup>

<!-- Collect all .NET MAUI items -->
<ItemGroup Condition="'$(TargetFramework)' == '' and '$(PackMauiItems)' == 'true'">

<_SafeMauiImage Include="@(MauiImage)" Exclude="$(PackMauiItemsExcludes)" />
<_SafeMauiIcon Include="@(MauiIcon)" Exclude="$(PackMauiItemsExcludes)" />
<_SafeMauiSplashScreen Include="@(MauiSplashScreen)" Exclude="$(PackMauiItemsExcludes)" />
<_SafeMauiAsset Include="@(MauiAsset)" Exclude="$(PackMauiItemsExcludes)" />
<_SafeMauiFont Include="@(MauiFont)" Exclude="$(PackMauiItemsExcludes)" />

<!-- MauiImage -->
<_PackageFiles Include="@(_SafeMauiImage)" Pack="True" PackagePath="buildTransitive\_MauiItems\Images\%(Filename)%(Extension)" />
<_MauiImageForegroundProxy Include="@(_SafeMauiImage->HasMetadata('ForegroundFile'))" BackgroundFile="%(Filename)%(Extension)" />
<_PackageFiles Include="@(_MauiImageForegroundProxy->'%(ForegroundFile)')" Pack="True" PackagePath="buildTransitive\_MauiItems\Images\Foreground\%(BackgroundFile)" />
<!-- MauiIcon -->
<_PackageFiles Include="@(_SafeMauiIcon)" Pack="True" PackagePath="buildTransitive\_MauiItems\AppIcon\%(Filename)%(Extension)" />
<_MauiIconForegroundProxy Include="@(_SafeMauiIcon->HasMetadata('ForegroundFile'))" BackgroundFile="%(Filename)%(Extension)" />
<_PackageFiles Include="@(_MauiIconForegroundProxy->'%(ForegroundFile)')" Pack="True" PackagePath="buildTransitive\_MauiItems\AppIcon\Foreground\%(BackgroundFile)" />
<!-- MauiSplashScreen -->
<_PackageFiles Include="@(_SafeMauiSplashScreen)" Pack="True" PackagePath="buildTransitive\_MauiItems\Splash\%(Filename)%(Extension)" />
<!-- MauiFont -->
<_PackageFiles Include="@(_SafeMauiFont)" Pack="True" PackagePath="buildTransitive\_MauiItems\Fonts\%(Filename)%(Extension)" />
<!-- MauiAsset -->
<_PackageFiles Include="@(_SafeMauiAsset)" Pack="True" PackagePath="buildTransitive\_MauiItems\Raw\%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<Target Name="GenerateIncludeMauiItemsTargets" BeforeTargets="GenerateNuspec" Condition="'$(PackMauiItems)' == 'true'">

<PropertyGroup>
<_IncludeMauiItemsTargetsBoilerplate>
<![CDATA[
<Project>
<ItemGroup>
{{MauiItems}}
</ItemGroup>
</Project>
]]>
</_IncludeMauiItemsTargetsBoilerplate>
</PropertyGroup>

<!-- Add all items to the generated targets file -->
<ItemGroup>
<!-- MauiImage -->
<_IncludeMauiItems Include="@(_SafeMauiImage->'&lt;MauiImage
Include=&quot;%24(MSBuildThisFileDirectory)_MauiItems\Images\%(Filename)%(Extension)&quot;
Link=&quot;%(Link)&quot;
BaseSize=&quot;%(BaseSize)&quot;
Resize=&quot;%(Resize)&quot;
TintColor=&quot;%(TintColor)&quot;
Color=&quot;%(Color)&quot;
Visible=&quot;False&quot;
/&gt;')" />
<!-- MauiIcon -->
<_IncludeMauiItems Include="@(_SafeMauiIcon->'&lt;MauiIcon
Include=&quot;%24(MSBuildThisFileDirectory)_MauiItems\AppIcon\%(Filename)%(Extension)&quot;
ForegroundFile=&quot;%24(MSBuildThisFileDirectory)_MauiItems\AppIcon\Foreground\%(Filename)%(Extension)&quot;
Link=&quot;%(Link)&quot;
BaseSize=&quot;%(BaseSize)&quot;
Resize=&quot;%(Resize)&quot;
TintColor=&quot;%(TintColor)&quot;
Color=&quot;%(Color)&quot;
ForegroundScale=&quot;%(ForegroundScale)&quot;
Visible=&quot;False&quot;
/&gt;')" />
<!-- MauiSplashScreen -->
<_IncludeMauiItems Include="@(_SafeMauiSplashScreen->'&lt;MauiSplashScreen
Include=&quot;%24(MSBuildThisFileDirectory)_MauiItems\Splash\%(Filename)%(Extension)&quot;
Link=&quot;%(Link)&quot;
BaseSize=&quot;%(BaseSize)&quot;
Resize=&quot;%(Resize)&quot;
TintColor=&quot;%(TintColor)&quot;
Color=&quot;%(Color)&quot;
Visible=&quot;False&quot;
/&gt;')" />
<!-- MauiFont -->
<_IncludeMauiItems Include="@(_SafeMauiFont->'&lt;MauiFont
Include=&quot;%24(MSBuildThisFileDirectory)_MauiItems\Fonts\%(Filename)%(Extension)&quot;
Link=&quot;%(Link)&quot;
Visible=&quot;False&quot;
/&gt;')" />
<!-- MauiAsset -->
<_IncludeMauiItems Include="@(_SafeMauiAsset->'&lt;MauiAsset
Include=&quot;%24(MSBuildThisFileDirectory)_MauiItems\Raw\%(RecursiveDir)%(Filename)%(Extension)&quot;
Link=&quot;%(Link)&quot;
LogicalName=&quot;%(LogicalName)&quot;
Visible=&quot;False&quot;
/&gt;')" />
</ItemGroup>

<!-- Generate the targets file -->
<PropertyGroup>
<_IncludeMauiItem>@(_IncludeMauiItems, '%0A ')</_IncludeMauiItem>
<_IncludeMauiItemsTargetsBoilerplate>$(_IncludeMauiItemsTargetsBoilerplate.Replace('{{MauiItems}}', '$(_IncludeMauiItem)'))</_IncludeMauiItemsTargetsBoilerplate>
<_FinalPackMauiItemsTargetsFileName>$(PackageId).targets</_FinalPackMauiItemsTargetsFileName>
</PropertyGroup>
<ItemGroup>
<_IncludeMauiItemsTargetsLines Include="$(_IncludeMauiItemsTargetsBoilerplate)" />
</ItemGroup>
<WriteLinesToFile File="$(IntermediateOutputPath)_IncludeMauiAssets.g.targets"
Lines="@(_IncludeMauiItemsTargetsLines)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)_IncludeMauiAssets.g.targets" />
<_PackageFiles Include="$(IntermediateOutputPath)_IncludeMauiAssets.g.targets" Pack="True" PackagePath="buildTransitive\$(_FinalPackMauiItemsTargetsFileName)" />
</ItemGroup>

</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions src/SharedMauiXamlStylesLibrary.SampleApp/Views/ButtonsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@
Text="{x:Static icons:MaterialIcons.ProgressCheck}"
Style="{StaticResource Style.Core.Button.IconPrimary.MaterialDesign}"
/>
<Button
Grid.Row="1"
Grid.Column="1"
Margin="8,16"
Text="{x:Static icons:MaterialIcons.AlertCircleCheckOutline}"
Style="{StaticResource Style.Core.Button.Icon.MaterialDesign.Critical}"
/>
<Button
Grid.Row="1"
Grid.Column="2"
Margin="8,16"
Text="{x:Static icons:MaterialIcons.ScriptOutline}"
Style="{StaticResource Style.Core.Button.Icon.MaterialDesign.Error}"
/>
</Grid>
</VerticalStackLayout>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@

<ItemGroup>
<ProjectReference Include="..\SharedMauiXamlStylesLibrary\SharedMauiXamlStylesLibrary.csproj" />
<PackageReference Include="Syncfusion.Maui.Barcode" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Buttons" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Charts" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Core" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.DataGrid" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Expander" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Gauges" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Inputs" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.ListView" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Picker" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Scheduler" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Sliders" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.TabView" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.TreeView" Version="25.2.3" />
<PackageReference Include="Syncfusion.Maui.Barcode" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Buttons" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Charts" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Core" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.DataGrid" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Expander" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Gauges" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Inputs" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.ListView" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Picker" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Scheduler" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.Sliders" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.TabView" Version="25.2.7" />
<PackageReference Include="Syncfusion.Maui.TreeView" Version="25.2.7" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -254,8 +254,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
</ItemGroup>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,68 @@
</Setter>
</Style>

<Style x:Key="Style.Core.Button.Icon.MaterialDesign.Critical" TargetType="Button" BasedOn="{StaticResource Style.Core.Button.Icon.MaterialDesign}">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="PointerOver" >
<VisualState.Setters>
<Setter Property="Background" Value="{StaticResource Transparent}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Yellow100Accent}, Dark={StaticResource Yellow100Accent}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Background" Value="{StaticResource Transparent}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Yellow}, Dark={StaticResource Yellow}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource Gray100}, Dark={StaticResource Gray900}}" />
<Setter Property="TextColor" Value="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" />
</VisualState.Setters>
</VisualState>
<!--
<VisualState x:Name="Focused" />
<VisualState x:Name="Selected" />
-->
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>

<Style x:Key="Style.Core.Button.Icon.MaterialDesign.Error" TargetType="Button" BasedOn="{StaticResource Style.Core.Button.Icon.MaterialDesign}">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="PointerOver" >
<VisualState.Setters>
<Setter Property="Background" Value="{StaticResource Transparent}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Light_Error}, Dark={StaticResource Dark_Error}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Normal">
<VisualState.Setters>
<Setter Property="Background" Value="{StaticResource Transparent}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Light_Error}, Dark={StaticResource Dark_Error}}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource Gray100}, Dark={StaticResource Gray900}}" />
<Setter Property="TextColor" Value="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" />
</VisualState.Setters>
</VisualState>
<!--
<VisualState x:Name="Focused" />
<VisualState x:Name="Selected" />
-->
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>

<Style x:Key="Style.Core.Button.IconSmall.MaterialDesign" TargetType="Button" BasedOn="{StaticResource Style.Core.Button.Icon.MaterialDesign}">
<Setter Property="FontSize" Value="{StaticResource SmallTextSize}" />
<Setter Property="HeightRequest" Value="{OnIdiom Desktop=48, Tablet=48, Default=40}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@

<ItemGroup>
<PackageReference Update="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.21" />
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>

Expand Down

0 comments on commit 0f2552f

Please sign in to comment.