From 67555bf4dfc52edb3a9a933b0d6d181a1bd783a1 Mon Sep 17 00:00:00 2001 From: Nat Ayewah Date: Tue, 7 Feb 2017 19:09:20 -0800 Subject: [PATCH 1/3] Use RID less targets to obtain compile assets. Derive ResolvedCompileFileDefinitions and ResolvedFrameworkAssemblies from file dependencies with parent target equal to NuGetTargetMoniker (i.e. excluding the RID if one exists) --- ...Microsoft.PackageDependencyResolution.targets | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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..30512628abe3 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. + + + <_RIDLessTFMFileDependencies Include="@(FileDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" /> + + + - <_CompileFileItems Include="@(_ActiveTFMFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" /> + <_CompileFileItems Include="@(_RIDLessTFMFileDependencies->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="@(_RIDLessTFMFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" /> false From ffcd2e0d2e786fcc914448c36b69c58678af097f Mon Sep 17 00:00:00 2001 From: Nat Ayewah Date: Fri, 10 Feb 2017 19:11:35 -0800 Subject: [PATCH 2/3] Replace RIDLess with TFMOnly --- .../Microsoft.PackageDependencyResolution.targets | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 30512628abe3..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,11 +306,11 @@ Copyright (c) .NET Foundation. All rights reserved. - + Returns="_TFMOnlyFileDependencies"> - <_RIDLessTFMFileDependencies Include="@(FileDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" /> + <_TFMOnlyFileDependencies Include="@(FileDependencies->WithMetadataValue('ParentTarget', '$(NuGetTargetMoniker)'))" /> @@ -324,10 +324,10 @@ Copyright (c) .NET Foundation. All rights reserved. --> - <_CompileFileItems Include="@(_RIDLessTFMFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" /> + <_CompileFileItems Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'CompileTimeAssembly'))" /> <__CompileFileDefinitions Include="@(FileDefinitions)" Exclude="@(_CompileFileItems)" /> @@ -344,10 +344,10 @@ Copyright (c) .NET Foundation. All rights reserved. - <_FrameworkAssemblies Include="@(_RIDLessTFMFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" /> + <_FrameworkAssemblies Include="@(_TFMOnlyFileDependencies->WithMetadataValue('FileGroup', 'FrameworkAssembly'))" /> false From 4f8295817f86cd49439154bb07cea7cbe8415fd3 Mon Sep 17 00:00:00 2001 From: Nat Ayewah Date: Tue, 14 Feb 2017 16:54:42 -0800 Subject: [PATCH 3/3] Add test that msbuild /t:Compile passes even if we pass in a bogus RID because compile is no longer relying on RID-specific section --- .../GivenThatWeWantToBuildALibrary.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) 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