Skip to content

Commit

Permalink
Centralize relationship of UseMaui* MSBuild properties
Browse files Browse the repository at this point in the history
When the UseMaui MSBuild property is true this implies UseMauiAssets and
UseMauiCore are also true, and UseMauiCore implies UseMauiEssentials.
Codify this relationship explicitly in the workload targets so
conditions elsewhere in the targets only have to check one of these
properties rather than implicitly redefining this relationship.

Note that UseMauiEssentials currently causes all of the controls build
targets to be imported as they do some generic stuff (e.g. SingleProject).
Ideally these would be separated out so they could be imported independently.
  • Loading branch information
mhutch committed Jul 8, 2021
1 parent f11994c commit f82db03
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<_MauiRuntimeIdentifiers Include="android;ios;maccatalyst;win" />
<KnownFrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' "
Condition="'$(UseMauiCore)' == 'true'"
Include="Microsoft.Maui.Extensions"
TargetFramework="net6.0"
RuntimeFrameworkName="Microsoft.Maui.Extensions"
Expand All @@ -22,7 +22,7 @@
RuntimePackRuntimeIdentifiers="any"
/>
<KnownFrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' "
Condition="'$(UseMauiCore)' == 'true'"
Include="Microsoft.Maui.Core"
TargetFramework="net6.0"
RuntimeFrameworkName="Microsoft.Maui.Core"
Expand All @@ -35,7 +35,7 @@
Profile="$(TargetPlatformIdentifier)"
/>
<KnownFrameworkReference
Condition=" '$(UseMaui)' == 'true' "
Condition="'$(_UseMauiControls)' == 'true'"
Include="Microsoft.Maui.Controls"
TargetFramework="net6.0"
RuntimeFrameworkName="Microsoft.Maui.Controls"
Expand All @@ -48,7 +48,7 @@
Profile="$(TargetPlatformIdentifier)"
/>
<KnownFrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiEssentials)' == 'true' "
Condition="'$(UseMauiEssentials)' == 'true'"
Include="Microsoft.Maui.Essentials"
TargetFramework="net6.0"
RuntimeFrameworkName="Microsoft.Maui.Essentials"
Expand All @@ -63,10 +63,10 @@
</ItemGroup>

<!-- These implicit <PackageReference/> pull dependencies from NuGet transitively -->
<ItemGroup Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' or '$(UseMauiEssentials)' == 'true' ">
<ItemGroup Condition="'$(UseMauiEssentials)' == 'true' ">
<PackageReference Include="Microsoft.Maui.Dependencies" Version="$(MicrosoftMauiSdkVersion)" IsImplicitlyDefined="true" />
</ItemGroup>
<ItemGroup Condition=" '$(UseMaui)' == 'true' and '$(UsingMicrosoftNETSdkRazor)' == 'true' ">
<ItemGroup Condition="'$(_UseMauiControls)' == 'true' and '$(UsingMicrosoftNETSdkRazor)' == 'true'">
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MicrosoftMauiSdkVersion)" IsImplicitlyDefined="true" />
</ItemGroup>

Expand Down
19 changes: 14 additions & 5 deletions src/Workload/Microsoft.Maui.Controls.Sdk/Sdk/Sdk.targets
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
<Project>
<PropertyGroup>
<!-- allow more explicit intent on conditions that bring in controls -->
<_UseMauiControls Condition="'$(UseMaui)'=='true'">true</_UseMauiControls>
</PropertyGroup>

<ItemGroup Condition=" '$(DisableImplicitFrameworkReferences)' != 'true' ">
<FrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' "
Condition="'$(UseMauiCore)' == 'true'"
Include="Microsoft.Maui.Extensions"
IsImplicitlyDefined="true"
Pack="false"
PrivateAssets="All"
/>
<FrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' "
Condition="'$(UseMauiCore)' == 'true'"
Include="Microsoft.Maui.Core"
IsImplicitlyDefined="true"
Pack="false"
PrivateAssets="All"
/>
<FrameworkReference
Condition=" '$(UseMaui)' == 'true' "
Condition="'$(_UseMauiControls)' == 'true'"
Include="Microsoft.Maui.Controls"
IsImplicitlyDefined="true"
Pack="false"
PrivateAssets="All"
/>
<FrameworkReference
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiEssentials)' == 'true' "
Condition="'$(UseMauiEssentials)' == 'true'"
Include="Microsoft.Maui.Essentials"
IsImplicitlyDefined="true"
Pack="false"
Expand All @@ -32,6 +36,11 @@
</ItemGroup>

<Import Project="../targets/BundledVersions.targets" />
<Import Project="Microsoft.Maui.Controls.Sdk.targets" Condition=" '$(UseMaui)' == 'true' " />
<!--
these targets currently bring in a mixture of controls logic (xamlc, default xaml items etc) and generic logic (singleproject)
they should really be split up and conditioned separately so projects can get singleproject logic without all the controls stuff.
perhaps singleproject should be a UseSingleProject that works by itself?
-->
<Import Project="Microsoft.Maui.Controls.Sdk.targets" Condition="'$(UseMauiEssentials)' == 'true'" />

This comment has been minimized.

Copy link
@jonathanpeppers

jonathanpeppers Jul 9, 2021

Member

I do think the targets need to be split up. $(UseMauiEssentials) doesn't really use any MSBuild targets, so maybe you have to put $(UseMaui) here until they are split up?

So far I took the approach of taking what they had and got it to the point it works...

This comment has been minimized.

Copy link
@mhutch

mhutch Aug 3, 2021

Author Member

There are a few things in those targets that need to be available when UseMauiEssentials is true e.g. ProjectCapability items and some property values IIRC.


</Project>
10 changes: 8 additions & 2 deletions src/Workload/Microsoft.NET.Sdk.Maui/WorkloadManifest.targets
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<Project>
<PropertyGroup>
<!-- UseMaui implies UseMauiAssets and UseMauiCore, and UseMauiCore implies UseMauiEssentials. -->
<UseMauiCore Condition="'$(UseMaui)'=='true'">true</UseMauiCore>
<UseMauiAssets Condition="'$(UseMaui)'=='true'">true</UseMauiAssets>
<UseMauiEssentials Condition="'$(UseMauiCore)'=='true'">true</UseMauiEssentials>
</PropertyGroup>
<Import
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiCore)' == 'true' or '$(UseMauiEssentials)' == 'true' "
Condition="'$(UseMauiEssentials)' == 'true'"
Project="Sdk.targets" Sdk="Microsoft.Maui.Controls.Sdk"
/>
<Import
Condition=" '$(UseMaui)' == 'true' or '$(UseMauiAssets)' == 'true' "
Condition="'$(UseMauiAssets)' == 'true'"
Project="Sdk.targets" Sdk="Microsoft.Maui.Resizetizer.Sdk"
/>
</Project>

0 comments on commit f82db03

Please sign in to comment.