Skip to content

Update Maui version flows #4321

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

Merged
merged 14 commits into from
Aug 1, 2024
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
15 changes: 9 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ jobs:
kind: maui_scenarios_android
projectFile: maui_scenarios_android.proj
dotnetVersionsLinks:
9.0: https://maui.blob.core.windows.net/metadata/sdks/net9.0.json
8.0: https://aka.ms/dotnet/sdk/maui/net8.0.json
9.0: ./eng/Version.Details.xml
channels:
- 8.0

# Maui iOS Mono scenario benchmarks
- template: /eng/performance/build_machine_matrix.yml
Expand All @@ -396,8 +397,9 @@ jobs:
kind: maui_scenarios_ios
projectFile: maui_scenarios_ios.proj
dotnetVersionsLinks:
9.0: https://maui.blob.core.windows.net/metadata/sdks/net9.0.json
8.0: https://aka.ms/dotnet/sdk/maui/net8.0.json
9.0: ./eng/Version.Details.xml
channels:
- 8.0
runtimeFlavor: mono

# Maui iOS Native AOT scenario benchmarks
Expand All @@ -411,8 +413,9 @@ jobs:
kind: maui_scenarios_ios
projectFile: maui_scenarios_ios.proj
dotnetVersionsLinks:
9.0: https://maui.blob.core.windows.net/metadata/sdks/net9.0.json
8.0: https://aka.ms/dotnet/sdk/maui/net8.0.json
9.0: ./eng/Version.Details.xml
channels:
- 8.0
runtimeFlavor: coreclr

## Maui scenario benchmarks
Expand Down
48 changes: 48 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,53 @@
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>731d793be2d0a66bafc96b1a79dc96b4d1f0301b</Sha>
</Dependency>
<!--
Maui Rollback Version mappings, default means generated from sdk version. Allows for manual override of version similar to https://github.com/dotnet/maui/blob/df8cfcf635a590955a8cc3d6cf7ae6280449dd3f/eng/Versions.props#L138-L146, where the logic comes from:
Mapping_Microsoft.Maui.Controls:default
Mapping_Microsoft.NETCore.App.Ref:default
Mapping_Microsoft.NET.Workload.Emscripten.Current:default
Mapping_Microsoft.Android.Sdk:default
Mapping_Microsoft.MacCatalyst.Sdk:9.0.100-preview.6
Mapping_Microsoft.macOS.Sdk:9.0.100-preview.6
Mapping_Microsoft.iOS.Sdk:9.0.100-preview.6
Mapping_Microsoft.tvOS.Sdk:9.0.100-preview.6
-->
<!-- Dependencies for .NET MAUI workload -->
<Dependency Name="Microsoft.Maui.Controls" Version="9.0.0-preview.7.24368.8">
<Sha>cf76a629023c99557239464a278daec280d1f448</Sha>
<Uri>https://github.com/dotnet/maui</Uri>
</Dependency>
<Dependency Name="VS.Tools.Net.Core.SDK.Resolver" Version="9.0.100-preview.7.24360.5" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>9a028e12b90e6a583b09ccb3008fdfaf85761f19</Sha>
<Uri>https://github.com/dotnet/sdk</Uri>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="9.0.0-preview.7.24357.2" CoherentParentDependency="VS.Tools.Net.Core.SDK.Resolver">
<Sha>4e278fe17f69ea31fbdcbab74ac47ec6fa84914b</Sha>
<Uri>https://github.com/dotnet/runtime</Uri>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Current.Manifest-9.0.100.Transport" Version="9.0.0-preview.7.24319.4" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Sha>ffe9afdc046cf7a6f82cc7c5796aade54047af64</Sha>
<Uri>https://github.com/dotnet/emsdk</Uri>
</Dependency>
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="34.99.0-preview.7.346" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>06bb1dc6a292ef5618a3bb6ecca3ca869253ff2e</Sha>
<Uri>https://github.com/dotnet/android</Uri>
</Dependency>
<Dependency Name="Microsoft.MacCatalyst.Sdk.net9.0_17.2" Version="17.2.9714-net9-p6" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>4741d540eee2390fa075d0bdb49083cb58e43048</Sha>
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
</Dependency>
<Dependency Name="Microsoft.macOS.Sdk.net9.0_14.2" Version="14.2.9714-net9-p6" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>4741d540eee2390fa075d0bdb49083cb58e43048</Sha>
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
</Dependency>
<Dependency Name="Microsoft.iOS.Sdk.net9.0_17.2" Version="17.2.9714-net9-p6" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>4741d540eee2390fa075d0bdb49083cb58e43048</Sha>
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
</Dependency>
<Dependency Name="Microsoft.tvOS.Sdk.net9.0_17.2" Version="17.2.9714-net9-p6" CoherentParentDependency="Microsoft.Maui.Controls">
<Sha>4741d540eee2390fa075d0bdb49083cb58e43048</Sha>
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
</Dependency>
</ToolsetDependencies>
</Dependencies>
27 changes: 22 additions & 5 deletions scripts/run_performance_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shutil
import sys
import urllib.request
import xml.etree.ElementTree as ET
from typing import Any, Dict, List, Optional

import ci_setup
Expand Down Expand Up @@ -546,12 +547,28 @@ def run_performance_job(args: RunPerformanceJobArgs):
ci_setup_arguments.dotnet_path = f"{wasm_bundle_dir}/dotnet"

if args.dotnet_version_link is not None:
with urllib.request.urlopen(args.dotnet_version_link) as response:
values = json.loads(response.read().decode('utf-8'))
if "dotnet_version" in values:
ci_setup_arguments.dotnet_versions = [values["dotnet_version"]]
if args.dotnet_version_link.startswith("https"): # Version link is a proper url
if args.dotnet_version_link.endswith(".json"):
with urllib.request.urlopen(args.dotnet_version_link) as response:
values = json.loads(response.read().decode('utf-8'))
if "dotnet_version" in values:
ci_setup_arguments.dotnet_versions = [values["dotnet_version"]]
else:
ci_setup_arguments.dotnet_versions = [values["version"]]
else:
ci_setup_arguments.dotnet_versions = [values["version"]]
raise ValueError("Invalid dotnet_version_link provided. Must be a json file if a url.")
elif os.path.exists(os.path.join(args.performance_repo_dir, args.dotnet_version_link)) and args.dotnet_version_link.endswith("Version.Details.xml"): # version_link is a file in the perf repo
with open(os.path.join(args.performance_repo_dir, args.dotnet_version_link), encoding="utf-8") as f:
root = ET.fromstring(f.read())
dependency = root.find(".//Dependency[@Name='VS.Tools.Net.Core.SDK.Resolver']") # For net9.0
if dependency is None: # For older than net9.0
dependency = root.find(".//Dependency[@Name='Microsoft.Dotnet.Sdk.Internal']")
if dependency is not None and "Version" in dependency.attrib: # Get the actual version
ci_setup_arguments.dotnet_versions = [dependency.get("Version", "ERROR: Failed to get version")]
else:
raise ValueError("Unable to find dotnet version in the provided xml file")
else:
raise ValueError("Invalid dotnet_version_link provided")

if args.pgo_run_type == "nodynamicpgo":
ci_setup_arguments.pgo_status = "nodynamicpgo"
Expand Down
86 changes: 79 additions & 7 deletions src/scenarios/shared/mauisharedpython.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,96 @@
import subprocess
import json
import os
import requests
import xml.etree.ElementTree as ET
import re
import urllib.request
from performance.common import get_repo_root_path
from shared.precommands import PreCommands

# Remove the aab files as we don't need them, this saves space in the correlation payload
def remove_aab_files(output_dir="."):
file_list = os.listdir(output_dir)
for file in file_list:
if file.endswith(".aab"):
os.remove(os.path.join(output_dir, file))
os.remove(os.path.join(output_dir, file))

def generate_maui_rollback_dict():
# Generate and use rollback based on Version.Details.xml
# Generate the list of versions starts to get and the names to save them as in the rollback.
# These mapping values were taken from the previously generated rollback files for the maui workload. There should be at least one entry for each
# of the Maui Workload dependencies in the /eng/Version.Details.xml file, aside from VS.Tools.Net.Core.SDK.Resolver.
# If there are errors in the future, reach out to the maui team.
rollback_name_to_xml_name_mappings: dict[str, str] = {
"microsoft.net.sdk.android" : "Microsoft.Android.Sdk",
"microsoft.net.sdk.ios" : "Microsoft.iOS.Sdk",
"microsoft.net.sdk.maccatalyst" : "Microsoft.MacCatalyst.Sdk",
"microsoft.net.sdk.macos" : "Microsoft.macOS.Sdk",
"microsoft.net.sdk.maui" : "Microsoft.Maui.Controls",
"microsoft.net.sdk.tvos" : "Microsoft.tvOS.Sdk",
"microsoft.net.sdk.mono.toolchain.current" : "Microsoft.NETCore.App.Ref",
"microsoft.net.sdk.mono.emscripten.current" : "Microsoft.NET.Workload.Emscripten.Current"
}
rollback_dict: dict[str, str] = {}

# Load in the Version.Details.xml file
with open(os.path.join(get_repo_root_path(), "eng", "Version.Details.xml"), encoding="utf-8") as f:
version_details_xml = f.read()
root = ET.fromstring(version_details_xml)

# Get the General Band version from the Version.Details.xml file sdk version
general_version_obj = root.find(".//Dependency[@Name='VS.Tools.Net.Core.SDK.Resolver']")
if general_version_obj is not None:
full_band_version_holder = general_version_obj.get("Version")
if full_band_version_holder is None:
raise ValueError("Unable to find VS.Tools.Net.Core.SDK.Resolver with proper version in Version.Details.xml")
match = re.search(r'^\d+\.\d+\.\d+\-(preview|rc|alpha).\d+', full_band_version_holder)
if match:
default_band_version = match.group(0)
else:
raise ValueError("Unable to find general version in Version.Details.xml")
else:
raise ValueError("Unable to find general version in Version.Details.xml")

# Get the available versions from the Version.Details.xml file
dependencies = root.findall(".//Dependency[@Name]")
for rollback_name, xml_name in rollback_name_to_xml_name_mappings.items():
for dependency in dependencies:
if dependency.get("Name").startswith(xml_name): # type: ignore we know Name is present
workload_version = dependency.get("Version")
if workload_version is None:
raise ValueError(f"Unable to find {xml_name} with proper version in the provided xml file")

# Use the band version based on what the maui upstream currently has. This is necessary if they hardcode the version.
band_name_match_string = rf"^\s*Mapping_{xml_name}:(\S*)"
band_version_mapping = re.search(band_name_match_string, version_details_xml, flags=re.MULTILINE)
if band_version_mapping is None:
raise ValueError(f"Unable to find band version mapping for match {band_name_match_string} in Version.Details.xml")
if band_version_mapping.group(1) == "default":
band_version = default_band_version
else:
band_version = band_version_mapping.group(1)
rollback_dict[rollback_name] = f"{workload_version}/{band_version}"
break
if rollback_name not in rollback_dict:
raise ValueError(f"Unable to find {rollback_name} with proper version in Version.Details.xml")
return rollback_dict

def dump_dict_to_json_file(dump_dict: dict[str, str], file_name: str):
json_output = json.dumps(dump_dict, indent=4)
with open(file_name, "w", encoding="utf-8") as f:
f.write(json_output)

def install_versioned_maui(precommands: PreCommands):
target_framework_wo_platform = precommands.framework.split('-')[0]

# Download what we need
with open ("MauiNuGet.config", "wb") as f:
f.write(requests.get(f'https://raw.githubusercontent.com/dotnet/maui/{target_framework_wo_platform}/NuGet.config', allow_redirects=True).content)
with open("MauiNuGet.config", "wb") as f:
with urllib.request.urlopen(f'https://raw.githubusercontent.com/dotnet/maui/{target_framework_wo_platform}/NuGet.config') as response:
f.write(response.read())

workload_install_args = ['--configfile', 'MauiNuGet.config', '--skip-sign-check']
if int(target_framework_wo_platform.split('.')[0][3:]) > 7: # Use the rollback file for versions greater than 7
workload_install_args += ['--from-rollback-file', f'https://maui.blob.core.windows.net/metadata/rollbacks/{target_framework_wo_platform}.json']
if int(target_framework_wo_platform.split('.')[0][3:]) > 8: # Use the rollback file for versions greater than 8 (should be set to only run for versions where we also use a specific dotnet version from the yml)
rollback_dict = generate_maui_rollback_dict()
dump_dict_to_json_file(rollback_dict, f"rollback_{target_framework_wo_platform}.json")
workload_install_args += ['--from-rollback-file', f'rollback_{target_framework_wo_platform}.json']

precommands.install_workload('maui', workload_install_args)
Loading