diff --git a/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs b/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs index 1ac1f736c..57e83c76c 100644 --- a/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs +++ b/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs @@ -36,7 +36,7 @@ namespace Microsoft.DotNet.ProjectModel public override IEnumerable CompileTimeAssemblies => FilterPlaceholders(base.CompileTimeAssemblies); - public bool HasCompileTimePlaceholder => base.CompileTimeAssemblies.Any(a => PackageDependencyProvider.IsPlaceholderFile(a)); + public bool HasCompileTimePlaceholder => base.CompileTimeAssemblies.Any() && base.CompileTimeAssemblies.All(a => PackageDependencyProvider.IsPlaceholderFile(a)); private static IEnumerable FilterPlaceholders(IEnumerable items) { diff --git a/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs b/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs index 04b7cffba..3286dd05e 100644 --- a/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs +++ b/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs @@ -42,6 +42,53 @@ namespace Microsoft.DotNet.ProjectModel.Tests Assert.Empty(p2.RuntimeAssemblies); } + [Fact] + public void HasCompileTimePlaceholderChecksAllCompileTimeAssets() + { + var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references")); + var package = new LockFilePackageLibrary(); + package.Name = "Something"; + package.Version = NuGetVersion.Parse("1.0.0"); + package.Files.Add("lib/net46/_._"); + package.Files.Add("lib/net46/Something.dll"); + + var target = new LockFileTargetLibrary(); + target.Name = "Something"; + target.Version = package.Version; + + target.RuntimeAssemblies.Add("lib/net46/_._"); + target.RuntimeAssemblies.Add("lib/net46/Something.dll"); + target.CompileTimeAssemblies.Add("lib/net46/_._"); + target.CompileTimeAssemblies.Add("lib/net46/Something.dll"); + + var p1 = provider.GetDescription(NuGetFramework.Parse("net46"), package, target); + + Assert.False(p1.HasCompileTimePlaceholder); + Assert.Equal(1, p1.CompileTimeAssemblies.Count()); + Assert.Equal(1, p1.RuntimeAssemblies.Count()); + Assert.Equal("lib/net46/Something.dll", p1.CompileTimeAssemblies.First().Path); + Assert.Equal("lib/net46/Something.dll", p1.RuntimeAssemblies.First().Path); + } + + [Fact] + public void HasCompileTimePlaceholderReturnsFalseIfEmpty() + { + var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references")); + var package = new LockFilePackageLibrary(); + package.Name = "Something"; + package.Version = NuGetVersion.Parse("1.0.0"); + + var target = new LockFileTargetLibrary(); + target.Name = "Something"; + target.Version = package.Version; + + var p1 = provider.GetDescription(NuGetFramework.Parse("net46"), package, target); + + Assert.False(p1.HasCompileTimePlaceholder); + Assert.Equal(0, p1.CompileTimeAssemblies.Count()); + Assert.Equal(0, p1.RuntimeAssemblies.Count()); + } + [Theory] [InlineData("TestMscorlibReference", true)] [InlineData("TestMscorlibReference", false)]