Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,14 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="_ComputeTFMOnlyFileDependencies"
DependsOnTargets="RunResolvePackageDependencies"
Returns="_TFMOnlyFileDependencies">
<ItemGroup>
<_TFMOnlyFileDependencies Include="@(FileDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" />
</ItemGroup>
</Target>

<!--
============================================================
Reference Targets: For populating References based on lock file
Expand All @@ -316,10 +324,10 @@ Copyright (c) .NET Foundation. All rights reserved.
-->

<Target Name="_ComputeLockFileReferences"
DependsOnTargets="_ComputeActiveTFMFileDependencies"
DependsOnTargets="_ComputeTFMOnlyFileDependencies"
Returns="ResolvedCompileFileDefinitions">
<ItemGroup>
<_CompileFileItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" />
<_CompileFileItems Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" />

<!-- Get corresponding file definitions -->
<__CompileFileDefinitions Include="@(FileDefinitions)" Exclude="@(_CompileFileItems)" />
Expand All @@ -336,10 +344,10 @@ Copyright (c) .NET Foundation. All rights reserved.

<Target Name="_ComputeLockFileFrameworks"
Condition="'$(DisableLockFileFrameworks)' != 'true'"
DependsOnTargets="_ComputeActiveTFMFileDependencies"
DependsOnTargets="_ComputeTFMOnlyFileDependencies"
Returns="ResolvedFrameworkAssemblies">
<ItemGroup>
<_FrameworkAssemblies Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" />
<_FrameworkAssemblies Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" />

<ResolvedFrameworkAssemblies Include="%(_FrameworkAssemblies.FrameworkAssembly)">
<Private>false</Private>
Expand Down
22 changes: 22 additions & 0 deletions test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}