Skip to content

Commit f71118c

Browse files
Copilotbaronfel
andcommitted
Add RID-specific assets validation to restore test
Co-authored-by: baronfel <[email protected]>
1 parent bf09c54 commit f71118c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/dotnet.Tests/CommandTests/Restore/GivenThatIWantToRestoreApp.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.DotNet.Tools.Test.Utilities;
5+
using Newtonsoft.Json.Linq;
56
using System.Runtime.InteropServices;
67

78
namespace Microsoft.DotNet.Restore.Test
@@ -205,6 +206,22 @@ public void ItRestoresWithRidSpecificOptions(params string[] ridOptions)
205206
// Verify that assets file was created
206207
var assetsFilePath = Path.Combine(rootPath, "obj", "project.assets.json");
207208
File.Exists(assetsFilePath).Should().BeTrue();
209+
210+
// Verify that the assets file contains RID-specific targets when using RID options
211+
if (ridOptions.Contains("-r") || ridOptions.Contains("--runtime") ||
212+
ridOptions.Contains("--os") || ridOptions.Contains("-a") || ridOptions.Contains("--arch"))
213+
{
214+
var assetsContents = JObject.Parse(File.ReadAllText(assetsFilePath));
215+
var targets = assetsContents["targets"];
216+
targets.Should().NotBeNull("assets file should contain targets section");
217+
218+
// Check for RID-specific targets (targets with RID have names containing "/")
219+
var ridSpecificTargets = targets.Children<JProperty>()
220+
.Where(target => target.Name.Contains("/"))
221+
.ToList();
222+
223+
ridSpecificTargets.Should().NotBeEmpty("assets file should contain RID-specific targets when using RID options");
224+
}
208225
}
209226

210227
private static string[] HandleStaticGraphEvaluation(bool useStaticGraphEvaluation, string[] args) =>

0 commit comments

Comments
 (0)