Match in-tree order of targets with workloads and fix some WinUI issues#5923
Match in-tree order of targets with workloads and fix some WinUI issues#5923mattleibow merged 9 commits intomainfrom
Conversation
| <ItemDefinitionGroup> | ||
| <MauiXaml> | ||
| <SubType>Designer</SubType> | ||
| </MauiXaml> | ||
| </ItemDefinitionGroup> | ||
|
|
||
| <ItemGroup Condition="'$(EnableDefaultItems)'=='True' And '$(EnableDefaultXamlItems)'=='True' And '$(EnableDefaultEmbeddedResourceItems)'=='True'"> | ||
| <MauiXaml Include="**\*.xaml" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)"/> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="'$(EnableDefaultItems)'=='True' And '$(EnableDefaultCssItems)'=='True' And '$(EnableDefaultEmbeddedResourceItems)'=='True'"> | ||
| <MauiCss Include="**\*.css" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder);$(DefaultWebContentItemExcludes)" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
Moved this in from DefaultItems.props as that was just a file in the maui repo and was confusing. Also, this chunk of stuff is in the AutoImport.props that the workload uses. This way it is all matching.
| <PropertyGroup Condition=" '$(SingleProject)' == 'true' and '$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework)))' == 'windows' "> | ||
| <OutputType Condition="'$(OutputType)' == 'Exe'">WinExe</OutputType> | ||
| <EnablePreviewMsixTooling Condition="'$(EnablePreviewMsixTooling)' == '' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</EnablePreviewMsixTooling> | ||
| <WindowsPackageType Condition=" '$(WindowsPackageType)' == '' and '$(EnablePreviewMsixTooling)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe') ">MSIX</WindowsPackageType> |
There was a problem hiding this comment.
This needs to be here to come before the nugets. Fixes a bug in #5896
| <Target Name="_MauiRemoveRemoveAppxManifestForUnpackaged" | ||
| Condition="'$(WindowsPackageType)' == 'None' and '@(AppxManifest)' != ''"> | ||
|
|
||
| <ItemGroup> | ||
| <AppxManifest Remove="@(AppxManifest)" /> | ||
| </ItemGroup> | ||
|
|
||
| </Target> |
There was a problem hiding this comment.
The issue that #5896 fixes is when the manifest AND unpackaged is specified. That PR tried to fix it by not including the manifest, however, this is wrong because the way the PR did it was to check after the nuget had already defaulted to None and thus never included it.
Technically, this is actually an invalid state with unpackaged AND a manifest, however since we auto-include we also need to un-include. And secondly, what if this is a multi-mode project? Instead of requiring the user to do weird conditions, just not exclude it for the user.
| <Import Project="..\..\..\Maui.InTree.targets" /> | ||
| <Import Project="$(MauiNuSpecDirectory)Microsoft.Maui.TestUtils.DeviceTests.Runners.targets" /> | ||
| <Import Project="..\..\..\..\Directory.Build.targets" /> | ||
| <Import Project="$(MauiSrcDirectory)Maui.InTree.targets" Condition=" '$(UseMaui)' != 'true' " /> | ||
| <Import Project="$(_MauiBuildTasksLocation)Microsoft.Maui.TestUtils.DeviceTests.Runners.targets" /> | ||
| <Import Project="$(MauiRootDirectory)Directory.Build.targets" /> |
There was a problem hiding this comment.
A big chunk of removing the ../ as this is terribly confusing.
| <Compile Include="Properties\MapsKey.cs" Condition="Exists('Properties\MapsKey.cs')" /> | ||
| </ItemGroup> | ||
|
|
||
| <Import Project="$(MauiSrcDirectory)Maui.InTree.props" Condition=" '$(UseMaui)' != 'true' " /> |
There was a problem hiding this comment.
All projects that need maui things, like xaml compilation, need to add Maui.InTree.props to the bottom of the .csproj in order to set values that are used by the nugets being imported.
| <Import Project="$(MauiSrcDirectory)Maui.InTree.targets" Condition=" '$(UseMaui)' != 'true' " /> | ||
| <Import Project="$(MauiRootDirectory)Directory.Build.targets" /> |
There was a problem hiding this comment.
Add the Maui.InTree.targets riiiight at the end of the list, but before the parent Directory.Build.targets. The only way to do this is to include the Maui.InTree.targets in a local Directory.Build.targets, and then include the parent afterwards.
| <AppxManifest | ||
| Include="$(PackageManifest)" | ||
| Condition="'$(WindowsPackageType)' != 'None' and Exists('$(PackageManifest)')" /> | ||
| Condition="Exists('$(PackageManifest)')" /> |
There was a problem hiding this comment.
The other half of the fix in #5896 that ran before the .csproj or nugets. This means the only way to set this was via Directory.Build.props or via the CLI - which is not a valid requirement.
| <OutputType Condition="'$(OutputType)' == 'Exe'">WinExe</OutputType> | ||
| <EnablePreviewMsixTooling Condition="'$(EnablePreviewMsixTooling)' == '' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</EnablePreviewMsixTooling> | ||
| <WindowsPackageType Condition=" '$(WindowsPackageType)' == '' and '$(EnablePreviewMsixTooling)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe') ">MSIX</WindowsPackageType> | ||
| <WinUISDKReferences Condition=" '$(WinUISDKReferences)' == '' and '$(EnablePreviewMsixTooling)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe') ">false</WinUISDKReferences> |
There was a problem hiding this comment.
Now that we have the order correct, we can also properly exclude the SDKReferences items because they are not something WinUI actually needs. This is a UWP thing. This fixes #5881
|
Works on my machine! I first built main, which failed with the gosh darn missing appxrecipe. I switched to the PR branch and it works! |
|
I am trying to publish my first MAUI app and am getting this error.. According to these posts the issue was resolved. I created the project on September 5th on a brand new VS2022 installation. |
|
Hi @solomonfried , can you please file a new issue with detailed steps to reproduce? |
I have created an issue Thanks |
|
As soon as I add |
|
@McoreD what's the error? Do you have spaces in your user profile? |
Description of Change
The order of the props/targets in the maui repo solution don't quite match the order of the targets once the workload is installed.
This PR Fixes some things:
Details
Also fixes some poor choices in #5896
And Fixes #5881 properly
This PR tries to get even closer to this. Not an exact match as there is no way to get the AutoImport.props in the right place, but it can be simulated by adding it to the end of the .csproj. And then we can use the Directory.Build.targets to simulate after all the things are ready.
It still does not quite match, but here is the orders of things: