Skip to content

Commit 9b78df1

Browse files
authored
Clean-up test projects (#2312)
1. Don't reference Microsoft.NETFramework.ReferenceAssemblies That package is already brought in by the SDK automatically when targeting .NET Framework. 2. When not using Arcade, bring xunit and xunit.runner.visualstudio in without specifying it in every test project. Same for the TestResults exclude that was specified in every project. 3. Simplify a few xml statements 4. Target .NET Frameworks on all builds as that support was added years ago by the SDK. 5. Remove the "DEBUG|TRACE" defines that are already the default when building debug.
1 parent c804f9e commit 9b78df1

File tree

11 files changed

+53
-181
lines changed

11 files changed

+53
-181
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<Project>
3-
<Import Project="Sdk.props"
4-
Sdk="Microsoft.DotNet.Arcade.Sdk"
2+
3+
<Import Project="Sdk.props"
4+
Sdk="Microsoft.DotNet.Arcade.Sdk"
55
Condition="'$(DisableArcade)' != '1'" />
66

77
<PropertyGroup>

Directory.Build.targets

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<Project>
3-
<Import Project="Sdk.targets"
2+
3+
<Import Project="Sdk.targets"
44
Sdk="Microsoft.DotNet.Arcade.Sdk"
5-
Condition="'$(DisableArcade)' != '1'" />
5+
Condition="'$(DisableArcade)' != '1'" />
6+
7+
<PropertyGroup Condition="'$(DisableArcade)' == '1' and $(MSBuildProjectName.EndsWith('.Tests'))">
8+
<DefaultExcludesInProjectFolder>$(DefaultExcludesInProjectFolder);TestResults\**</DefaultExcludesInProjectFolder>
9+
</PropertyGroup>
10+
11+
<ItemGroup Condition="'$(DisableArcade)' == '1' and $(MSBuildProjectName.EndsWith('.Tests'))">
12+
<PackageReference Include="xunit" Version="2.4.1" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
14+
</ItemGroup>
15+
616
</Project>

src/System.CommandLine.ApiCompatibility.Tests/System.CommandLine.ApiCompatibility.Tests.csproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@
1515
<ProjectReference Include="..\System.CommandLine\System.CommandLine.csproj" />
1616
</ItemGroup>
1717

18-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
19-
<PackageReference Include="xunit" Version="2.4.1" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
21-
<PrivateAssets>all</PrivateAssets>
22-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
23-
</PackageReference>
24-
</ItemGroup>
25-
2618
</Project>

src/System.CommandLine.DragonFruit.Tests/System.CommandLine.DragonFruit.Tests.csproj

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>$(TargetFrameworkForNETSDK)</TargetFramework>
45
<StartupObject>AutoGeneratedProgram</StartupObject>
@@ -10,24 +11,10 @@
1011
<NoWarn>1701;1702;1591</NoWarn>
1112
</PropertyGroup>
1213

13-
<ItemGroup>
14-
<Compile Remove="TestResults\**" />
15-
<EmbeddedResource Remove="TestResults\**" />
16-
<None Remove="TestResults\**" />
17-
</ItemGroup>
18-
1914
<ItemGroup>
2015
<PackageReference Include="FluentAssertions" Version="5.10.3" />
2116
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
2217
</ItemGroup>
23-
24-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
25-
<PackageReference Include="xunit" Version="2.4.1" />
26-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
27-
<PrivateAssets>all</PrivateAssets>
28-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
29-
</PackageReference>
30-
</ItemGroup>
3118

3219
<ItemGroup>
3320
<ProjectReference Include="..\System.CommandLine.DragonFruit\System.CommandLine.DragonFruit.csproj" />
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFrameworks>$(TargetFrameworkForNETSDK)</TargetFrameworks>
4-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
4+
<TargetFrameworks>$(TargetFrameworkForNETSDK);net462</TargetFrameworks>
55
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
66
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
77
<Nullable>enable</Nullable>
88
</PropertyGroup>
99

10-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
11-
<DefineConstants>DEBUG;TRACE</DefineConstants>
12-
</PropertyGroup>
13-
14-
<ItemGroup>
15-
<Compile Remove="TestResults\**" />
16-
<EmbeddedResource Remove="TestResults\**" />
17-
<None Remove="TestResults\**" />
18-
</ItemGroup>
19-
2010
<ItemGroup>
2111
<ProjectReference Include="..\System.CommandLine.Generator.CommandHandler\System.CommandLine.Generator.CommandHandler.csproj" />
2212
<ProjectReference Include="..\System.CommandLine\System.CommandLine.csproj" />
@@ -25,15 +15,7 @@
2515

2616
<ItemGroup>
2717
<PackageReference Include="FluentAssertions" Version="5.10.3" />
28-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
2918
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
3019
</ItemGroup>
31-
32-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
33-
<PackageReference Include="xunit" Version="2.4.1" />
34-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
35-
<PrivateAssets>all</PrivateAssets>
36-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
37-
</PackageReference>
38-
</ItemGroup>
20+
3921
</Project>

src/System.CommandLine.Hosting.Tests/System.CommandLine.Hosting.Tests.csproj

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>$(TargetFrameworkForNETSDK)</TargetFrameworks>
5-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
4+
<TargetFrameworks>$(TargetFrameworkForNETSDK);net462</TargetFrameworks>
65
<IsPackable>false</IsPackable>
76
</PropertyGroup>
87

9-
<ItemGroup>
10-
<Compile Remove="TestResults\**" />
11-
<EmbeddedResource Remove="TestResults\**" />
12-
<None Remove="TestResults\**" />
13-
</ItemGroup>
14-
158
<ItemGroup>
169
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1710
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" />
18-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
19-
</ItemGroup>
20-
21-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
22-
<PackageReference Include="xunit" Version="2.4.1" />
23-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
24-
<PrivateAssets>all</PrivateAssets>
25-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26-
</PackageReference>
2711
</ItemGroup>
2812

2913
<ItemGroup>
Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFrameworks>$(TargetFrameworkForNETSDK)</TargetFrameworks>
4-
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
4+
<TargetFrameworks>$(TargetFrameworkForNETSDK);net462</TargetFrameworks>
55
<LangVersion>10</LangVersion>
66
</PropertyGroup>
7-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
8-
<DefineConstants>DEBUG;TRACE</DefineConstants>
9-
</PropertyGroup>
10-
<ItemGroup>
11-
<Compile Remove="TestResults\**" />
12-
<EmbeddedResource Remove="TestResults\**" />
13-
<None Remove="TestResults\**" />
14-
</ItemGroup>
157

168
<ItemGroup>
179
<Compile Include="..\Common\ArgumentBuilder.cs" Link="Utility\ArgumentBuilder.cs" />
@@ -28,16 +20,8 @@
2820
<ItemGroup>
2921
<PackageReference Include="ApprovalTests" Version="5.4.7" />
3022
<PackageReference Include="FluentAssertions" Version="5.10.3" />
31-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
3223
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
3324
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.1.6" />
3425
</ItemGroup>
35-
36-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
37-
<PackageReference Include="xunit" Version="2.4.1" />
38-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
39-
<PrivateAssets>all</PrivateAssets>
40-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
41-
</PackageReference>
42-
</ItemGroup>
26+
4327
</Project>

src/System.CommandLine.Rendering.Tests/System.CommandLine.Rendering.Tests.csproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<Compile Remove="TestResults\**" />
10-
<EmbeddedResource Remove="TestResults\**" />
11-
<None Remove="TestResults\**" />
12-
</ItemGroup>
13-
148
<ItemGroup>
159
<Compile Include="..\System.CommandLine.Rendering\WrappingExtensions.cs" Link="WrappingExtensions.cs" />
1610
</ItemGroup>
@@ -26,12 +20,4 @@
2620
<ProjectReference Include="..\System.CommandLine\System.CommandLine.csproj" />
2721
</ItemGroup>
2822

29-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
30-
<PackageReference Include="xunit" Version="2.4.1" />
31-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
32-
<PrivateAssets>all</PrivateAssets>
33-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
34-
</PackageReference>
35-
</ItemGroup>
36-
3723
</Project>

src/System.CommandLine.Suggest.Tests/dotnet-suggest.Tests.csproj

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,46 @@
22

33
<PropertyGroup>
44
<TargetFramework>$(TargetFrameworkForNETSDK)</TargetFramework>
5+
<DefaultExcludesInProjectFolder>$(DefaultExcludesInProjectFolder);EndToEndTestApp\**</DefaultExcludesInProjectFolder>
56
</PropertyGroup>
67

7-
<ItemGroup>
8-
<Compile Remove="TestResults\**" />
9-
<EmbeddedResource Remove="TestResults\**" />
10-
<None Remove="TestResults\**" />
11-
12-
<Compile Remove="EndToEndTestApp/**" />
13-
<Content Remove="EndToEndTestApp/**" />
14-
<EmbeddedResource Remove="EndToEndTestApp/**" />
15-
<None Remove="EndToEndTestApp/**" />
16-
</ItemGroup>
17-
188
<ItemGroup>
199
<Compile Include="..\System.CommandLine.Suggest\DotnetMuxer.cs" Link="DotnetMuxer.cs" />
2010
</ItemGroup>
2111

2212
<ItemGroup>
2313
<PackageReference Include="FluentAssertions" Version="5.10.3" />
2414
</ItemGroup>
25-
26-
<ItemGroup Condition="'$(DisableArcade)' == '1'">
27-
<PackageReference Include="xunit" Version="2.4.1" />
28-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
29-
<PrivateAssets>all</PrivateAssets>
30-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
31-
</PackageReference>
32-
</ItemGroup>
3315

3416
<ItemGroup>
3517
<ProjectReference Include="..\System.CommandLine.Suggest\dotnet-suggest.csproj" />
3618
<ProjectReference Include="..\System.CommandLine.Tests\System.CommandLine.Tests.csproj" />
3719
</ItemGroup>
3820

3921
<Target Name="DotnetSuggestIntegrationTestAssets" BeforeTargets="Build" Condition="'$(Configuration)' == 'Release'">
22+
<PropertyGroup>
23+
<TestAssetsPath>$([System.IO.Path]::GetFullPath('$(OutputPath)'))/TestAssets</TestAssetsPath>
24+
</PropertyGroup>
4025

41-
<PropertyGroup>
42-
<TestAssetsPath>
43-
$([System.IO.Path]::GetFullPath('$(OutputPath)'))/TestAssets
44-
</TestAssetsPath>
45-
</PropertyGroup>
46-
47-
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
48-
<Rid>win-x64</Rid>
49-
</PropertyGroup>
26+
<PropertyGroup Condition="'$(OS)' == 'Windows_NT'">
27+
<Rid>win-x64</Rid>
28+
</PropertyGroup>
5029

51-
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
52-
<Rid>osx-x64</Rid>
53-
</PropertyGroup>
30+
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">
31+
<Rid>osx-x64</Rid>
32+
</PropertyGroup>
5433

55-
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
56-
<Rid>linux-x64</Rid>
57-
</PropertyGroup>
34+
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">
35+
<Rid>linux-x64</Rid>
36+
</PropertyGroup>
5837

59-
<MSBuild BuildInParallel="False" Projects="../System.CommandLine.Suggest/dotnet-suggest.csproj" Targets="Restore" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);ForceRestoreToEvaluateSeparately=1;Configuration=Release">
60-
</MSBuild>
38+
<MSBuild BuildInParallel="False" Projects="../System.CommandLine.Suggest/dotnet-suggest.csproj" Targets="Restore" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);ForceRestoreToEvaluateSeparately=1;Configuration=Release" />
6139

62-
<MSBuild BuildInParallel="False" Projects="../System.CommandLine.Suggest/dotnet-suggest.csproj" Targets="Build;Publish" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);PublishDir=$(TestAssetsPath);Configuration=Release">
63-
</MSBuild>
64-
65-
<MSBuild BuildInParallel="False" Projects="EndToEndTestApp/EndToEndTestApp.csproj" Targets="Restore" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);ForceRestoreToEvaluateSeparately=1;Configuration=Release">
66-
</MSBuild>
40+
<MSBuild BuildInParallel="False" Projects="../System.CommandLine.Suggest/dotnet-suggest.csproj" Targets="Build;Publish" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);PublishDir=$(TestAssetsPath);Configuration=Release" />
41+
42+
<MSBuild BuildInParallel="False" Projects="EndToEndTestApp/EndToEndTestApp.csproj" Targets="Restore" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);ForceRestoreToEvaluateSeparately=1;Configuration=Release" />
6743

68-
<MSBuild BuildInParallel="False" Projects="EndToEndTestApp/EndToEndTestApp.csproj" Targets="Build;Publish" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);PublishDir=$(TestAssetsPath);Configuration=Release">
69-
</MSBuild>
70-
71-
</Target>
44+
<MSBuild BuildInParallel="False" Projects="EndToEndTestApp/EndToEndTestApp.csproj" Targets="Build;Publish" Properties="UseAppHost=true;SelfContained=false;RuntimeIdentifier=$(Rid);PublishDir=$(TestAssetsPath);Configuration=Release" />
45+
</Target>
7246

7347
</Project>

src/System.CommandLine.Suggest/dotnet-suggest.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<OutputType>Exe</OutputType>
45
<TargetFramework>$(TargetFrameworkForNETSDK)</TargetFramework>
@@ -19,10 +20,7 @@
1920
<!--No warning for the scripts, it is part of the content, not to execuate-->
2021
<NoWarn>$(NoWarn);NU5110;NU5111;</NoWarn>
2122
</PropertyGroup>
22-
23-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
24-
<DefineConstants>DEBUG;TRACE</DefineConstants>
25-
</PropertyGroup>
23+
2624

2725
<ItemGroup>
2826
<ProjectReference Include="..\System.CommandLine\System.CommandLine.csproj" />
@@ -49,4 +47,5 @@
4947
<FileVersion></FileVersion>
5048
</PropertyGroup>
5149
</Target>
50+
5251
</Project>

0 commit comments

Comments
 (0)