Update logs, add check for valid RID
This commit is contained in:
parent
5a2d878d25
commit
8eb0cd2a5c
3 changed files with 16 additions and 2 deletions
|
@ -8,6 +8,9 @@
|
|||
DependsOnTargets="DetermineSourceBuiltSdkVersion"
|
||||
Condition="'$(ShortStack)' != 'true'" >
|
||||
|
||||
<Message Text="Comparing built SDK against closest official build"
|
||||
Importance="High"/>
|
||||
|
||||
<GetValidArchiveItems ArchiveItems="@(SdkTarballItem)"
|
||||
ArchiveName="dotnet-sdk">
|
||||
<Output TaskParameter="ValidArchiveItems"
|
||||
|
|
|
@ -122,6 +122,15 @@ public abstract class Archive : IDisposable
|
|||
.Replace(Version, "")
|
||||
.Replace(packageName, "")
|
||||
.Trim('-', '.', '_');
|
||||
|
||||
// A RID with '.' must have a version number after the first '.' in each part of the RID. For example, alpine.3.10-arm64.
|
||||
// Otherwise, it's likely an archive of another type of file that we don't handle here, for example, .msi.wixpack.zip.
|
||||
var ridParts = Rid.Split('-');
|
||||
foreach(var item in ridParts.SelectMany(p => p.Split('.').Skip(1)))
|
||||
{
|
||||
if (!int.TryParse(item, out _))
|
||||
throw new ArgumentException($"Invalid Rid '{Rid}' in archive file name '{filename}'. Expected RID with '.' to be part of a version. This likely means the file is an archive of a different file type.");
|
||||
}
|
||||
return (Version, Rid, extension);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Build.Framework;
|
||||
|
||||
public class GetValidArchiveItems : Microsoft.Build.Utilities.Task
|
||||
|
@ -21,15 +22,16 @@ public class GetValidArchiveItems : Microsoft.Build.Utilities.Task
|
|||
List<ITaskItem> archiveItems = new();
|
||||
foreach (var item in ArchiveItems)
|
||||
{
|
||||
var filename = Path.GetFileName(item.ItemSpec);
|
||||
try
|
||||
{
|
||||
// Ensure the version and RID info can be parsed from the item
|
||||
_ = Archive.GetInfoFromFileName(item.ItemSpec, ArchiveName);
|
||||
_ = Archive.GetInfoFromFileName(filename, ArchiveName);
|
||||
archiveItems.Add(item);
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Log.LogMessage(MessageImportance.High, e.Message);
|
||||
Log.LogMessage($"'{item.ItemSpec}' is not a valid archive name: '{e.Message}'");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue