PR feedback

This commit is contained in:
Forgind 2023-07-31 09:49:10 -07:00
parent 63faf3282d
commit 465fe07004
3 changed files with 10 additions and 82 deletions

View file

@ -1,64 +0,0 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Newtonsoft.Json.Linq;
namespace Microsoft.DotNet.Cli.Build
{
public class JsonPropertyParser : Task
{
[Required]
public string[] JFilenames
{
get;
set;
}
[Required]
public string[] JPaths
{
get;
set;
}
[Output]
public ITaskItem[] Value
{
get;
private set;
}
public override bool Execute()
{
Value = new TaskItem[JFilenames.Length];
for (var i = 0; i < JFilenames.Length; i++)
{
Value[i] = new TaskItem(JFilenames[i]);
try
{
using (var sr = new StreamReader(JFilenames[i]))
{
var json = sr.ReadToEnd();
var o = JObject.Parse(json);
foreach (var path in JPaths)
{
var lastDot = path.LastIndexOf('.');
var name = lastDot == -1 ? path : path.Substring(lastDot + 1);
Value[i].SetMetadata(name, o.SelectToken(path).Value<string>());
}
}
}
catch (Exception e)
{
Log.LogErrorFromException(e);
}
}
return !Log.HasLoggedErrors;
}
}
}

View file

@ -35,7 +35,6 @@
<UsingTask TaskName="GetDependencyInfo" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GetLinuxNativeInstallerDependencyVersions" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="GetRuntimePackRids" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="JsonPropertyParser" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="ReplaceDuplicateFilesWithHardLinks" AssemblyFile="$(CoreSdkTaskDll)"/>
<UsingTask TaskName="ReplaceFileContents" AssemblyFile="$(CoreSdkTaskDll)" />
<UsingTask TaskName="TarGzFileCreateFromDirectory" AssemblyFile="$(CoreSdkTaskDll)" />

View file

@ -105,29 +105,22 @@
<Copy SourceFiles="@(ManifestContent)"
DestinationFolder="$(RedistLayoutPath)sdk-manifests/%(DestinationPath)"/>
<ItemGroup>
<FormattedManifestPaths Include="$(RedistLayoutPath)sdk-manifests\**\%(BundledManifests.Identity)\WorkloadManifest.json" />
</ItemGroup>
<PropertyGroup>
<WorkloadSetVersion Condition="'$(DotNetFinalVersionKind)' == 'release'">$(Version)-baseline.$(_PatchNumber)</WorkloadSetVersion>
<WorkloadSetVersion Condition="'$(DotNetFinalVersionKind)' != 'release'">$(Version)</WorkloadSetVersion>
<RealFormattedManifestPaths>$(RedistLayoutPath)sdk-manifests\$(NetFeatureBand)\workloadsets\$(WorkloadSetVersion)</RealFormattedManifestPaths>
</PropertyGroup>
<JsonPropertyParser JFileNames="@(FormattedManifestPaths)" JPaths="version" Value="empty">
<Output TaskParameter="Value" ItemName="BaselineManifestsWithVersion" />
</JsonPropertyParser>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<FormattedBaselineManifest Include="{" />
<FormattedBaselineManifest Include="&quot;$([System.IO.Path]::GetFileName(%(BaselineManifestsWithVersion.Identity)))&quot;: &quot;%(BaselineManifestsWithVersion.Version)&quot;,"/>
<FormattedBaselineManifest Include="&quot;Version&quot;: &quot;$(WorkloadSetVersion)&quot;," />
<FormattedBaselineManifest Include="&quot;%(BundledManifests.Identity)&quot;: &quot;%(BundledManifests.Version)&quot;,"/>
<FormattedBaselineManifest Include="}" />
</ItemGroup>
<<<<<<< Updated upstream
<WriteLinestoFile File="$(RedistLayoutPath)sdk-manifests\BaselineManifest.json" Lines="@(FormattedBaselineManifest)" />
=======
<PropertyGroup>
<BaselineManifestFileName Condition="''$(DotNetFinalVersionKind)' == 'release'">BaselineManifest</BaselineManifestFileName>
<BaselineManifestFileName Condition="''$(DotNetFinalVersionKind)' != 'release'">BaselineManifest</BaselineManifestFileName>
</PropertyGroup>
<WriteLinestoFile File="$(RedistLayoutPath)sdk-manifests\$(BaselineManifestFileName).json" Lines="@(FormattedBaselineManifest)" />
>>>>>>> Stashed changes
<WriteLinestoFile File="$(RealFormattedManifestPaths)\Baseline.WorkloadSet.json" Lines="@(FormattedBaselineManifest)" />
</Target>
</Project>