Skip to content

Commit 9542489

Browse files
committed
Add test
1 parent 298bb03 commit 9542489

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildADesktopLibrary.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,34 @@ public void Method1()
105105

106106
}
107107

108+
[Theory]
109+
[InlineData("RazorSimpleMvc22", "netcoreapp2.2", "SimpleMvc22")]
110+
[InlineData("DesktopReferencingNetStandardLibrary", "net46", "Library")]
111+
public void PackageReferences_with_private_assets_do_not_appear_in_deps_file(string asset, string targetFramework, string exeName)
112+
{
113+
var testAsset = _testAssetsManager
114+
.CopyTestAsset(asset)
115+
.WithSource();
116+
117+
var buildCommand = new BuildCommand(testAsset);
118+
buildCommand.Execute().Should().Pass();
119+
120+
using (var depsJsonFileStream = File.OpenRead(Path.Combine(buildCommand.GetOutputDirectory(targetFramework).FullName, exeName + ".deps.json")))
121+
{
122+
var dependencyContext = new DependencyContextJsonReader().Read(depsJsonFileStream);
123+
if (asset.Equals("DesktopReferencingNetStandardLibrary"))
124+
{
125+
dependencyContext.CompileLibraries.Any(l => l.Name.Equals("Library")).Should().BeTrue();
126+
dependencyContext.RuntimeLibraries.Any(l => l.Name.Equals("Library")).Should().BeTrue();
127+
}
128+
else
129+
{
130+
dependencyContext.CompileLibraries.Any(l => l.Name.Equals("Nerdbank.GitVersioning")).Should().BeTrue();
131+
dependencyContext.RuntimeLibraries.Any(l => l.Name.Equals("Nerdbank.GitVersioning")).Should().BeFalse();
132+
}
133+
}
134+
}
135+
108136
[WindowsOnlyFact]
109137
public void It_can_reference_a_netstandard2_library_and_exchange_types()
110138
{

test/TestAssets/TestProjects/RazorSimpleMvc22/SimpleMvc22.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</PropertyGroup>
1919

2020
<ItemGroup>
21+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.6.146" ExcludeAssets="runtime"/>
2122
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.6" PrivateAssets="All" />
2223
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
2324
</ItemGroup>

0 commit comments

Comments
 (0)