Prebuilt report fix (#15329)
This commit is contained in:
parent
154f9b87ce
commit
c9bfab9a6f
3 changed files with 15 additions and 23 deletions
src/SourceBuild/content
eng/tools/tasks/Microsoft.DotNet.SourceBuild.Tasks.XPlat
repo-projects
|
@ -195,13 +195,14 @@ namespace Microsoft.DotNet.SourceBuild.Tasks.UsageReport
|
|||
// Get the embedded creation time if possible: the file's original metadata may
|
||||
// have been destroyed by copying, zipping, etc.
|
||||
string creationTime = snapshot.Xml
|
||||
// Get the second PropertyGroup.
|
||||
.Elements().Skip(1).FirstOrDefault()
|
||||
// Get the creation time element.
|
||||
?.Element(snapshot.Xml
|
||||
.GetDefaultNamespace()
|
||||
.GetName(WritePackageVersionsProps.CreationTimePropertyName))
|
||||
?.Value;
|
||||
// Get all elements
|
||||
.Elements()
|
||||
// Select all the subelements
|
||||
.SelectMany(e => e.Elements())
|
||||
// Find all that match the creation time property name
|
||||
.Where(e => e.Name == snapshot.Xml.GetDefaultNamespace().GetName(WritePackageVersionsProps.CreationTimePropertyName))
|
||||
// There should be only one or zero
|
||||
.SingleOrDefault()?.Value;
|
||||
|
||||
if (string.IsNullOrEmpty(creationTime))
|
||||
{
|
||||
|
@ -279,7 +280,8 @@ namespace Microsoft.DotNet.SourceBuild.Tasks.UsageReport
|
|||
public static PackageVersionPropsElement[] Parse(XElement xml)
|
||||
{
|
||||
return xml
|
||||
// Get the single PropertyGroup
|
||||
// Get the first PropertyGroup. The second PropertyGroup is 'extra properties', and the third group is the creation time.
|
||||
// Only select the first because the extra properties are not built packages.
|
||||
.Elements()
|
||||
.First()
|
||||
// Get all *PackageVersion property elements.
|
||||
|
|
|
@ -61,13 +61,6 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
[Required]
|
||||
public string OutputPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a second PropertyGroup to the output XML containing a property with the time of
|
||||
/// creation in UTC DateTime Ticks. This can be used to track creation time in situations
|
||||
/// where file metadata isn't reliable or preserved.
|
||||
/// </summary>
|
||||
public bool IncludeCreationTimeProperty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Properties to add to the build output props, which may not exist as nupkgs.
|
||||
/// FOr example, this is used to pass the version of the CLI toolset archives.
|
||||
|
@ -242,12 +235,9 @@ namespace Microsoft.DotNet.Build.Tasks
|
|||
WriteExtraProperties(sw);
|
||||
WriteVersionEntries(sw, additionalAssetElementsToWrite, "additional assets");
|
||||
|
||||
if (IncludeCreationTimeProperty)
|
||||
{
|
||||
sw.WriteLine(@" <PropertyGroup>");
|
||||
sw.WriteLine($@" <{CreationTimePropertyName}>{DateTime.UtcNow.Ticks}</{CreationTimePropertyName}>");
|
||||
sw.WriteLine(@" </PropertyGroup>");
|
||||
}
|
||||
sw.WriteLine(@" <PropertyGroup>");
|
||||
sw.WriteLine($@" <{CreationTimePropertyName}>{DateTime.UtcNow.Ticks}</{CreationTimePropertyName}>");
|
||||
sw.WriteLine(@" </PropertyGroup>");
|
||||
|
||||
sw.WriteLine(@"</Project>");
|
||||
}
|
||||
|
|
|
@ -602,7 +602,7 @@
|
|||
Outputs="$(RepoCompletedSemaphorePath)WritePrebuiltUsageData.complete">
|
||||
<!-- Save the PVP snapshot of each build step to be evaluated while building the report. -->
|
||||
<ItemGroup>
|
||||
<PackageVersionPropsSnapshotFiles Include="$(IntermediatePath)PackageVersions.props.pre.*.xml" />
|
||||
<PackageVersionPropsSnapshotFiles Include="$(IntermediatePath)PackageVersions.*.Current.props" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(PackageVersionPropsSnapshotFiles)" DestinationFolder="$(PackageReportDir)snapshots/" />
|
||||
|
||||
|
@ -688,7 +688,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageVersionPropsSavedSnapshotFiles Include="$(PackageReportDir)snapshots/PackageVersions.props.pre.*.xml" />
|
||||
<PackageVersionPropsSavedSnapshotFiles Include="$(PackageReportDir)snapshots/PackageVersions.*.Current.props" />
|
||||
</ItemGroup>
|
||||
|
||||
<WriteUsageReports DataFile="$(PackageReportDataFile)"
|
||||
|
|
Loading…
Add table
Reference in a new issue