[build] Make package metadata optional (#21081)

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.iOS.Ref.net9.0_17.5/17.5.9231-net9-p7
https://nuget.info/packages/Microsoft.NETCore.App.Runtime.Mono.ios-arm64/9.0.0-preview.7.24405.7
https://nuget.info/packages/Microsoft.Maui.Sdk/9.0.0-preview.7.24407.4

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.

While waiting for a fix in arcade, we can remove this metadata to
restore dependency flow. It can be restored in the future by setting
the following:

    NUGET_BUILD_METADATA=+sha.$(CURRENT_HASH)

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

[0]:
b4f4d40741/src/Microsoft.DotNet.Build.Tasks.Feed/src/PushToBuildStorage.cs

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
Peter Collins 2024-08-23 12:19:32 -04:00 коммит произвёл GitHub
Родитель c7cbd6728e
Коммит 92092f67fd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
6 изменённых файлов: 22 добавлений и 28 удалений

Просмотреть файл

@ -161,7 +161,7 @@ else
NUGET_PRERELEASE_IDENTIFIER=-ci.$(CURRENT_BRANCH_ALPHANUMERIC)
endif
NUGET_BUILD_METADATA=sha.$(CURRENT_HASH)
NUGET_BUILD_METADATA=
IOS_PRODUCT=Xamarin.iOS
IOS_PACKAGE_NAME=Xamarin.iOS
@ -178,7 +178,7 @@ IOS_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(IOS_NUGET_VERSION)))
IOS_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(IOS_NUGET_VERSION)))
IOS_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(IOS_NUGET_VERSION)))
IOS_NUGET_VERSION_NO_METADATA=$(IOS_NUGET_VERSION)$(NUGET_PRERELEASE_IDENTIFIER)
IOS_NUGET_VERSION_FULL=$(IOS_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)
IOS_NUGET_VERSION_FULL=$(IOS_NUGET_VERSION_NO_METADATA)$(NUGET_BUILD_METADATA)
IOS_WINDOWS_NUGET=Microsoft.iOS.Windows
IOS_WINDOWS_NUGET_VERSION_MAJOR=$(IOS_NUGET_VERSION_MAJOR)
@ -193,7 +193,7 @@ TVOS_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(TVOS_NUGET_VERSION)))
TVOS_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(TVOS_NUGET_VERSION)))
TVOS_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(TVOS_NUGET_VERSION)))
TVOS_NUGET_VERSION_NO_METADATA=$(TVOS_NUGET_VERSION)$(NUGET_PRERELEASE_IDENTIFIER)
TVOS_NUGET_VERSION_FULL=$(TVOS_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)
TVOS_NUGET_VERSION_FULL=$(TVOS_NUGET_VERSION_NO_METADATA)$(NUGET_BUILD_METADATA)
WATCHOS_NUGET=Microsoft.watchOS
WATCHOS_NUGET_VERSION=$(WATCHOS_NUGET_OS_VERSION).$(WATCHOS_NUGET_COMMIT_DISTANCE)
@ -201,7 +201,7 @@ WATCHOS_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(WATCHOS_NUGET_VERSION)))
WATCHOS_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(WATCHOS_NUGET_VERSION)))
WATCHOS_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(WATCHOS_NUGET_VERSION)))
WATCHOS_NUGET_VERSION_NO_METADATA=$(WATCHOS_NUGET_VERSION)$(NUGET_PRERELEASE_IDENTIFIER)
WATCHOS_NUGET_VERSION_FULL=$(WATCHOS_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)
WATCHOS_NUGET_VERSION_FULL=$(WATCHOS_NUGET_VERSION_NO_METADATA)$(NUGET_BUILD_METADATA)
MACCATALYST_NUGET=Microsoft.MacCatalyst
MACCATALYST_NUGET_VERSION=$(MACCATALYST_NUGET_OS_VERSION).$(MACCATALYST_NUGET_COMMIT_DISTANCE)
@ -209,7 +209,7 @@ MACCATALYST_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(MACCATALYST_NUGET_VERSIO
MACCATALYST_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(MACCATALYST_NUGET_VERSION)))
MACCATALYST_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(MACCATALYST_NUGET_VERSION)))
MACCATALYST_NUGET_VERSION_NO_METADATA=$(MACCATALYST_NUGET_VERSION)$(NUGET_PRERELEASE_IDENTIFIER)
MACCATALYST_NUGET_VERSION_FULL=$(MACCATALYST_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)
MACCATALYST_NUGET_VERSION_FULL=$(MACCATALYST_NUGET_VERSION_NO_METADATA)$(NUGET_BUILD_METADATA)
# Xcode version should have both a major and a minor version (even if the minor version is 0)
XCODE_VERSION=15.4
@ -581,7 +581,7 @@ MACOS_NUGET_VERSION_MAJOR=$(word 1, $(subst ., ,$(MACOS_NUGET_VERSION)))
MACOS_NUGET_VERSION_MINOR=$(word 2, $(subst ., ,$(MACOS_NUGET_VERSION)))
MACOS_NUGET_VERSION_PATCH=$(word 3, $(subst ., ,$(MACOS_NUGET_VERSION)))
MACOS_NUGET_VERSION_NO_METADATA=$(MACOS_NUGET_VERSION)$(NUGET_PRERELEASE_IDENTIFIER)
MACOS_NUGET_VERSION_FULL=$(MACOS_NUGET_VERSION_NO_METADATA)+$(NUGET_BUILD_METADATA)
MACOS_NUGET_VERSION_FULL=$(MACOS_NUGET_VERSION_NO_METADATA)$(NUGET_BUILD_METADATA)
ifneq ($(TESTS_USE_SYSTEM),)
MAC_DESTDIR ?= /

Просмотреть файл

@ -362,7 +362,7 @@ $(TMP_PKG_DIR)/Microsoft.$1.Templates.$2.pkg: $(TEMPLATE_PACKS_$(4)) | $(TMP_PKG
$$(Q) rm -f $$@
$$(Q) rm -rf tmpdir/Microsoft.$1.Templates.$2/
$$(Q) mkdir -p tmpdir/Microsoft.$1.Templates.$2/usr/local/share/dotnet/template-packs/
$$(Q) $$(CP) $(TEMPLATE_PACKS_$(4)) tmpdir/Microsoft.$1.Templates.$2/usr/local/share/dotnet/template-packs/$(subst +$(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q) $$(CP) $(TEMPLATE_PACKS_$(4)) tmpdir/Microsoft.$1.Templates.$2/usr/local/share/dotnet/template-packs/$(subst $(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q_GEN) pkgbuild --quiet --version '$2' --root tmpdir/Microsoft.$1.Templates.$2 --component-plist PackageInfo.plist --install-location / --identifier com.microsoft.net.$3.template.pkg $$@.tmp
$$(Q) mv $$@.tmp $$@
@ -395,7 +395,7 @@ $(TMP_PKG_DIR)/Microsoft.$1.Bundle.$2.zip: $($(1)_NUGET_TARGETS) $(WORKLOAD_TARG
$$(Q) $(CP) -r Workloads/Microsoft.NET.Sdk.$1 $$@.tmpdir/dotnet/sdk-manifests/$(MACIOS_MANIFEST_VERSION_BAND)/microsoft.net.sdk.$3
$$(Q) $(CP) -r $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME) $$@.tmpdir/dotnet/packs/$($(1)_NUGET_SDK_NAME)/$2
$$(Q) $(CP) -r $(DOTNET_DESTDIR)/$($(1)_NUGET_REF_NAME) $$@.tmpdir/dotnet/packs/$($(1)_NUGET_REF_NAME)/$2
$$(Q) $(CP) $(TEMPLATE_PACKS_$(4)) $$@.tmpdir/dotnet/template-packs/$(subst +$(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q) $(CP) $(TEMPLATE_PACKS_$(4)) $$@.tmpdir/dotnet/template-packs/$(subst $(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q_GEN) cd $$@.tmpdir && zip -9rq $$(abspath $$@.tmp) .
$$(Q) mv $$@.tmp $$@
$$(Q) echo Created $$@
@ -423,7 +423,7 @@ $(TMP_PKG_DIR)/Microsoft.$1.Windows.Bundle.$2.zip: $($(1)_NUGET_TARGETS) $($(1)_
$$(Q) $(CP) -r $(DOTNET_DESTDIR)/$($(1)_NUGET_SDK_NAME) $$@.tmpdir/dotnet/packs/$($(1)_NUGET_SDK_NAME)/$2
$$(Q) $(CP) -r $(DOTNET_DESTDIR)/$($(1)_NUGET_WINDOWS_SDK_NAME) $$@.tmpdir/dotnet/packs/$($(1)_NUGET_WINDOWS_SDK_NAME)/$2
$$(Q) $(CP) -r $(DOTNET_DESTDIR)/$($(1)_NUGET_REF_NAME) $$@.tmpdir/dotnet/packs/$($(1)_NUGET_REF_NAME)/$2
$$(Q) $(CP) $(TEMPLATE_PACKS_$(4)) $$@.tmpdir/dotnet/template-packs/$(subst +$(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q) $(CP) $(TEMPLATE_PACKS_$(4)) $$@.tmpdir/dotnet/template-packs/$(subst $(NUGET_BUILD_METADATA),,$(notdir $(TEMPLATE_PACKS_$(4))))
$$(Q_GEN) cd $$@.tmpdir && zip -9rq $$(abspath $$@.tmp) .
$$(Q) mv $$@.tmp $$@
$$(Q) echo Created $$@

Просмотреть файл

@ -4,7 +4,7 @@
Our NuGet packages are versioned using [Semver 2.0.0][2].
This is the scheme: `OsMajor.OsMinor.InternalRelease[-prereleaseX]+sha.1b2c3d4`.
This is the scheme: `OsMajor.OsMinor.InternalRelease[-prereleaseX]`.
* Major: The major OS version.
* Minor: The minor OS version.
@ -36,24 +36,13 @@ This is the scheme: `OsMajor.OsMinor.InternalRelease[-prereleaseX]+sha.1b2c3d4`.
* Example: `iOS 15.1.123-rt` (and nothing else). This makes these
versions exactly 3 characters longer than the release version, which
is hopefully enough to avoid MAX_PATH issues on Windows.
* Build metadata: Required Hash
* Build metadata: Optional 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: `iOS 14.0.123+sha.1a2b3c`
* Example (CI build): `iOS 15.0.123-ci.main+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: `iOS 15.0.123`: incomplete version
* Example: `iOS 15.0.123+sha.1a2b3c`: stable
* Example: `iOS 15.0.123-ci.d17-0+sha.1a2b3c`: CI build
* Example: `iOS 15.0.123-xcode13-1.beta+sha.1a2b3c`: official
preview
* Technically it's possible to remove the prerelease part, but
wed still be able to figure out its not a stable version by
using the commit hash.
[1]: https://github.com/dotnet/designs/blob/master/accepted/2018/sdk-version-scheme.md
[2]: https://semver.org

Двоичные данные
dotnet/package/Icon.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.1 KiB

Просмотреть файл

@ -12,8 +12,12 @@
<RepositoryCommit>$(CurrentHash)</RepositoryCommit>
<Authors>Microsoft</Authors>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/xamarin/xamarin-macios</PackageProjectUrl>
<PackageProjectUrl>https://dot.net</PackageProjectUrl>
<Owners>microsoft,dotnetframework</Owners>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>Icon.png</PackageIcon>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDependencyFile>false</GenerateDependencyFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@ -39,6 +43,7 @@
<ItemGroup>
<None Include="$(_RepositoryPath)/LICENSE" Pack="true" PackagePath="/" />
<None Include="$(MSBuildThisFileDirectory)Icon.png" Pack="true" PackagePath="/" />
<Content Include="$(_packagePath)**" Pack="true" PackagePath="/" />
</ItemGroup>

Просмотреть файл

@ -33,22 +33,22 @@
-e "s/@IOS_VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@IOS_REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(CURRENT_HASH))/g' \
-e "s/@IOS_NUGET_VERSION@/$(IOS_NUGET_VERSION)/g" \
-e "s/@IOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(IOS_NUGET_COMMIT_DISTANCE)+$(NUGET_BUILD_METADATA)/g" \
-e "s/@IOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(IOS_NUGET_COMMIT_DISTANCE)$(NUGET_BUILD_METADATA)/g" \
\
-e "s/@TVOS_VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@TVOS_REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(CURRENT_HASH))/g' \
-e "s/@TVOS_NUGET_VERSION@/$(TVOS_NUGET_VERSION)/g" \
-e "s/@TVOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(TVOS_NUGET_COMMIT_DISTANCE)+$(NUGET_BUILD_METADATA)/g" \
-e "s/@TVOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(TVOS_NUGET_COMMIT_DISTANCE)$(NUGET_BUILD_METADATA)/g" \
\
-e "s/@WATCHOS_VERSION@/$(IOS_PACKAGE_VERSION_MAJOR).$(IOS_PACKAGE_VERSION_MINOR).$(IOS_PACKAGE_VERSION_REV)/g" \
-e 's/@WATCHOS_REVISION@/$(IOS_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(CURRENT_HASH))/g' \
-e "s/@WATCHOS_NUGET_VERSION@/$(WATCHOS_NUGET_VERSION)/g" \
-e "s/@WATCHOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(WATCHOS_NUGET_COMMIT_DISTANCE)+$(NUGET_BUILD_METADATA)/g" \
-e "s/@WATCHOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(WATCHOS_NUGET_COMMIT_DISTANCE)$(NUGET_BUILD_METADATA)/g" \
\
-e "s/@MACOS_VERSION@/$(MAC_PACKAGE_VERSION_MAJOR).$(MAC_PACKAGE_VERSION_MINOR).$(MAC_PACKAGE_VERSION_REV)/g" \
-e 's/@MACOS_REVISION@/$(MAC_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(CURRENT_HASH))/g' \
-e "s/@MACOS_NUGET_VERSION@/$(MACOS_NUGET_VERSION)/g" \
-e "s/@MACOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(MACOS_NUGET_COMMIT_DISTANCE)+$(NUGET_BUILD_METADATA)/g" \
-e "s/@MACOS_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$(MACOS_NUGET_COMMIT_DISTANCE)$(NUGET_BUILD_METADATA)/g" \
\
-e "s/@TARGET_PLATFORM_VERSION_IOS@/$(IOS_NUGET_OS_VERSION)/g" \
-e "s/@TARGET_PLATFORM_VERSION_TVOS@/$(TVOS_NUGET_OS_VERSION)/g" \
@ -72,7 +72,7 @@
\
$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),-e 's/@$(platform)_REVISION@/$($(platform)_COMMIT_DISTANCE) ($(CURRENT_BRANCH_SED_ESCAPED): $(CURRENT_HASH))/g') \
$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),-e 's/@$(platform)_NUGET_VERSION@/$($(platform)_NUGET_VERSION)/g') \
$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),-e "s/@$(platform)_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$($(platform)_NUGET_COMMIT_DISTANCE)+$(NUGET_BUILD_METADATA)/g") \
$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),-e "s/@$(platform)_NUGET_REVISION@/$(NUGET_PRERELEASE_IDENTIFIER)$($(platform)_NUGET_COMMIT_DISTANCE)$(NUGET_BUILD_METADATA)/g") \
\
-e "s/@PRODUCT_HASH@/$(CURRENT_HASH_LONG)/g" \
$< > $@