Skip to content

Commit

Permalink
Merge pull request #836 from natidea/useRidLess
Browse files Browse the repository at this point in the history
Use RID less targets to obtain compile assets
  • Loading branch information
natidea authored Feb 15, 2017
2 parents 11bcb10 + 4f82958 commit c17908c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,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 @@ -314,10 +322,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 @@ -334,10 +342,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();
}
}
}

0 comments on commit c17908c

Please sign in to comment.