Skip to content

Commit 742f28e

Browse files
committed
Fix test failures
1 parent b2426b3 commit 742f28e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,22 @@ Restores netcoreapp and publishes it to a temp directory
258258

259259
<Target Name="_RestoreCrossgen"
260260
DependsOnTargets="PrepforRestoreForComposeStore;
261-
_SetupStageForCrossgen;"
261+
_SetupStageForCrossgen;
262+
ApplyImplicitVersions"
262263
Condition="$(SkipOptimization) != 'true' ">
264+
265+
<ItemGroup>
266+
<!-- Filter package references to the one for the platform library, in order to find the right version -->
267+
<PackageReferenceForCrossGen Include="@(PackageReference)" Condition="'%(Identity)' == '$(MicrosoftNETPlatformLibrary)'" />
268+
</ItemGroup>
269+
263270
<MSBuild Projects="$(MSBuildProjectFullPath)"
264271
Targets="Restore"
265272
Properties="RestoreGraphProjectInput=$(MSBuildProjectFullPath);
266273
DisableImplicitFrameworkReferences=true;
267274
RestoreOutputPath=$(_CrossProjFileDir);
268275
StorePackageName=$(MicrosoftNETPlatformLibrary);
269-
StorePackageVersion=$(RuntimeFrameworkVersion);"/>
276+
StorePackageVersion=%(PackageReferenceForCrossGen.Version);"/>
270277

271278
<ResolvePublishAssemblies ProjectPath="$(MSBuildProjectFullPath)"
272279
AssetsFilePath="$(_CrossProjAssetsFile)"

src/Tests/Microsoft.NET.Publish.Tests/GivenThatAPublishedDepsJsonShouldContainVersionInformation.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
using Microsoft.NET.TestFramework.Commands;
1616
using Microsoft.NET.TestFramework.ProjectConstruction;
1717
using Newtonsoft.Json.Linq;
18+
using NuGet.Common;
19+
using NuGet.Frameworks;
20+
using NuGet.ProjectModel;
1821
using Xunit;
1922
using Xunit.Abstractions;
2023

@@ -254,15 +257,14 @@ string GetRollForwardNetCoreAppVersion()
254257

255258
var testAsset = _testAssetsManager.CreateTestProject(testProject)
256259
.Restore(Log, testProject.Name);
257-
var getValuesCommand = new GetValuesCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name),
258-
testProject.TargetFrameworks, "RuntimeFrameworkVersion")
259-
{
260-
ShouldCompile = false
261-
};
262260

263-
getValuesCommand.Execute().Should().Pass();
261+
LockFile lockFile = LockFileUtilities.GetLockFile(Path.Combine(testAsset.TestRoot, testProject.Name,
262+
"obj", "project.assets.json"), NullLogger.Instance);
263+
264+
var target = lockFile.GetTarget(NuGetFramework.Parse(testProject.TargetFrameworks), null);
265+
var netCoreAppLibrary = target.Libraries.Single(l => l.Name == "Microsoft.NETCore.App");
264266

265-
return getValuesCommand.GetValues().Single();
267+
return netCoreAppLibrary.Version.ToString();
266268
}
267269
}
268270
}

0 commit comments

Comments
 (0)