Skip to content

Commit ce0be21

Browse files
committed
Update test to parse assets file
1 parent 1a07dba commit ce0be21

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/Microsoft.NET.Build.Tests/GivenThatWeWantToResolveConflicts.cs

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

44
using System.Text.RegularExpressions;
5+
using NuGet.Common;
6+
using NuGet.Frameworks;
7+
using NuGet.ProjectModel;
58

69
namespace Microsoft.NET.Build.Tests
710
{
@@ -286,15 +289,16 @@ public void PlatformPackagesCanBePruned(bool prunePackages)
286289
buildCommand.Execute().Should().Pass();
287290

288291
var assetsFilePath = Path.Combine(buildCommand.GetBaseIntermediateDirectory().FullName, "project.assets.json");
289-
290-
// TODO: parse and process assets file instead of just loooking for string in it
292+
var lockFile = LockFileUtilities.GetLockFile(assetsFilePath, new NullLogger());
293+
var lockFileTarget = lockFile.GetTarget(NuGetFramework.Parse(ToolsetInfo.CurrentTargetFramework), runtimeIdentifier: null);
294+
291295
if (prunePackages)
292296
{
293-
File.ReadAllText(assetsFilePath).Should().NotContain("System.Text.Json");
297+
lockFileTarget.Libraries.Should().NotContain(library => library.Name.Equals("System.Text.Json", StringComparison.OrdinalIgnoreCase));
294298
}
295299
else
296300
{
297-
File.ReadAllText(assetsFilePath).Should().Contain("System.Text.Json");
301+
lockFileTarget.Libraries.Should().Contain(library => library.Name.Equals("System.Text.Json", StringComparison.OrdinalIgnoreCase));
298302
}
299303
}
300304
}

0 commit comments

Comments
 (0)