Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move some of the require props into Core and fix #6529 #6767

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .nuspec/Microsoft.Maui.Controls.SingleProject.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

<PropertyGroup Condition=" '$(SingleProject)' == 'true' and '$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework)))' == 'windows' ">
<OutputType Condition="'$(OutputType)' == 'Exe'">WinExe</OutputType>
<EnableMsixTooling Condition="'$(EnableMsixTooling)' == ''">true</EnableMsixTooling>
<EnablePreviewMsixTooling Condition="'$(EnablePreviewMsixTooling)' == ''">$(EnableMsixTooling)</EnablePreviewMsixTooling>
<WindowsPackageType Condition=" '$(WindowsPackageType)' == '' and '$(EnableMsixTooling)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe') ">MSIX</WindowsPackageType>
<WinUISDKReferences Condition=" '$(WinUISDKReferences)' == '' and '$(EnableMsixTooling)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe') ">false</WinUISDKReferences>
<GenerateLibraryLayout Condition=" '$(GenerateLibraryLayout)' == '' and '$(EnableMsixTooling)' == 'true' and '$(OutputType)' != 'Exe' and '$(OutputType)' != 'WinExe' ">true</GenerateLibraryLayout>
<WindowsAppSdkBootstrapInitialize Condition=" '$(WindowsAppSdkBootstrapInitialize)' == '' and '$(EnableMsixTooling)' == 'true' and '$(OutputType)' != 'Exe' and '$(OutputType)' != 'WinExe' ">false</WindowsAppSdkBootstrapInitialize>
Copy link
Member Author

@mattleibow mattleibow May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might also need to be moved as a result of microsoft/WindowsAppSDK#2456 - along with WindowsPackageType

<PublishAppXPackage Condition=" '$(PublishAppXPackage)' == '' and '$(EnableMsixTooling)' == 'true' and '$(WindowsPackageType)' == 'MSIX' ">true</PublishAppXPackage>
<_SingleProjectRIDRequired Condition="'$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe'">true</_SingleProjectRIDRequired>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
<MSBuildWarningsAsMessages Condition=" '$(TargetPlatformIdentifier)' == 'Android' ">$(MSBuildWarningsAsMessages);XA4218</MSBuildWarningsAsMessages>
</PropertyGroup>

<Import Project="WinUI.targets" Condition=" '$(TargetPlatformIdentifier)' == 'windows' " />
<!--
This double check seems excessive, but importing the WinUI.targets when building for windows is not
sufficient. The WASDK targets assume everything is WinUI and thus just passes along the TFM of the app.
As a result, if you have a net6.0 class library, the app will call MSBuild on that library - with the Windows TFM!
This results in the $(TargetPlatformIdentifier) condition being met - even though there are no WASK targets to run!
-->
<Import Project="WinUI.targets" Condition=" '$(TargetPlatformIdentifier)' == 'windows' and '$(WindowsAppSDKWinUI)' == 'true'" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that when this target is imported it is BOTH a windows project AND it is referencing the WASDK nuget. If MSBuild is run with a TargetFramework of windows, the first condition will become true, but the second one will not because the real project will not have referenced the WASDK nuget.

And this is fine because all the targets in the WinUI.targets are workarounds for windows AND WASDK nuget together.


</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<UsingMicrosoftMauiCoreSdk>true</UsingMicrosoftMauiCoreSdk>
</PropertyGroup>

<!-- Set some property defaults that MAUI requires - especially for dotnet build to work -->
<PropertyGroup Condition=" '$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework)))' == 'windows' ">
<EnableMsixTooling Condition=" '$(EnableMsixTooling)' == '' ">true</EnableMsixTooling>
<EnablePreviewMsixTooling Condition=" '$(EnablePreviewMsixTooling)' == '' ">$(EnableMsixTooling)</EnablePreviewMsixTooling>
<GenerateLibraryLayout Condition=" '$(GenerateLibraryLayout)' == '' and '$(EnableMsixTooling)' == 'true' and '$(OutputType)' != 'Exe' and '$(OutputType)' != 'WinExe' ">true</GenerateLibraryLayout>
<WinUISDKReferences Condition=" '$(WinUISDKReferences)' == '' and '$(EnableMsixTooling)' == 'true' ">false</WinUISDKReferences>
</PropertyGroup>
Comment on lines +8 to +13
Copy link
Member Author

@mattleibow mattleibow May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these properties to here to reduce the required properties in class libraries that use maui but do not set single project and target windows:

  • we mainly require EnableMsixTooling for dotnet build, but it also fixes some bugs
  • GenerateLibraryLayout is required for all libraries... not sure why it is not set
  • WinUISDKReferences is a compatibility feature and should be avoided in new projects


<!-- Imported last -->
<PropertyGroup>
<AfterMicrosoftNETSdkTargets>$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)Microsoft.Maui.Core.Sdk.After.targets</AfterMicrosoftNETSdkTargets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@

</Target>

<Target Name="GetPriOutputs"
<Target Name="GetPriOutputs"
Condition="'$(AppxGeneratePriEnabled)'=='true'"
Returns="@(PriOutputs);@(ProjectPriFile)"
DependsOnTargets="$(GetPriOutputsDependsOn)">
Expand Down