Skip to content

Commit 1b6d4a0

Browse files
committed
Go through test failures from first pass to fix various issues like extra ref files, missing dev.json, and analyzer changes.
Lots of tests had hardcoded TFMs in the test itself as well.
1 parent 2b640f2 commit 1b6d4a0

20 files changed

+106
-86
lines changed

src/Assets/TestProjects/CrossTargeting/DesktopAndNetStandard/DesktopAndNetStandard.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.5'">
1616
<Reference Include="System.Windows.Forms" />
17-
<PackageReference Include="Newtonsoft.Json" Version="6.0.4" />
17+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1818
</ItemGroup>
1919
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.5'">
2020
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />

src/Assets/TestProjects/CrossTargeting/NetStandardAndNetCoreApp/NetStandardAndNetCoreApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<PropertyGroup>
33
<TargetFrameworks>$(CurrentTargetFramework);netstandard1.5</TargetFrameworks>
44
</PropertyGroup>
5-
<PropertyGroup Condition="'$(TargetFramework)' == '$(CurrentTargetFramework)'">
5+
<PropertyGroup Condition="'$(TargetFramework)' != 'netstandard1.5'">
66
<OutputType>exe</OutputType>
77
<DefineConstants>NETCOREAPP;$(DefineConstants)</DefineConstants>
88
<AssetTargetFallback>dnxcore50</AssetTargetFallback>
99
</PropertyGroup>
10-
<ItemGroup Condition="'$(TargetFramework)' == '$(CurrentTargetFramework)'">
10+
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard1.5'">
1111
<PackageReference Include="Newtonsoft.Json" Version="7.0.1" />
1212
</ItemGroup>
1313
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.5'">

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAComServerLibrary.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ public void It_copies_the_comhost_to_the_output_directory()
2929

3030
var buildCommand = new BuildCommand(testAsset);
3131
buildCommand
32-
.Execute()
32+
.Execute("/p:ProduceReferenceAssembly=false")
3333
.Should()
3434
.Pass();
3535

36-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp3.1");
36+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
3737

3838
outputDirectory.Should().OnlyHaveFiles(new[] {
3939
"ComServer.dll",
4040
"ComServer.pdb",
4141
"ComServer.deps.json",
4242
"ComServer.comhost.dll",
43-
"ComServer.runtimeconfig.json",
44-
"ComServer.runtimeconfig.dev.json"
43+
"ComServer.runtimeconfig.json"
4544
});
4645

4746
string runtimeConfigFile = Path.Combine(outputDirectory.FullName, "ComServer.runtimeconfig.json");
@@ -66,20 +65,19 @@ public void It_generates_a_regfree_com_manifest_when_requested()
6665

6766
var buildCommand = new BuildCommand(testAsset);
6867
buildCommand
69-
.Execute()
68+
.Execute("/p:ProduceReferenceAssembly=false")
7069
.Should()
7170
.Pass();
7271

73-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp3.1");
72+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
7473

7574
outputDirectory.Should().OnlyHaveFiles(new[] {
7675
"ComServer.dll",
7776
"ComServer.pdb",
7877
"ComServer.deps.json",
7978
"ComServer.comhost.dll",
8079
"ComServer.X.manifest",
81-
"ComServer.runtimeconfig.json",
82-
"ComServer.runtimeconfig.dev.json"
80+
"ComServer.runtimeconfig.json"
8381
});
8482
}
8583

@@ -100,19 +98,18 @@ public void It_embeds_the_clsidmap_in_the_comhost_when_rid_specified(string rid)
10098

10199
var buildCommand = new BuildCommand(testAsset);
102100
buildCommand
103-
.Execute()
101+
.Execute("/p:ProduceReferenceAssembly=false")
104102
.Should()
105103
.Pass();
106104

107-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp3.1", runtimeIdentifier: rid);
105+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: rid);
108106

109107
outputDirectory.Should().OnlyHaveFiles(new[] {
110108
"ComServer.dll",
111109
"ComServer.pdb",
112110
"ComServer.deps.json",
113111
"ComServer.comhost.dll",
114-
"ComServer.runtimeconfig.json",
115-
"ComServer.runtimeconfig.dev.json"
112+
"ComServer.runtimeconfig.json"
116113
});
117114
}
118115

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildACrossTargetedLibrary.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public void It_builds_nondesktop_library_successfully_on_all_platforms()
3535

3636
var outputDirectory = buildCommand.GetOutputDirectory(targetFramework: "");
3737
outputDirectory.Should().OnlyHaveFiles(new[] {
38-
"netcoreapp1.1/NetStandardAndNetCoreApp.dll",
39-
"netcoreapp1.1/NetStandardAndNetCoreApp.pdb",
40-
"netcoreapp1.1/NetStandardAndNetCoreApp.runtimeconfig.json",
41-
"netcoreapp1.1/NetStandardAndNetCoreApp.runtimeconfig.dev.json",
42-
"netcoreapp1.1/NetStandardAndNetCoreApp.deps.json",
38+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.dll",
39+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.pdb",
40+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.runtimeconfig.json",
41+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.deps.json",
42+
$"{ToolsetInfo.CurrentTargetFramework}/Newtonsoft.Json.dll",
43+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp.deps.json",
44+
$"{ToolsetInfo.CurrentTargetFramework}/NetStandardAndNetCoreApp{EnvironmentInfo.ExecutableExtension}",
45+
$"{ToolsetInfo.CurrentTargetFramework}/ref/NetStandardAndNetCoreApp.dll",
4346
"netstandard1.5/NetStandardAndNetCoreApp.dll",
4447
"netstandard1.5/NetStandardAndNetCoreApp.pdb",
4548
"netstandard1.5/NetStandardAndNetCoreApp.deps.json"
@@ -107,7 +110,7 @@ public void It_combines_inner_rids_for_restore(
107110
new XElement(ns + "RuntimeIdentifier", firstFrameworkRid),
108111
new XElement(ns + "RuntimeIdentifiers", firstFrameworkRids)),
109112
new XElement(ns + "PropertyGroup",
110-
new XAttribute(ns + "Condition", "'$(TargetFramework)' == 'netcoreapp1.1'"),
113+
new XAttribute(ns + "Condition", $"'$(TargetFramework)' == '{ToolsetInfo.CurrentTargetFramework}'"),
111114
new XElement(ns + "RuntimeIdentifier", secondFrameworkRid),
112115
new XElement(ns + "RuntimeIdentifiers", secondFrameworkRids)));
113116
});

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrariesAndRid.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.NET.TestFramework;
77
using Microsoft.NET.TestFramework.Assertions;
88
using Microsoft.NET.TestFramework.Commands;
9+
using System;
910
using System.IO;
1011
using System.Linq;
1112
using System.Runtime.InteropServices;
@@ -48,7 +49,7 @@ public void It_builds_a_RID_specific_runnable_output()
4849
.Should()
4950
.Pass();
5051

51-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp2.1", runtimeIdentifier: runtimeIdentifier);
52+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: runtimeIdentifier);
5253
var selfContainedExecutable = $"App{Constants.ExeSuffix}";
5354

5455
string selfContainedExecutableFullPath = Path.Combine(outputDirectory.FullName, selfContainedExecutable);
@@ -91,26 +92,42 @@ public void It_builds_a_framework_dependent_RID_specific_runnable_output()
9192
var buildCommand = new BuildCommand(testAsset, "App");
9293

9394
buildCommand
94-
.Execute($"/p:RuntimeIdentifier={runtimeIdentifier}", $"/p:TestRuntimeIdentifier={runtimeIdentifier}", "/p:SelfContained=false")
95+
.Execute($"/p:RuntimeIdentifier={runtimeIdentifier}", $"/p:TestRuntimeIdentifier={runtimeIdentifier}", "/p:SelfContained=false", "/p:ProduceReferenceAssembly=false")
9596
.Should().Pass();
9697

97-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp2.1", runtimeIdentifier: runtimeIdentifier);
98+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework, runtimeIdentifier: runtimeIdentifier);
9899

99100
outputDirectory.Should().NotHaveSubDirectories();
100-
outputDirectory.Should().OnlyHaveFiles(new[] {
101+
102+
var sqlFile = "";
103+
if (OperatingSystem.IsWindows())
104+
{
105+
sqlFile = "sqlite3.dll";
106+
}
107+
else if (OperatingSystem.IsLinux())
108+
{
109+
sqlFile = "libsqlite3.so";
110+
}
111+
else if (OperatingSystem.IsMacOS())
112+
{
113+
sqlFile = "libsqlite3.dylib";
114+
}
115+
string[] expectedFiles = new[] {
101116
$"App{Constants.ExeSuffix}",
102117
"App.dll",
103118
"App.pdb",
104119
"App.deps.json",
105120
"App.runtimeconfig.json",
106-
"App.runtimeconfig.dev.json",
107121
"LibraryWithoutRid.dll",
108122
"LibraryWithoutRid.pdb",
109123
"LibraryWithRid.dll",
110124
"LibraryWithRid.pdb",
111125
"LibraryWithRids.dll",
112126
"LibraryWithRids.pdb",
113-
});
127+
sqlFile
128+
};
129+
130+
outputDirectory.Should().OnlyHaveFiles(expectedFiles.Where(x => !String.IsNullOrEmpty(x)).ToList() );
114131

115132
new DotnetCommand(Log, Path.Combine(outputDirectory.FullName, "App.dll"))
116133
.Execute()

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithLibrary.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ public void It_builds_the_project_successfully_twice()
5050
void VerifyAppBuilds(TestAsset testAsset)
5151
{
5252
var buildCommand = new BuildCommand(testAsset, "TestApp");
53-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.1");
53+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
5454

5555
buildCommand
56-
.Execute()
56+
.Execute("/p:ProduceReferenceAssembly=false")
5757
.Should()
5858
.Pass();
5959

6060
outputDirectory.Should().OnlyHaveFiles(new[] {
6161
"TestApp.dll",
6262
"TestApp.pdb",
63+
$"TestApp{EnvironmentInfo.ExecutableExtension}",
6364
"TestApp.deps.json",
6465
"TestApp.runtimeconfig.json",
65-
"TestApp.runtimeconfig.dev.json",
6666
"TestLibrary.dll",
6767
"TestLibrary.pdb",
6868
});
@@ -100,11 +100,11 @@ public void It_generates_satellite_assemblies()
100100

101101
var buildCommand = new BuildCommand(testAsset, "TestApp");
102102
buildCommand
103-
.Execute()
103+
.Execute("/p:PredefinedCulturesOnly=false")
104104
.Should()
105105
.Pass();
106106

107-
var outputDir = buildCommand.GetOutputDirectory("netcoreapp2.0");
107+
var outputDir = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
108108

109109
var commandResult = new DotnetCommand(Log, Path.Combine(outputDir.FullName, "TestApp.dll"))
110110
.Execute();
@@ -146,17 +146,17 @@ public void The_clean_target_removes_all_files_from_the_output_folder()
146146
var buildCommand = new BuildCommand(testAsset, "TestApp");
147147

148148
buildCommand
149-
.Execute()
149+
.Execute("/p:ProduceReferenceAssembly=false")
150150
.Should()
151151
.Pass();
152152

153-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.1");
153+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
154154

155155
outputDirectory.Should().OnlyHaveFiles(new[] {
156156
"TestApp.dll",
157157
"TestApp.pdb",
158+
$"TestApp{EnvironmentInfo.ExecutableExtension}",
158159
"TestApp.deps.json",
159-
"TestApp.runtimeconfig.dev.json",
160160
"TestApp.runtimeconfig.json",
161161
"TestLibrary.dll",
162162
"TestLibrary.pdb"

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithSharedProject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void It_does_not_assign_link_metadata_to_items_from_shared_project()
3434
.Should()
3535
.Pass();
3636

37-
string intermediateOutputPath = Path.Combine(command.GetBaseIntermediateDirectory().FullName, "Debug", "netcoreapp2.0");
37+
string intermediateOutputPath = Path.Combine(command.GetBaseIntermediateDirectory().FullName, "Debug", ToolsetInfo.CurrentTargetFramework);
3838
string itemsFile = Path.Combine(intermediateOutputPath, "Items.txt");
3939

4040
var items = File.ReadAllLines(itemsFile)
@@ -69,7 +69,7 @@ public void It_copies_items_from_shared_project_to_correct_output_folder()
6969
.Should()
7070
.Pass();
7171

72-
var outputPath = buildCommand.GetOutputDirectory("netcoreapp2.0");
72+
var outputPath = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
7373

7474
outputPath.Should().NotHaveFile("TextFile1.txt");
7575

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithTransitiveProjectRefs.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ public void It_builds_the_project_successfully()
4141
void VerifyAppBuilds(TestAsset testAsset)
4242
{
4343
var buildCommand = new BuildCommand(testAsset, "TestApp");
44-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.1");
44+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
4545

4646
buildCommand
47-
.Execute()
47+
.Execute("/p:ProduceReferenceAssembly=false")
4848
.Should()
4949
.Pass();
5050

5151
outputDirectory.Should().OnlyHaveFiles(new[] {
5252
"TestApp.dll",
5353
"TestApp.pdb",
54+
$"TestApp{EnvironmentInfo.ExecutableExtension}",
5455
"TestApp.deps.json",
5556
"TestApp.runtimeconfig.json",
56-
"TestApp.runtimeconfig.dev.json",
5757
"MainLibrary.dll",
5858
"MainLibrary.pdb",
5959
"AuxLibrary.dll",
@@ -80,17 +80,17 @@ public void The_clean_target_removes_all_files_from_the_output_folder()
8080
var buildCommand = new BuildCommand(testAsset, "TestApp");
8181

8282
buildCommand
83-
.Execute()
83+
.Execute("/p:ProduceReferenceAssembly=false")
8484
.Should()
8585
.Pass();
8686

87-
var outputDirectory = buildCommand.GetOutputDirectory("netcoreapp1.1");
87+
var outputDirectory = buildCommand.GetOutputDirectory(ToolsetInfo.CurrentTargetFramework);
8888

8989
outputDirectory.Should().OnlyHaveFiles(new[] {
9090
"TestApp.dll",
9191
"TestApp.pdb",
92+
$"TestApp{EnvironmentInfo.ExecutableExtension}",
9293
"TestApp.deps.json",
93-
"TestApp.runtimeconfig.dev.json",
9494
"TestApp.runtimeconfig.json",
9595
"MainLibrary.dll",
9696
"MainLibrary.pdb",

src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildAnAppWithoutTransitiveProjectRefs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public void It_builds_the_project_successfully_when_RAR_finds_all_references()
3030
BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/p:DisableTransitiveProjectReferences=true"});
3131
}
3232

33-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/13081")]
33+
[Fact]
3434
public void It_builds_the_project_successfully_with_static_graph_and_isolation()
3535
{
3636
BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/graph"});
3737
}
3838

39-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/13081")]
39+
[Fact]
4040
public void It_cleans_the_project_successfully_with_static_graph_and_isolation()
4141
{
4242
var (testAsset, outputDirectories) = BuildAppWithTransitiveDependenciesAndTransitiveCompileReference(new []{"/graph"});

0 commit comments

Comments
 (0)