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

Generate the Windows manifests as well #2704

Merged
merged 21 commits into from
Feb 24, 2022
Merged

Generate the Windows manifests as well #2704

merged 21 commits into from
Feb 24, 2022

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Sep 27, 2021

Description of Change

Until the Windows build system supports the new One .NET properties, Resizetizer can do this to fill in the gaps.

https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetSingleProject.md

Additions made

  • Adds a new MauiGeneratePackageAppxManifest task to generate a completed manifest.
  • $(ApplicationId) must be a GUID and is used as the app id for the store. To be used in a single project, they can be conditioned:
    <ApplicationId>com.microsoft.maui.sample</ApplicationId>
    <ApplicationId Condition="$(TargetFramework.Contains('-windows'))">f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8</ApplicationId>
  • $(ApplicationDisplayVersion) and $(ApplicationVersion) are merged to form the app version. Tnis is possible because iOS/Mac Catalyst need the version to be a 3 part version number. If there are not enough parts, then zeroes (0) are used to full the gaps. Because Windows only has a single version attribute, we can just merge:
    Version="$(ApplicationDisplayVersion).$(ApplicationVersion)"
    
  • $(ApplicationTitle) is used for several names:
    • Package/installer DisplayName
    • Installed app DisplayName
    • App description (this could be later controlled with a new property - such as $(ApplicationDescription))
    • Tile ShortName (this is used when the app has a very small tile, however with Windows 11 we don't have tiles)
  • @(MauiImage) with IsAppIcon="true" is used to generate the images for the tiles, icons and logos.
  • @(MauiSplashScreen) is used to generate the splash screen (not sure where this appears)
  • Added a new @(MauiAppIcon) which is just an alias for @(MauiImage):
    <MauiImage Include="@(MauiAppIcon)" IsAppIcon="True" />

If any of these components are missing, then it is just ignored and will require the developer manually enter values in the manifest.

If there are any of these values in the manifest already, then this task will not overwrite. Native manifest always takes priority.

Example

New minimum manifest:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
         xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
         xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
         IgnorableNamespaces="uap rescap">
  <Identity Publisher="CN=.NET Foundation" />
  <Properties>
    <PublisherDisplayName>.NET Foundation</PublisherDisplayName>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
      <uap:VisualElements />
    </Application>
  </Applications>
  <Capabilities>
    <rescap:Capability Name="runFullTrust" />
  </Capabilities>
</Package>

Project Properties:

<PropertyGroup>
  <ApplicationId>com.microsoft.maui.sample</ApplicationId>
  <ApplicationId Condition="$(TargetFramework.Contains('-windows'))">f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8</ApplicationId>
  <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
  <ApplicationVersion>1</ApplicationVersion>
  <ApplicationTitle>.NET MAUI Controls</ApplicationTitle>
</PropertyGroup>

<ItemGroup>
  <MauiImage Include="Resources\AppIcons\appicon.svg" ForegroundFile="Resources\AppIcons\appicon_foreground.svg" IsAppIcon="true" />
  <MauiSplashScreen Include="Resources\Images\dotnet_bot.svg" Color="#FFFFFF" />
</ItemGroup>

Generated Manifest:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap rescap">
  <Identity Publisher="CN=.NET Foundation" Name="f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8" Version="1.0.0.1" />
  <Properties>
    <PublisherDisplayName>.NET Foundation</PublisherDisplayName>
    <DisplayName>.NET MAUI Controls</DisplayName>
    <Logo>Assets\appiconStoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
      <uap:VisualElements DisplayName=".NET MAUI Controls" Description=".NET MAUI Controls" BackgroundColor="transparent" Square150x150Logo="Assets\appiconMediumTile.png" Square44x44Logo="Assets\appiconLogo.png">
        <uap:DefaultTile Wide310x150Logo="Assets\appiconWideTile.png" Square71x71Logo="Assets\appiconSmallTile.png" Square310x310Logo="Assets\appiconLargeTile.png" ShortName=".NET MAUI Controls">
          <uap:ShowNameOnTiles>
            <uap:ShowOn Tile="square150x150Logo" />
            <uap:ShowOn Tile="wide310x150Logo" />
          </uap:ShowNameOnTiles>
        </uap:DefaultTile>
        <uap:SplashScreen Image="Assets\dotnet_botSplashScreen.png" />
      </uap:VisualElements>
    </Application>
  </Applications>
  <Capabilities>
    <rescap:Capability Name="runFullTrust" />
    <DeviceCapability Name="location" />
  </Capabilities>
</Package>

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

This is just an alias for `@(MauiImage)`: `<MauiImage Include="@(MauiAppIcon)" IsAppIcon="True" />`
@mattleibow mattleibow requested a review from Eilon as a code owner September 27, 2021 01:28
@@ -12,6 +12,8 @@
<WindowsPackageType>MSIX</WindowsPackageType>
<ApplicationTitle>.NET MAUI Controls</ApplicationTitle>
<ApplicationId>com.microsoft.maui.sample</ApplicationId>
<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">f9e4fa3e-3505-4742-9b2b-d1acdaff4ec8</ApplicationId>
Copy link
Member Author

Choose a reason for hiding this comment

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

Windows uses a GUID for this, so we unfortunately need to condition. Maybe we can have an $(ApplicationGuid)? Then we don't need this and we can potentially use that GUID in other OS. Not sure what Tizen uses? @rookiejava

@mattleibow mattleibow added the area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer label Sep 28, 2021
@mattleibow mattleibow marked this pull request as draft October 7, 2021 17:53
@mattleibow mattleibow marked this pull request as ready for review January 31, 2022 03:25
@mattleibow mattleibow requested a review from a team as a code owner January 31, 2022 03:41
@mattleibow
Copy link
Member Author

I Updated the templates to make use of this. All that was needed was 2 new properties:

<ApplicationId Condition="$(TargetFramework.Contains('-windows'))">8B51DC95-6D07-4C39-BC6C-3BFE96E8A7EA</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>

This should be a no-op on existing projects with manifests. Only the missing properties are filled in and all existing projects already have complete manifests. To make it work, all the user has to do is delete the bits in the manifest that can be generated.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

When we decide on what this does, can you send a PR to fill in what windows does in this doc here:

https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNetSingleProject.md

(or we could consider moving this doc to the MAUI repo) I didn't want to put it in dotnet/designs and go through review there.

Eilon
Eilon previously requested changes Feb 23, 2022
Copy link
Member

@Eilon Eilon left a comment

Choose a reason for hiding this comment

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

See comment about GUID. Maybe one was missed from template.json

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Latest changes look OK to me. 👍

@Redth Redth merged commit bdae729 into main Feb 24, 2022
@Redth Redth deleted the dev/win-manifest branch February 24, 2022 22:05
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2023
@samhouts samhouts added the fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-single-project Splash Screen, Multi-Targeting, MauiFont, MauiImage, MauiAsset, Resizetizer fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! platform/windows 🪟
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants