diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets index 90deefc671c6..d404088a5648 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.PackageDependencyResolution.targets @@ -306,6 +306,14 @@ Copyright (c) .NET Foundation. All rights reserved. + + + <_TFMOnlyFileDependencies Include="@(FileDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" /> + + + - <_CompileFileItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" /> + <_CompileFileItems Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" /> <__CompileFileDefinitions Include="@(FileDefinitions)" Exclude="@(_CompileFileItems)" /> @@ -336,10 +344,10 @@ Copyright (c) .NET Foundation. All rights reserved. - <_FrameworkAssemblies Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" /> + <_FrameworkAssemblies Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" /> false diff --git a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs index 69608cebd1af..72774c3b5eb3 100644 --- a/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs +++ b/test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs @@ -555,5 +555,27 @@ public void It_fails_gracefully_if_targetframework_is_empty() .And.HaveStdOutContaining("TargetFramework=''") // new deliberate error .And.NotHaveStdOutContaining(">="); // old error about comparing empty string to version } + + [Fact] + public void It_passes_ridless_target_to_compiler() + { + var testAsset = _testAssetsManager + .CopyTestAsset("AppWithLibrary", "RidlessLib") + .WithSource() + .Restore(relativePath: "TestLibrary"); + + var libraryProjectDirectory = Path.Combine(testAsset.TestRoot, "TestLibrary"); + var fullPathProjectFile = new BuildCommand(Stage0MSBuild, libraryProjectDirectory).FullPathProjectFile; + + // compile should still pass with unknown RID because references are always pulled + // from RIDLess target + var buildCommand = Stage0MSBuild.CreateCommandForTarget( + "Compile", fullPathProjectFile, "/p:RuntimeIdentifier=unknownrid"); + + buildCommand + .Execute() + .Should() + .Pass(); + } } } \ No newline at end of file