-
Notifications
You must be signed in to change notification settings - Fork 280
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
LoopedBard3
merged 14 commits into
dotnet:main
from
LoopedBard3:UpdateMauiVersionRetrievalFlow
Aug 1, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7860bf8
WIP: Update how we determine dotnet version to use and rollback versi…
LoopedBard3 9b15cd1
WIP Continue: Added more mappings and figured out we do have to inclu…
LoopedBard3 3ba3ed6
Add Maui Versions to Version.Details.xml for the mainline maui versions.
LoopedBard3 e272c4b
WIP Continue: Switched to using local Version.Details.xml for the wor…
LoopedBard3 aaa88e7
Switch to using Version.Details.xml to determine which version to use…
LoopedBard3 7ef37f9
Update how we get the version from the azure-pipelines.yml for 9.0 ma…
LoopedBard3 fa4d370
Attempt to fix pipeline error.
LoopedBard3 d42ee45
Setup testing.
LoopedBard3 13fd087
Revert "Setup testing."
LoopedBard3 cab856e
Remove unnecessary mono rollback entries and added a printout of the …
LoopedBard3 ff71767
Break off the rollback generation and the dict to json file so they c…
LoopedBard3 6c29a7d
Remove requests import from the mauisharedpython.py for runtime runab…
LoopedBard3 2437130
Update per feedback.
LoopedBard3 ba84ed7
Update per feedback, pt. 2.
LoopedBard3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
LoopedBard3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.