Skip to content

Commit

Permalink
[build] Update package metadata (#9230)
Browse files Browse the repository at this point in the history
Looking at the package explorer for recent .NET 9 preview 7 builds I
noticed that other packages do not include sha metadata in the
version element.

Compare the following by clicking "View Metadata source":

  * https://nuget.info/packages/Microsoft.Android.Runtime.35.android-arm/35.0.0-preview.7.41
    > <version>35.0.0-preview.7.41+sha.a9d10b4</version>
  * https://nuget.info/packages/Microsoft.NETCore.App.Runtime.Mono.android-arm/9.0.0-preview.7.24405.7
    > <version>9.0.0-preview.7.24405.7</version>
  * https://nuget.info/packages/Microsoft.Maui.Sdk/9.0.0-preview.7.24407.4
    > <version>9.0.0-preview.7.24407.4</version>

I believe the sha metadata was added when we were initially figuring
out a package versioning schema that would produce unique package
versions; however, our usage of commit distance in both preview and
stable versions should address this concern.

The sha metadata inclusion in the version element but not the `.nupkg`
name also causes conflicts with the latest version of the
[arcade publishing tooling][0] which expects these to be in sync.

The short hash in the metadata has been replaced by a `repository`
element which will contain the repo url and full commit hash:

	<repository type="git" url="https://github.com/dotnet/android" branch="refs/heads/dev/pjc/pack-repo-meta" commit="eb5455aaecd59ca979f184e7992624819e263315" />

The icon and other package metadata have been updated to better match
other .NET packages.

[0]: https://github.com/dotnet/arcade/blob/b4f4d40741f161e2c0d96c19c51a4013850ef65f/src/Microsoft.DotNet.Build.Tasks.Feed/src/PushToBuildStorage.cs
  • Loading branch information
pjcollins authored Aug 20, 2024
1 parent 003f5d1 commit baa7eba
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
20 changes: 1 addition & 19 deletions Documentation/guides/OneDotNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ see the [net6-samples][net6-samples] repo.

## Package Versioning Scheme

This is the package version scheme: `OS-Major.OS-Minor.InternalRelease[-prereleaseX]+sha.1b2c3d4`.
This is the package version scheme: `OS-Major.OS-Minor.InternalRelease[-prereleaseX].CommitDistance`.

* Major: The highest stable API level, such as 30. On Apple platforms, this is the major OS version.
* Minor: Always 0 for Android. On Apple platforms, this is the minor OS version.
Expand Down Expand Up @@ -327,24 +327,6 @@ This is the package version scheme: `OS-Major.OS-Minor.InternalRelease[-prerelea
referencing `*-android-r.beta.*`
* It's still possible to sign up for all `android-r` builds, by
referencing `*-ci.android-r.*`
* Build metadata: Required Hash
* This is `sha.` + the short commit hash.
* Use the short hash because the long hash is quite long and
cumbersome. This leaves the complete version open for duplication,
but this is extremely unlikely.
* Example: `30.0.100+sha.1a2b3c`
* Example (CI build): `30.0.100-ci.master.1234+sha.1a2b3c`
* Since the build metadata is required for all builds, we're able to
recognize incomplete version numbers and determine if a particular
version string refers to a stable version or not.
* Example: `30.0.100`: incomplete version
* Example: `30.0.100+sha.1a2b3c`: stable
* Example: `30.0.100-ci.d17-0.1234+sha.1a2b3c`: CI build
* Example: `30.0.100-android-r.beta.1+sha.1a2b3c`: official
preview
* Technically it's possible to remove the prerelease part, but
we’d still be able to figure out it’s not a stable version by
using the commit hash.


[0]: https://github.com/dotnet/installer#installers-and-binaries
Expand Down
2 changes: 2 additions & 0 deletions build-tools/create-packs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageType>DotnetPlatform</PackageType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<OutputPath>$(BootstrapOutputDirectory)nuget-unsigned\</OutputPath>
<GenerateDependencyFile>false</GenerateDependencyFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Expand Down
2 changes: 1 addition & 1 deletion build-tools/create-packs/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<Target Name="_GetDefaultPackageVersion"
DependsOnTargets="GetXAVersionInfo" >
<PropertyGroup>
<PackageVersion>$(AndroidPackVersionLong)+sha.$(XAVersionHash)</PackageVersion>
<PackageVersion>$(AndroidPackVersionLong)</PackageVersion>
</PropertyGroup>
</Target>

Expand Down
Binary file added build-tools/create-packs/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion build-tools/create-packs/License.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
<PropertyGroup>
<Authors>Microsoft</Authors>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/dotnet/android</PackageProjectUrl>
<RepositoryUrl>https://github.com/dotnet/android</RepositoryUrl>
<PackageProjectUrl>https://dot.net</PackageProjectUrl>
<Owners>microsoft,dotnetframework</Owners>
<NuGetLicense Condition="Exists('$(XamarinAndroidSourcePath)external\monodroid\tools\scripts\License.txt')">$(XamarinAndroidSourcePath)external\monodroid\tools\scripts\License.txt</NuGetLicense>
<NuGetLicense Condition=" '$(NuGetLicense)' == '' or '$(PackageId)' != 'Microsoft.Android.Sdk.$(HostOS)' ">$(XamarinAndroidSourcePath)LICENSE.TXT</NuGetLicense>
<PackageLicenseFile>LICENSE.TXT</PackageLicenseFile>
<PackageIcon>Icon.png</PackageIcon>
<BeforePack>_GetLicense;$(BeforePack)</BeforePack>
</PropertyGroup>
<Target Name="_GetLicense">
Expand All @@ -19,6 +22,7 @@
<ItemGroup>
<_PackageFiles Include="$(IntermediateOutputPath)$(PackageLicenseFile)" PackagePath="\" />
<_PackageFiles Include="$(XAInstallPrefix)THIRD-PARTY-NOTICES.TXT" PackagePath="\" />
<_PackageFiles Include="$(MSBuildThisFileDirectory)Icon.png" PackagePath="\" />
</ItemGroup>
</Target>
</Project>
2 changes: 1 addition & 1 deletion src/Microsoft.Android.Templates/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Target Name="_GetDefaultPackageVersion"
DependsOnTargets="GetXAVersionInfo" >
<PropertyGroup>
<TemplatePackVersion Condition="'$(TemplatePackVersion)' == ''">$(AndroidPackVersionLong)+sha.$(XAVersionHash)</TemplatePackVersion>
<TemplatePackVersion Condition="'$(TemplatePackVersion)' == ''">$(AndroidPackVersionLong)</TemplatePackVersion>
<PackageVersion>$(TemplatePackVersion)</PackageVersion>
</PropertyGroup>
</Target>
Expand Down

0 comments on commit baa7eba

Please sign in to comment.