Skip to content

Commit

Permalink
build: Refactor how pages are included
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Jan 17, 2023
1 parent 6cf8e3b commit 6114d93
Show file tree
Hide file tree
Showing 28 changed files with 54 additions and 252 deletions.
6 changes: 1 addition & 5 deletions src/Common_ViewLibraryProps/Globbing.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<Project ToolsVersion="Current">
<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>
</Project>
</Project>
4 changes: 4 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<NoWarn>$(NoWarn);MSB4011</NoWarn> <!-- Disable duplicate msbuild files imports message -->
<NoWarn>$(NoWarn);NU1505</NoWarn> <!-- Disable: Duplicate 'PackageDownload' items found. Remove the duplicate items or use the Update functionality to ensure a consistent restore behavior. The duplicate 'PackageDownload' items are: Microsoft.NETCore.App.Host.win-x64 [3.1.25], Microsoft.NETCore.App.Host.win-x64 [3.1.25], Microsoft.NETCore.App.Host.win-x64 [3.1.25], Microsoft.NETCore.App.Host.win-x64 [3.1.25]. -->

<EnableAutomaticXamlPageInclusion>true</EnableAutomaticXamlPageInclusion>

<DebugType>portable</DebugType>
<DebugSymbols>True</DebugSymbols>
<RepositoryUrl>$(BUILD_REPOSITORY_URI)</RepositoryUrl>
Expand Down Expand Up @@ -58,6 +60,8 @@

<!-- Enable ShouldWriteErrorOnInvalidXaml for all the sample and test projects of this solution -->
<ShouldWriteErrorOnInvalidXaml>True</ShouldWriteErrorOnInvalidXaml>

<ExtrasEnableDefaultPageItems>false</ExtrasEnableDefaultPageItems>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<Product>$(AssemblyName) ($(TargetFramework) $(UnoRuntimeIdentifier))</Product>
</PropertyGroup>

<ItemGroup Condition="$(EnableAutomaticXamlPageInclusion)">
<Page Include="**\*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(PageExclusions)" />
</ItemGroup>

<!--
Comment out this section if you need to update Resource.designer.cs files.
See DEVELOPMENT.md#Android for details.
Expand Down
5 changes: 0 additions & 5 deletions src/PlatformItemGroups.props
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@
<Compile Include="**\*.net.cs"
Exclude="bin\**\*.net.cs;obj\**\*.net.cs"
Condition="'$(TargetFramework)'=='net461'" />

<Page Include="**\*.xaml"
Exclude="bin/**/*.xaml;obj/**/*.xaml"
Condition="$(IsAndroid) or $(IsIOSOrCatalyst) or $(_IsUWP) or $(_IsNetStd) or $(IsMacOS)" />

</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions src/SamplesApp/UITests.Shared/ItemExclusions.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<ItemGroup Condition="'$(UNO_UWP_BUILD)'!='true'">
<Page Remove="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
<Compile Remove="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
<None Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**" />
</ItemGroup>

<PropertyGroup Condition="'$(UNO_UWP_BUILD)'!='true'">
<PageExclusions>$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\MapPresenter\**</PageExclusions>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
</PropertyGroup>

<ItemGroup Label="GlobalUsings">
Expand Down Expand Up @@ -53,7 +54,6 @@

<ItemGroup>
<Compile Remove="MetadataUpdateTests\Scenarios\**" />
<Page Remove="MetadataUpdateTests\Scenarios\**" />
<Content Include="MetadataUpdateTests\Scenarios\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<PackageReference Include="Xamarin.AndroidX.RecyclerView" />
</ItemGroup>

<ItemGroup>
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>

<ItemGroup>
<PRIResource Include="Resources.resw" />
</ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/Uno.CrossTargetting.props
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@
<GenerateLibraryLayout>true</GenerateLibraryLayout>
</PropertyGroup>

<ItemGroup Condition=" ($(IsAndroid) or $(IsIOS)) and '$(ExtrasIsReferenceAssembly)'!='' ">
<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>

<Target Name="GetBuiltProjectOutputRecursive" Condition=" '$(TargetFramework)' == 'xamarinios10' " />

<Target Name="_DisplayTargets" BeforeTargets="BeforeBuild">
Expand Down
32 changes: 5 additions & 27 deletions src/Uno.UI.FluentTheme.v1/FluentMerge.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<ThemesExclusion>$(MSBuildThisFileDirectory)Resources\**\*.xaml</ThemesExclusion>
<PageExclusions>$(MSBuildThisFileDirectory)Resources\**\*.xaml</PageExclusions>
</PropertyGroup>

<UsingTask TaskName="BatchMergeXaml" AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll" />

<!-- This task is temporarily placed in debug configuration to avoid parallel build concurrency issues -->
Expand Down Expand Up @@ -35,31 +35,9 @@
<Message Text="Theme resources XAML file was generated" />
</Target>

<Choose>
<When Condition="'$(TargetFramework)'=='net461'">
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</When>
<When Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />

<!-- Remove all xaml files as netstandard2.0 is the reference target and won't be used at runtime -->
<Page Remove="@(Page)" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />

<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</Otherwise>
</Choose>

<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
</PropertyGroup>

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
Expand Down
32 changes: 5 additions & 27 deletions src/Uno.UI.FluentTheme.v2/FluentMerge.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<ThemesExclusion>$(MSBuildThisFileDirectory)Resources\**\*.xaml</ThemesExclusion>
<PageExclusions>$(MSBuildThisFileDirectory)Resources\**\*.xaml</PageExclusions>
</PropertyGroup>

<UsingTask TaskName="BatchMergeXaml" AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll" />

<!-- This task is temporarily placed in debug configuration to avoid parallel build concurrency issues -->
Expand Down Expand Up @@ -34,31 +34,9 @@
<Message Text="Theme resources XAML file was generated" />
</Target>

<Choose>
<When Condition="'$(TargetFramework)'=='net461'">
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</When>
<When Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />

<!-- Remove all xaml files as netstandard2.0 is the reference target and won't be used at runtime -->
<Page Remove="@(Page)" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />

<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</Otherwise>
</Choose>

<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
</PropertyGroup>

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
Expand Down
32 changes: 5 additions & 27 deletions src/Uno.UI.FluentTheme/FluentMerge.targets
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<ThemesExclusion>$(MSBuildThisFileDirectory)Resources\**\*.xaml</ThemesExclusion>
<PageExclusions>$(MSBuildThisFileDirectory)Resources\**\*.xaml</PageExclusions>
</PropertyGroup>

<UsingTask TaskName="BatchMergeXaml" AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll" />


<Choose>
<When Condition="'$(TargetFramework)'=='net461'">
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</When>
<When Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />

<!-- Remove all xaml files as netstandard2.0 is the reference target and won't be used at runtime -->
<Page Remove="@(Page)" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
<UsingTask TaskName="BatchMergeXaml" AssemblyFile="$(UnoUIMSBuildTasksPath)\Uno.UI.Tasks.v0.dll" />

<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="$(MSBuildThisFileDirectory)**/*.xaml" Exclude="bin/**/*.xaml;obj/**/*.xaml;$(ThemesExclusion)" />
</ItemGroup>
</Otherwise>
</Choose>

<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0' and '$(UnoRuntimeIdentifier)'=='Reference'">
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
</PropertyGroup>

<PropertyGroup>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
Expand Down
5 changes: 4 additions & 1 deletion src/Uno.UI.Maps/Uno.UI.Maps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@

<ItemGroup Condition="'$(UNO_UWP_BUILD)'!='true'">
<!-- Maps are not yet supported by WinUI 3.0 -->
<Page Remove="**\*.xaml" />
<Compile Remove="**\*.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(UNO_UWP_BUILD)'!='true'">
<!-- Maps are not yet supported by WinUI 3.0 -->
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
</PropertyGroup>

</Project>
8 changes: 0 additions & 8 deletions src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.Skia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@
<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
<Import Project="..\Uno.CrossTargetting.props" />

<ItemGroup>
<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="$(PlatformItemsBasePath)**/*.xaml" Exclude="$(PlatformItemsBasePath)bin/**/*.xaml;$(PlatformItemsBasePath)obj/**/*.xaml" />

<UpToDateCheckInput Include="$(PlatformItemsBasePath)**\*.xaml" Exclude="$(PlatformItemsBasePath)bin\**\*.xaml;$(PlatformItemsBasePath)obj\**\*.xaml" />
</ItemGroup>

<ItemGroup>
<PRIResource Include="Resources\**\*.resw" />
</ItemGroup>
Expand Down
8 changes: 0 additions & 8 deletions src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,4 @@
<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />

<Import Project="..\Uno.CrossTargetting.props" />

<ItemGroup>
<!-- remove files included by msbuild extras -->
<Page Remove="@(Page)" />
<Page Include="$(PlatformItemsBasePath)**/*.xaml" Exclude="$(PlatformItemsBasePath)bin/**/*.xaml;$(PlatformItemsBasePath)obj/**/*.xaml" />

<UpToDateCheckInput Include="$(PlatformItemsBasePath)**\*.xaml" Exclude="$(PlatformItemsBasePath)bin\**\*.xaml;$(PlatformItemsBasePath)obj\**\*.xaml" />
</ItemGroup>
</Project>
12 changes: 3 additions & 9 deletions src/Uno.UI.RuntimeTests/Uno.UI.RuntimeTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,9 @@

<Import Project="..\Uno.CrossTargetting.props" />

<ItemGroup>
<!-- Remove already included XAML -->
<Page Remove="@(Page)" />
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
<UpToDateCheckInput Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='uap10.0.18362'">
<Page Remove="$(MSBuildThisFileDirectory)MUX\Microsoft_UI_XAML_Controls\**\*.xaml" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='uap10.0.18362'">
<PageExclusions>$(MSBuildThisFileDirectory)MUX\Microsoft_UI_XAML_Controls\**\*.xaml</PageExclusions>
</PropertyGroup>

<ItemGroup>
<PRIResource Include="Resources\**\*.resw" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
<Import Project="..\Uno.CrossTargetting.props" />

<ItemGroup>
<!-- Remove already included XAML -->
<Page Remove="@(Page)" />
<Page Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />
<UpToDateCheckInput Include="**\*.xaml" Exclude="bin\**\*.xaml;obj\**\*.xaml" />

<Content Include="Assets\**" />
</ItemGroup>

Expand Down
5 changes: 0 additions & 5 deletions src/Uno.UI.Tests.ViewLibrary/Uno.UI.Tests.ViewLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@

<Target Name="BeforeBuildCleanup" BeforeTargets="XamlMarkupCompilePass1;_UnoSourceGenerator" />

<ItemGroup>
<Page Remove="@(Page)" />
<Page Include="Themes\**\*.xaml" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SourceGenerators\System.Xaml\Uno.Xaml.csproj" />
<ProjectReference Include="..\Uno.UI\Uno.UI.csproj" />
Expand Down
17 changes: 2 additions & 15 deletions src/Uno.UI.Tests/Uno.UI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@
<EmbeddedResource Include="$(MSBuildThisFileDirectory)..\Uno.Net.Shared\Resources\**\*.resx">
<Link>Resources\%(RecursiveDir)%(FileName)%(Extension)</Link>
</EmbeddedResource>

<!-- This has to be after all the shared projects imports -->
<Page Remove="@(Page)" />
</ItemGroup>

<PropertyGroup>
<EnableAutomaticXamlPageInclusion>false</EnableAutomaticXamlPageInclusion>
<UnoUIMSBuildTasksPath>$(MSBuildThisFileDirectory)..\SourceGenerators\Uno.UI.Tasks\bin\$(Configuration)_Shadow</UnoUIMSBuildTasksPath>
<UnoForceProcessPRIResource>true</UnoForceProcessPRIResource>
</PropertyGroup>
Expand All @@ -93,18 +91,7 @@
<ItemGroup>
<PRIResource Include="**\*.resw" />
</ItemGroup>
<ItemGroup>
<Page Include="Windows_UI_Xaml\**\*.xaml" />
<Page Include="Windows_UI_Xaml_Data\**\*.xaml" />
<Page Include="Windows_UI_Xaml_Controls\**\*.xaml" />
<Page Include="ResourceLoader\Controls\**\*.xaml" />
<Page Include="Windows_UI_Xaml_Markup\**\*.xaml" />
<Page Include="HotReload\Windows_UI_Xaml\**\*.xaml" />
<Page Include="App\**\*.xaml" />
<None Remove="Lottie\animation.json" />
<None Remove="Windows_UI_Xaml_Markup\XamlReaderTests\When_CustomResource.xamltest" />
<Page Include="..\SamplesApp\UITests.Shared\Windows_UI_Xaml\Resources\Test_Dictionary_Linked.xaml" Link="App/Linked/Test_Dictionary_Linked.xaml" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\Uno.UI.RuntimeTests\Helpers\SizeAssertion.cs" Link="Extensions\SizeAssertion.cs" />
<Compile Include="..\Uno.UI.RuntimeTests\Tests\Windows_UI_Xaml_Controls\Given_ListViewBase_Items.cs" Link="Windows_UI_XAML_Controls\ListViewBaseTests\Given_ListViewBase_Items.cs" />
Expand Down
5 changes: 0 additions & 5 deletions src/Uno.UI.Toolkit/Uno.UI.Toolkit.Reference.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Page Remove="Themes\Generic.xaml" />
<Page Include="Themes\Generic.xaml" />
</ItemGroup>

<Import Project="..\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props" />

<Target Name="_UnoToolkitOverrideNuget" AfterTargets="AfterBuild" DependsOnTargets="BuiltProjectOutputGroup" Condition="'$(UnoNugetOverrideVersion)'!=''">
Expand Down
5 changes: 0 additions & 5 deletions src/Uno.UI.Toolkit/Uno.UI.Toolkit.Skia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Page Remove="Themes\Generic.xaml" />
<Page Include="Themes\Generic.xaml" />
</ItemGroup>

<!-- Override existing target, this project cannot be published -->
<Target Name="Publish" />

Expand Down
5 changes: 0 additions & 5 deletions src/Uno.UI.Toolkit/Uno.UI.Toolkit.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
</ProjectReference>
</ItemGroup>

<ItemGroup>
<Page Remove="Themes\Generic.xaml" />
<Page Include="Themes\Generic.xaml" />
</ItemGroup>

<!-- Override existing target, this project cannot be published -->
<Target Name="Publish" />

Expand Down
Loading

0 comments on commit 6114d93

Please sign in to comment.