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

[CI] Install the android and iOS dotnet version when they are diff to the maui one. #13228

Merged
merged 3 commits into from
Feb 10, 2023
Merged
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
29 changes: 29 additions & 0 deletions src/DotNet/DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PropertyGroup>
<_ProvisionDependsOn>
_DownloadDotNetInstallScript;
_GetExternalDotNetSdkVersions;
_InstallDotNet;
_AcquireWorkloadManifests;
_InstallWorkloadPacks;
Expand Down Expand Up @@ -97,11 +98,39 @@
/>
</Target>

<!-- if we are building in the unified pipeline we want to install the runtimes from the props of the sdks -->
<Target Name="_GetExternalDotNetSdkVersions">
<XmlPeek
Condition="Exists('$(AndroidSrcPath)\eng\Versions.props')"
XmlInputPath="$(AndroidSrcPath)\eng\Versions.props"
Query="/Project/PropertyGroup/MicrosoftNETCoreAppRefPackageVersion/text()">
<Output TaskParameter="Result" PropertyName="VersionFromAndroid" />
</XmlPeek>
<XmlPeek
Condition="Exists('$(MaciosSrcPath)\eng\Versions.props')"
XmlInputPath="$(MaciosSrcPath)\eng\Versions.props"
Query="/Project/PropertyGroup/MicrosoftNETCoreAppRefPackageVersion/text()">
<Output TaskParameter="Result" PropertyName="VersionFromMacios" />
</XmlPeek>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows'))">
<DotNetXARuntimeInstallCommand>&amp; '$(DotNetInstallScriptPath)' -Version $(VersionFromAndroid) -InstallDir '$(DotNetDirectory)' -Verbose -Runtime dotnet</DotNetXARuntimeInstallCommand>
Copy link
Member

Choose a reason for hiding this comment

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

This will install a new runtime into the .NET SDK. So, you get a folder like dotnet/host/fxr/7.0.*.

This allows dotnet build to run with a newer runtime, but I don't think it will actually provision a newer Mono workload. So on-device tests & things will have the older one?

Do we need to figure this out as well?

Copy link
Member

Choose a reason for hiding this comment

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

The main reasoning behind this is to fix the MAUI build in the megapipeline. If Android builds with an sdk that references a newer runtime than the one that MAUI provisions, tools like class-parse won't run:

Using: D:\a\_work\1\s\bin\dotnet\dotnet.exe D:\a\_work\1\s\bin\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.30\tools\class-parse.dll
    [class-parse] response file: obj\Release\net7.0-android\class-parse.rsp
    --o="obj\Release\net7.0-android\api.xml.class-parse"
    "obj\Release\net7.0-android\library_project_jars\maui.aar\classes.jar"
    CommandLineArguments = D:\a\_work\1\s\bin\dotnet\dotnet.exe D:\a\_work\1\s\bin\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.30\tools\class-parse.dll "@obj\Release\net7.0-android\class-parse.rsp" 
    You must install or update .NET to run this application.
    App: D:\a\_work\1\s\bin\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.30\tools\class-parse.dll
    Architecture: x64
    Framework: 'Microsoft.NETCore.App', version '7.0.0' (x64)
    .NET location: D:\a\_work\1\s\bin\dotnet\
    The following frameworks were found:
      7.0.0-rtm.22511.4 at [D:\a\_work\1\s\bin\dotnet\shared\Microsoft.NETCore.App]

I think we may have a similar situation with some of the tools that ship with XM/XI SDKs as well. Ideally the megapipeline will add support to build everything against the same .NET SDK dependency, but that is not currently the case.

<DotNetXMRuntimeInstallCommand>&amp; '$(DotNetInstallScriptPath)' -Version $(VersionFromMacios) -InstallDir '$(DotNetDirectory)' -Verbose -Runtime dotnet</DotNetXMRuntimeInstallCommand>
<DotNetXARuntimeInstallCommand>powershell -ExecutionPolicy ByPass -NoProfile -Command &quot;$(DotNetXARuntimeInstallCommand)&quot;</DotNetXARuntimeInstallCommand>
<DotNetXMRuntimeInstallCommand>powershell -ExecutionPolicy ByPass -NoProfile -Command &quot;$(DotNetXMRuntimeInstallCommand)&quot;</DotNetXMRuntimeInstallCommand>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx'))">
<DotNetXARuntimeInstallCommand>bash '$(DotNetInstallScriptPath)' --version $(VersionFromAndroid) --install-dir '$(DotNetDirectory)' --verbose -Runtime dotnet</DotNetXARuntimeInstallCommand>
<DotNetXMRuntimeInstallCommand>bash '$(DotNetInstallScriptPath)' --version $(VersionFromMacios) --install-dir '$(DotNetDirectory)' --verbose -Runtime dotnet</DotNetXMRuntimeInstallCommand>
</PropertyGroup>
</Target>

<Target Name="_InstallDotNet"
Inputs="$(_Inputs)"
Outputs="$(DotNetDirectory).stamp">
<RemoveDir Directories="$(DotNetDirectory)" />
<Exec Command="$(DotNetInstallCommand)" />
<Exec Condition=" '$(VersionFromAndroid)' != '' " Command="$(DotNetXARuntimeInstallCommand)" />
<Exec Condition=" '$(VersionFromMacios)' != '' " Command="$(DotNetXMRuntimeInstallCommand)" />
<Touch Files="$(DotNetDirectory).stamp" AlwaysCreate="true" />

<!-- This is used by iOS pair to mac because pair to mac can't
Expand Down