How to install Microsoft.UI.Xaml to Uno Platform Library #7528
-
I wanna to create my custom Expander style in the SomeCustomControlsProject.
Error:
Common.targets<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Check TargetPlatformMinVersion during build to block unsupported configurations. -->
<Target Name="MicrosoftUIXamlCheckTargetPlatformVersion" BeforeTargets="PrepareForBuild"
Condition="'$(TargetPlatformVersion)' != '' and '$(TargetPlatformMinVersion)' != '' and '$(SkipMicrosoftUIXamlCheckTargetPlatformVersion)'==''">
<PropertyGroup>
<MicrosoftUIXamlTargetPlatformMinCheckValue>$([System.Version]::Parse('$(TargetPlatformMinVersion)').Build)</MicrosoftUIXamlTargetPlatformMinCheckValue>
</PropertyGroup>
<Error
Text="Microsoft.UI.Xaml nuget package requires TargetPlatformMinVersion >= 10.0.15063.0 (current project is $(MicrosoftUIXamlTargetPlatformMinCheckValue))"
Condition="$(MicrosoftUIXamlTargetPlatformMinCheckValue) < 15063" />
<PropertyGroup>
<MicrosoftUIXamlTargetPlatformCheckValue>$([System.Version]::Parse('$(TargetPlatformVersion)').Build)</MicrosoftUIXamlTargetPlatformCheckValue>
</PropertyGroup>
<Error
Text="Microsoft.UI.Xaml nuget package requires TargetPlatformVersion >= 10.0.18362.0 (current project is $(MicrosoftUIXamlTargetPlatformCheckValue))"
Condition="$(MicrosoftUIXamlTargetPlatformCheckValue) < 18362" />
</Target>
<!-- WACK certification requires that types referenced by dependent packages exist in WinMD files in the root of the AppX.
However, the BuildNativePackage target requires that it *not* be in that location, or else that target will return an error.
In order to enable apps to pass WACK certification that reference packages that reference us, we'll add it to the package payload
after that target has completed. -->
<ItemGroup>
<XamlWinmd Include="$(MSBuildThisFileDirectory)..\lib\uap10.0\Microsoft.UI.Xaml.winmd">
<SkipHarvestingWinmdRegistration Condition="'$(MicrosoftUIXamlAppxVersion)' != ''">true</SkipHarvestingWinmdRegistration>
<TargetPath>$(WinMetadataDir)\Microsoft.UI.Xaml.winmd</TargetPath>
<OutputGroup>CustomOutputGroupForPackaging</OutputGroup>
<ProjectName>$(ProjectName)</ProjectName>
<Implementation Condition="'$(MicrosoftUIXamlAppxVersion)' == ''">Microsoft.UI.Xaml.dll</Implementation>
</XamlWinmd>
</ItemGroup>
<PropertyGroup>
<XamlWinmdName>Microsoft.UI.Xaml.winmd</XamlWinmdName>
<XamlCompactXbfName>Microsoft.UI.Xaml\DensityStyles\Compact.xbf</XamlCompactXbfName>
</PropertyGroup>
<Target Name="_FixWinmdCopyLocal" AfterTargets="ResolveNuGetPackageAssets">
<ItemGroup>
<XamlWinMdCopyLocal Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)' == '$(XamlWinmdName)'" />
</ItemGroup>
<ItemGroup Condition="'@(XamlWinMdCopyLocal)' != ''">
<ReferenceCopyLocalPaths Remove="@(XamlWinMdCopyLocal)" />
</ItemGroup>
</Target>
<Target Name="_FixWinmdPackaging" BeforeTargets="_ComputeAppxPackagePayload">
<ItemGroup>
<XamlWinmdPackagingOutput Include="@(PackagingOutputs)" Condition="'%(PackagingOutputs.Filename)%(PackagingOutputs.Extension)' == '$(XamlWinmdName)'" />
</ItemGroup>
<ItemGroup Condition="'@(XamlWinmdPackagingOutput)' != ''">
<PackagingOutputs Remove="@(XamlWinmdPackagingOutput)" />
</ItemGroup>
<ItemGroup>
<PackagingOutputs Include="@(XamlWinmd)" />
</ItemGroup>
</Target>
<Target Name="_RemoveXamlWinmdFromWinMetadataFolder" AfterTargets="BuildNativePackage" BeforeTargets="_AddXamlWinmdToPackageLayoutRoot">
<ItemGroup>
<XamlWinmdAppxPackagePayload Include="@(AppxPackagePayload)" Condition="'%(AppxPackagePayload.TargetPath)' == '$(WinMetadataDir)\$(XamlWinmdName)'" />
<XamlWinmdAppxUploadPackagePayload Include="@(AppxUploadPackagePayload)" Condition="'%(AppxUploadPackagePayload.TargetPath)' == '$(WinMetadataDir)\$(XamlWinmdName)'" />
</ItemGroup>
<ItemGroup Condition="'@(XamlWinmdAppxPackagePayload)' != ''">
<AppxPackagePayload Remove="@(XamlWinmdAppxPackagePayload)" />
</ItemGroup>
<ItemGroup Condition="'@(XamlWinmdAppxUploadPackagePayload)' != ''">
<AppxUploadPackagePayload Remove="@(XamlWinmdAppxUploadPackagePayload)" />
</ItemGroup>
</Target>
<Target Name="_AddXamlWinmdToPackageLayoutRoot" AfterTargets="BuildNativePackage">
<ItemGroup>
<AppxPackagePayload Include="@(XamlWinmd)">
<TargetPath>Microsoft.UI.Xaml.winmd</TargetPath>
</AppxPackagePayload>
<AppxUploadPackagePayload Include="@(XamlWinmd)">
<TargetPath>Microsoft.UI.Xaml.winmd</TargetPath>
</AppxUploadPackagePayload>
</ItemGroup>
<Copy SourceFiles="@(XamlWinmd)" DestinationFiles="@(XamlWinmd -> '$(OutDir)\%(Filename)%(Extension)')" />
</Target>
</Project>
And now im stack, because I don't understand how to connect CustomControls.Shared Generic.xaml project to App.xaml resources: <Application x:Class="LigricUno.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
<ResourceDictionary Source="ms-appx:///CustomControls.Shared/Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application> |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You can take an example from this: https://github.com/unoplatform/Uno.Samples/blob/master/UI/ControlLibrary/XamlControlLibrary. To add WinUI 2.x, you'll need to add a package reference explicitly in this block: https://github.com/unoplatform/Uno.Samples/blob/master/UI/ControlLibrary/XamlControlLibrary/XamlControlLibrary.csproj#L15-L17, so that the WinUI reference is only used by the UWP part of the build. The other Uno-specific targets already include references to WinUI. |
Beta Was this translation helpful? Give feedback.
-
@jeromelaban, if I understood you well I should be add next lines to the my library project: <ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform " Version="6.0.8" />
</ItemGroup> But I still does't see this lib: My full .csproj file: <Project Sdk="MSBuild.Sdk.Extras/3.0.23">
<PropertyGroup>
<TargetFrameworks>uap10.0.18362;netstandard2.0;net6.0-android</TargetFrameworks>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Uno.UI" Version="3.11.6" />
</ItemGroup>
<ItemGroup>
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>
<ItemGroup>
<None Remove="Boards\BoardStandardCustomControl.xaml" />
<None Remove="Items\ItemStandardCustomControl.xaml" />
<None Remove="Menus\MenuStandardCustomControl.xaml" />
<None Remove="Styles\Expander.xaml" />
<None Remove="Themes\Generic.xaml" />
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Remove="Boards\BoardStandardCustomControl.xaml" />
<UpToDateCheckInput Remove="Items\ItemStandardCustomControl.xaml" />
<UpToDateCheckInput Remove="Menus\MenuStandardCustomControl.xaml" />
<UpToDateCheckInput Remove="Styles\Expander.xaml" />
<UpToDateCheckInput Remove="Themes\Generic.xaml" />
</ItemGroup>
<ItemGroup>
<Page Update="BoardStandard\BoardStandardCustomControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="ItemStandard\ItemStandardCustomControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Menus\MenuStandardCustomControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Styles\Expander.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Themes\Generic.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform " Version="6.0.8" />
</ItemGroup>
</Project> |
Beta Was this translation helpful? Give feedback.
-
@jeromelaban I Added but it's didn't help me. <ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform " Version="6.0.8" />
<PackageReference Include="Microsoft.UI.Xaml" Version="2.7.0" />
</ItemGroup> |
Beta Was this translation helpful? Give feedback.
You can take an example from this: https://github.com/unoplatform/Uno.Samples/blob/master/UI/ControlLibrary/XamlControlLibrary.
To add WinUI 2.x, you'll need to add a package reference explicitly in this block: https://github.com/unoplatform/Uno.Samples/blob/master/UI/ControlLibrary/XamlControlLibrary/XamlControlLibrary.csproj#L15-L17, so that the WinUI reference is only used by the UWP part of the build. The other Uno-specific targets already include references to WinUI.