Skip to content

Commit a078ab0

Browse files
[build] allow long branch names on PRs (#9983)
If you open a PR with a long branch name, it can error with: NuGet.Build.Tasks.Pack.targets(221,5): error NU5123: Warning As Error: The file 'package/services/metadata/core-properties/d9cd2ffb8cfc41bdbfe90e7dbc7228fb.psmdcp' path, name, or both are too long. Your package might not work without long file path support. Please shorten the file path or file name. Let's set `$(WarningAsMessages)=NU5123` for pull requests by checking if `$(BUILD_DEFINITIONNAME)` is `Xamarin.Android-PR`. This is the AzDO pipeline name we use for pull requests. The `Xamarin.Android` pipeline runs ci builds on `main` and release branches. I think the warning, in general, is good to know if we create a path inside a `.nupkg` that is too long. But for PRs, we should ignore it. This also reverts some commits that "shorten" branch names, which should no longer be needed: * 7651b64 * 6d9b295
1 parent f565669 commit a078ab0

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

build-tools/create-packs/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
1414
<!-- Ignore TargetFramework reference group related warnings, these are workload packs not functional NuGets. -->
1515
<NoWarn>$(NoWarn);NU5128;NU5131</NoWarn>
16+
<!-- Allow NU5123 for pull requests, which will run on the Xamarin.Android-PR pipeline -->
17+
<NoWarn Condition=" '$(BUILD_DEFINITIONNAME)' == 'Xamarin.Android-PR' ">$(NoWarn);NU5123</NoWarn>
1618
</PropertyGroup>
1719

1820
<Import Project="..\..\Configuration.props" />

build-tools/create-packs/Directory.Build.targets

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
<_GlobalProperties Include="-p:Configuration=$(Configuration)" />
4949
<_GlobalProperties Include="-p:IncludeSymbols=False" />
5050
</ItemGroup>
51+
<PropertyGroup>
52+
<_BinlogPrefix>-bl:$(XamarinAndroidSourcePath)bin/Build$(Configuration)/msbuild-$([System.DateTime]::Now.ToString('yyyyMMddThhmmss'))-</_BinlogPrefix>
53+
</PropertyGroup>
5154
</Target>
5255

5356
<Target Name="_CleanNuGetDirectory">
@@ -63,25 +66,25 @@
6366

6467
<Target Name="_CreateDefaultRefPack"
6568
Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidDefaultTargetDotnetApiLevel)' and Exists('$(_MonoAndroidNETOutputRoot)$(AndroidDefaultTargetDotnetApiLevel)\Mono.Android.dll') ">
66-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
69+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Ref.$(AndroidDefaultTargetDotnetApiLevel).binlog&quot; -p:AndroidApiLevel=$(AndroidDefaultTargetDotnetApiLevel) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
6770
</Target>
6871

6972
<Target Name="_CreatePreviewPacks"
7073
DependsOnTargets="_CreateItemGroups"
7174
Condition=" '$(AndroidLatestStableApiLevel)' != '$(AndroidLatestUnstableApiLevel)' and Exists('$(_MonoAndroidNETOutputRoot)$(AndroidLatestUnstableApiLevel)\Mono.Android.dll') ">
72-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:AndroidApiLevel=$(AndroidLatestUnstableApiLevel) -p:AndroidRID=%(_AndroidRIDs.Identity) -p:AndroidRuntime=%(_AndroidRIDs.Runtime) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
73-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:AndroidApiLevel=$(AndroidLatestUnstableApiLevel) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
75+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Runtime.%(_AndroidRIDs.Runtime).$(AndroidLatestUnstableApiLevel).%(_AndroidRIDs.Identity).binlog&quot; -p:AndroidApiLevel=$(AndroidLatestUnstableApiLevel) -p:AndroidRID=%(_AndroidRIDs.Identity) -p:AndroidRuntime=%(_AndroidRIDs.Runtime) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
76+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Ref.$(AndroidLatestUnstableApiLevel).binlog&quot; -p:AndroidApiLevel=$(AndroidLatestUnstableApiLevel) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
7477
</Target>
7578

7679
<Target Name="CreateAllPacks"
7780
DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo;_CleanNuGetDirectory;_CreateItemGroups;_CreatePreviewPacks;_CreateDefaultRefPack">
78-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:AndroidRID=%(_AndroidRIDs.Identity) -p:AndroidRuntime=%(_AndroidRIDs.Runtime) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
79-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
80-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:HostOS=Linux &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' == 'Linux' " />
81-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:HostOS=Darwin &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' == 'Darwin' " />
82-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') -p:HostOS=Windows &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' != 'Linux' " /> <!-- Windows pack should be built both Windows and macOS -->
83-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Android.proj&quot;" />
84-
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj&quot;" />
81+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Runtime.%(_AndroidRIDs.Runtime).$(AndroidLatestStableApiLevel).%(_AndroidRIDs.Identity).binlog&quot; -p:AndroidRID=%(_AndroidRIDs.Identity) -p:AndroidRuntime=%(_AndroidRIDs.Runtime) &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Runtime.proj&quot;" />
82+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Ref.$(AndroidLatestStableApiLevel).binlog&quot; &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Ref.proj&quot;" />
83+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Sdk.Linux.binlog&quot; -p:HostOS=Linux &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' == 'Linux' " />
84+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Sdk.Darwin.binlog&quot; -p:HostOS=Darwin &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' == 'Darwin' " />
85+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Sdk.Windows.binlog&quot; -p:HostOS=Windows &quot;$(MSBuildThisFileDirectory)Microsoft.Android.Sdk.proj&quot;" Condition=" '$(HostOS)' != 'Linux' " /> <!-- Windows pack should be built both Windows and macOS -->
86+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.NET.Sdk.Android.binlog&quot; &quot;$(MSBuildThisFileDirectory)Microsoft.NET.Sdk.Android.proj&quot;" />
87+
<Exec Command="&quot;$(DotNetPreviewTool)&quot; pack @(_GlobalProperties, ' ') &quot;$(_BinlogPrefix)Microsoft.Android.Templates.binlog&quot; &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\Microsoft.Android.Templates.csproj&quot;" />
8588
<ReplaceFileContents
8689
SourceFile="vs-workload.in.props"
8790
DestinationFile="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\vs-workload.props"

build-tools/xa-prep-tasks/Xamarin.Android.BuildTools.PrepTasks/GitBranch.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,10 @@ public override bool Execute ()
4949
}
5050

5151
done:
52-
CheckBranchLength ();
5352
Log.LogMessage (MessageImportance.Low, $" [Output] {nameof (Branch)}: {Branch}");
5453
return !Log.HasLoggedErrors;
5554
}
5655

57-
void CheckBranchLength ()
58-
{
59-
// Trim generated dependabot branch names that are too long to produce useful package names
60-
const int maxBranchLength = 32;
61-
var lastSlashIndex = Branch.LastIndexOf ('/');
62-
if (Branch.StartsWith ("dependabot") && lastSlashIndex != -1 && Branch.Length > maxBranchLength) {
63-
Log.LogMessage ($"Trimming characters from the branch name at index {lastSlashIndex}: {Branch}");
64-
Branch = Branch.Substring (lastSlashIndex + 1);
65-
}
66-
67-
// Trim darc/Maestro branch names that are too long
68-
// These will have a Guid in the branch name
69-
if (IsTrimmedBranch () && Branch.Length > maxBranchLength) {
70-
Log.LogMessage ($"Trimming to {maxBranchLength} characters from the branch name: {Branch}");
71-
Branch = Branch.Substring (0, maxBranchLength);
72-
}
73-
}
74-
75-
bool IsTrimmedBranch () =>
76-
TrimmedBranchPrefixes.Any (prefix => Branch.StartsWith (prefix, StringComparison.Ordinal));
77-
78-
static readonly string[] TrimmedBranchPrefixes = [ "darc-", "juno/" ];
79-
8056
protected override string GenerateCommandLineCommands ()
8157
{
8258
return "name-rev --name-only --exclude=tags/* HEAD";

0 commit comments

Comments
 (0)