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

Add Android workload manifests to SB .NET SDK #42125

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"version": "34.99.0-preview.6.340",
"workloads": {
"android": {
"description": ".NET SDK Workload for building Android applications.",
"packs": [
"Microsoft.Android.Sdk.net9",
"Microsoft.Android.Sdk.net8",
"Microsoft.Android.Ref.34",
"Microsoft.Android.Runtime.34.android-arm",
"Microsoft.Android.Runtime.34.android-arm64",
"Microsoft.Android.Runtime.34.android-x86",
"Microsoft.Android.Runtime.34.android-x64",
"Microsoft.Android.Templates"
],
"platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ],
"extends" : [
"microsoft-net-runtime-android-net8",
"microsoft-net-runtime-android-aot-net8",
"microsoft-net-runtime-android",
"microsoft-net-runtime-android-aot"
]
},
"android-35": {
"description": "Preview support for Android API-35.",
"packs": [
"Microsoft.Android.Ref.35",
"Microsoft.Android.Runtime.35.android-arm",
"Microsoft.Android.Runtime.35.android-arm64",
"Microsoft.Android.Runtime.35.android-x86",
"Microsoft.Android.Runtime.35.android-x64"
],
"platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ],
"extends" : [ "android" ]
}
},
"packs": {
"Microsoft.Android.Sdk.net9": {
"kind": "sdk",
"version": "34.99.0-preview.6.340",
"alias-to": {
"osx-x64": "Microsoft.Android.Sdk.Darwin",
"osx-arm64": "Microsoft.Android.Sdk.Darwin",
"win-x86": "Microsoft.Android.Sdk.Windows",
"win-x64": "Microsoft.Android.Sdk.Windows",
"win-arm64": "Microsoft.Android.Sdk.Windows",
"linux-x64": "Microsoft.Android.Sdk.Linux",
"linux-arm64": "Microsoft.Android.Sdk.Linux"
}
},
"Microsoft.Android.Sdk.net8": {
"kind": "sdk",
"version": "34.0.113",
"alias-to": {
"osx-x64": "Microsoft.Android.Sdk.Darwin",
"osx-arm64": "Microsoft.Android.Sdk.Darwin",
"win-x86": "Microsoft.Android.Sdk.Windows",
"win-x64": "Microsoft.Android.Sdk.Windows",
"win-arm64": "Microsoft.Android.Sdk.Windows",
"linux-x64": "Microsoft.Android.Sdk.Linux",
"linux-arm64": "Microsoft.Android.Sdk.Linux"
}
},
"Microsoft.Android.Ref.34": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.34.android-arm": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.34.android-arm64": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.34.android-x86": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.34.android-x64": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Ref.35": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.35.android-arm": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.35.android-arm64": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.35.android-x86": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Runtime.35.android-x64": {
"kind": "framework",
"version": "34.99.0-preview.6.340"
},
"Microsoft.Android.Templates": {
"kind": "template",
"version": "34.99.0-preview.6.340"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<ImportGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' ">
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net9"
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '9.0')) " />
<Import Project="Sdk.targets" Sdk="Microsoft.Android.Sdk.net8"
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) " />
<Import Project="Eol.targets" Sdk="Microsoft.Android.Sdk.net9"
Condition=" $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) or $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0')) " />
</ImportGroup>

<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' and $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) ">
<KnownFrameworkReference
Update="Microsoft.Android"
LatestRuntimeFrameworkVersion="34.0.113"
TargetingPackVersion="34.0.113"
/>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0')) ">
<SdkSupportedTargetPlatformIdentifier Include="android" DisplayName="Android" />
</ItemGroup>
</Project>
34 changes: 29 additions & 5 deletions src/Installer/redist-installer/targets/BundledManifests.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<ItemGroup>
<BundledManifests Include="Microsoft.NET.Sdk.Android" FeatureBand="$(MauiFeatureBand)" Version="$(XamarinAndroidWorkloadManifestVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
<BundledManifests Include="Microsoft.NET.Sdk.Android" FeatureBand="$(MauiFeatureBand)" Version="$(XamarinAndroidWorkloadManifestVersion)" IncludedInSource="true" />
<BundledManifests Include="Microsoft.NET.Sdk.iOS" FeatureBand="$(MauiFeatureBand)" Version="$(XamarinIOSWorkloadManifestVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
<BundledManifests Include="Microsoft.NET.Sdk.MacCatalyst" FeatureBand="$(MauiFeatureBand)" Version="$(XamarinMacCatalystWorkloadManifestVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
<BundledManifests Include="Microsoft.NET.Sdk.macOS" FeatureBand="$(MauiFeatureBand)" Version="$(XamarinMacOSWorkloadManifestVersion)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
Expand Down Expand Up @@ -31,12 +31,14 @@
<RestoredNupkgContentPath>$(NuGetPackageRoot)$([MSBuild]::ValueOrDefault('%(NupkgId)', '').ToLower())/$([MSBuild]::ValueOrDefault('%(Version)', '').ToLower())</RestoredNupkgContentPath>
<MsiNupkgId>%(Identity).Manifest-%(FeatureBand).Msi.$(MsiArchitectureForWorkloadManifests)</MsiNupkgId>
<RestoredMsiNupkgContentPath>$(NuGetPackageRoot)$([MSBuild]::ValueOrDefault('%(MsiNupkgId)', '').ToLower())/$([MSBuild]::ValueOrDefault('%(Version)', '').ToLower())</RestoredMsiNupkgContentPath>
<IncludedInSource Condition="'%(IncludedInSource)' == ''">false</IncludedInSource>
<PackageDownload Condition="'$(DotNetBuildSourceOnly)' != 'true' or '%(IncludedInSource)' != 'true'">true</PackageDownload>
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to not specialize this for source-build? e.g. the MSFT build would also use the version from the SDK repo. It is best to avoid unnecessary differences between the two builds. Keeping them the same helps flush out issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can rework this to use a property like -p:UpdateManifestSources=true, and then it wouldn't need to ever check $(DotNetBuildSourceOnly). Someone would only set this property when updating the manifest sources.

Is the build green (or need a rerun)? I don't think I've seen it fully green yet, so just wondering if it works before I refactor it. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I think this got past the pre-built errors now, but some of the smoke tests run into:

System.InvalidOperationException : Failed to execute /vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/extracted-sdk/dotnet test /bl:/vmr/artifacts/TestResults/Release/BasicScenarioTests_MSTest_CSharp-test.binlog
Exit code: 1
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242: SDK Resolver Failure: "The SDK resolver "Microsoft.DotNet.MSBuildWorkloadSdkResolver" failed while attempting to resolve the SDK "MSTest.Sdk/3.4.3". Exception: "System.IO.FileNotFoundException: Workload manifest microsoft.net.sdk.android: 34.99.0-preview.6.340/9.0.100-preview.6 from workload version 9.0.100-preview.7.24373.1 was not installed. Running "dotnet workload repair" may resolve this.
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.SdkDirectoryWorkloadManifestProvider.GetManifests()
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.LoadManifestsFromProvider(IWorkloadManifestProvider manifestProvider)
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.InitializeManifests()
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadManifestReader.WorkloadResolver.TryGetPackInfo(WorkloadPackId packId)
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, IWorkloadManifestProvider manifestProvider, IWorkloadResolver workloadResolver)
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.CachingWorkloadResolver.Resolve(String sdkReferenceName, String dotnetRootPath, String sdkVersion, String userProfileDir, String globalJsonPath)
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.NET.Sdk.WorkloadMSBuildSdkResolver.WorkloadSdkResolver.Resolve(SdkReference sdkReference, SdkResolverContext resolverContext, SdkResultFactory factory)
/vmr/artifacts/bin/Microsoft.DotNet.SourceBuild.SmokeTests/Release/projects-202407231701323151/BasicScenarioTests_MSTest_CSharp/BasicScenarioTests_MSTest_CSharp.csproj : error MSB4242:    at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.TryResolveSdkUsingSpecifiedResolvers(IReadOnlyList`1 resolvers, Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive, Boolean isRunningInVisualStudio, SdkResult& sdkResult, IEnumerable`1& errors, IEnumerable`1& warnings)""

I'll see if I can reproduce this on GitHub codespaces.

</BundledManifests>
</ItemGroup>

<!-- Restore workload manifests via PackageDownload -->
<ItemGroup>
<PackageDownload Include="@(BundledManifests->'%(NupkgId)')">
<PackageDownload Include="@(BundledManifests->'%(NupkgId)'->WithMetadataValue('PackageDownload', 'true'))">
<Version>[%(Version)]</Version>
</PackageDownload>
</ItemGroup>
Expand Down Expand Up @@ -86,15 +88,37 @@

<Target Name="LayoutManifests"
DependsOnTargets="SetupBundledComponents">

<!-- Manifest sources that exist in-tree -->
<ItemGroup>
<SourceManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\*"
Condition="'%(BundledManifests.IncludedInSource)' == 'true' and Exists('%(BundledManifests.RestoredNupkgContentPath)\data')"
DestinationPath="%(BundledManifests.FeatureBand)/$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/%(BundledManifests.Version)"
RestoredNupkgContentPath="%(RestoredNupkgContentPath)"
WorkloadManifestId="%(Identity)" />

<SourceManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\localize\*"
Condition="'%(BundledManifests.IncludedInSource)' == 'true' and Exists('%(RestoredNupkgContentPath)\data\localize')"
DestinationPath="%(BundledManifests.FeatureBand)/$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/%(BundledManifests.Version)/localize" />
</ItemGroup>

<!-- Do not copy for source build, should already be in-tree -->
<Copy Condition="'$(DotNetBuildSourceOnly)' != 'true'"
SourceFiles="@(SourceManifestContent)"
DestinationFolder="sdk-manifests/%(DestinationPath)"
SkipUnchangedFiles="true" />
Comment on lines +105 to +109
Copy link
Member Author

Choose a reason for hiding this comment

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

This is for convenience of someone updating the manifests (likely me). We could put it behind a property like -p:UpdateManifestSources=true, if we are concerned about this running.


<ItemGroup>
<ManifestContent Include="@(SourceManifestContent->'sdk-manifests/%(DestinationPath)/%(FileName)%(Extension)')" />

<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\*"
Condition="Exists('%(RestoredNupkgContentPath)\data')"
DestinationPath="%(FeatureBand)/$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/%(Version)"
Condition="'%(BundledManifests.IncludedInSource)' != 'true' and Exists('%(BundledManifests.RestoredNupkgContentPath)\data')"
DestinationPath="%(BundledManifests.FeatureBand)/$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/%(BundledManifests.Version)"
RestoredNupkgContentPath="%(RestoredNupkgContentPath)"
WorkloadManifestId="%(Identity)" />

<ManifestContent Include="%(BundledManifests.RestoredNupkgContentPath)\data\localize\*"
Condition="Exists('%(RestoredNupkgContentPath)\data\localize')"
Condition="'%(BundledManifests.IncludedInSource)' != 'true' and Exists('%(RestoredNupkgContentPath)\data\localize')"
DestinationPath="%(BundledManifests.FeatureBand)/$([MSBuild]::ValueOrDefault('%(Identity)', '').ToLower())/%(BundledManifests.Version)/localize" />
</ItemGroup>

Expand Down
Loading