Skip to content

Commit 0d9acd5

Browse files
committed
Use .NET SDK in NetCore.Test project
- for now, unable to target `netcoreapp2.1` in NetCore.Test project - Microsoft.Net.Http is not compatible - System.Net.Http types have different identities, causing compilation failures - switch to use `dotnet vstest` for any .NET Core assemblies (just one currently) - can use `Xunit` target for all .NET Framework assemblies - make XunitXml.TestLogger available for .NET Core App testing - use above test logger in repo-level testing - integrate w/ tests that use the `Xunit` target - don't import from xunit.msbuild.runner when targeting .NET Core; not needed - add `$(CopyLocalLockFileAssemblies)` to these (now both .NET SDK) test projects - xUnit assemblies were not copied (when they should have been) w/o this
1 parent 2cdd25b commit 0d9acd5

File tree

9 files changed

+103
-360
lines changed

9 files changed

+103
-360
lines changed

Runtime.msbuild

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@
6868
<_NuGetPackagesAndSolutions Include="Runtime.sln" />
6969

7070
<!-- Avoid restoring RuntimePortable.sln directly. -->
71-
<_NuGetPackagesAndSolutions Include="src\System.Net.Http.Formatting.NetCore\packages.config;
72-
test\System.Net.Http.Formatting.NetCore.Test\packages.config"
71+
<_NuGetPackagesAndSolutions Include="src\System.Net.Http.Formatting.NetCore\packages.config"
7372
Condition=" '$(BuildPortable)' == 'true' " />
74-
<_ProjectsToRestore Include="test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
73+
<_ProjectsToRestore Include="
74+
test\System.Net.Http.Formatting.NetCore.Test\System.Net.Http.Formatting.NetCore.Test.csproj;
75+
test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
7576
Condition=" '$(BuildPortable)' == 'true' " />
7677
</ItemGroup>
7778

@@ -114,11 +115,17 @@
114115
<Target Name="RunTests" DependsOnTargets="CheckSkipStrongNames">
115116
<ItemGroup>
116117
<_TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.dll" />
117-
<_TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.*.dll" />
118-
<_TestDLLsXunit Include="bin\$(Configuration)\Test\NetCore\*.Test.dll" Condition="'$(BuildPortable)' == 'true'" />
118+
<_TestDLLsXunit Include="bin\$(Configuration)\test\*\net4*\*.Test.dll" />
119119
<_XunitProject Include="tools\WebStack.xunit.targets">
120120
<Properties>TestAssembly=%(_TestDLLsXunit.FullPath);XmlPath=$(TestResultsDirectory)%(_TestDLLsXunit.FileName)-XunitResults.xml</Properties>
121121
</_XunitProject>
122+
123+
<_VSTestDLLs Include="bin\$(Configuration)\test\*\netcoreapp*\*.Test.dll" />
124+
</ItemGroup>
125+
<ItemGroup>
126+
<_VSTestDLLs>
127+
<TestResultsPath>$(TestResultsDirectory)%(FileName)-NetCoreApp-XunitResults.xml</TestResultsPath>
128+
</_VSTestDLLs>
122129
</ItemGroup>
123130

124131
<!-- Recreate the test results directory so that print summary doesn't run on old test results. -->
@@ -129,12 +136,11 @@
129136
<Output TaskParameter="TargetOutputs" ItemName="_ExitCodes" />
130137
</MSBuild>
131138

132-
<!-- Failures in this project will fail build. But, results will not be included in test run summary. -->
133-
<MSBuild
134-
Properties="Configuration=$(Configuration)"
135-
Projects="test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
136-
Targets="Test"
137-
Condition="'$(BuildPortable)' == 'true'" />
139+
<Exec Command="dotnet vstest @(_VSTestDLLs) --logger:&quot;xunit;LogFilePath=%(_VSTestDLLs.TestResultsPath)&quot;"
140+
Condition=" '$(BuildPortable)' == 'true' "
141+
IgnoreExitCode="true">
142+
<Output TaskParameter="ExitCode" ItemName="_VSTestErrorCode" />
143+
</Exec>
138144
</Target>
139145

140146
<Target Name="CheckSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">

RuntimePortable.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.TestCommon", "tes
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetCore", "src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj", "{C7060639-719B-4BD2-8A37-2F146B5A0668}"
1313
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetCore.Test", "test\System.Net.Http.Formatting.NetCore.Test\System.Net.Http.Formatting.NetCore.Test.csproj", "{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}"
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.Formatting.NetCore.Test", "test\System.Net.Http.Formatting.NetCore.Test\System.Net.Http.Formatting.NetCore.Test.csproj", "{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08}"
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Net.Http.Formatting.NetStandard", "src\System.Net.Http.Formatting.NetStandard\System.Net.Http.Formatting.NetStandard.csproj", "{636CA76A-C85C-42E2-B4AA-88046279B3CA}"
1717
EndProject

packages/repositories.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<repository path="..\test\Microsoft.Web.Helpers.Test\packages.config" />
2222
<repository path="..\test\Microsoft.Web.Mvc.Test\packages.config" />
2323
<repository path="..\test\Microsoft.Web.WebPages.OAuth.Test\packages.config" />
24-
<repository path="..\test\System.Net.Http.Formatting.NetCore.Test\packages.config" />
2524
<repository path="..\test\System.Net.Http.Formatting.Test\packages.config" />
2625
<repository path="..\test\System.Web.Cors.Test\packages.config" />
2726
<repository path="..\test\System.Web.Helpers.Test\packages.config" />

test/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<PropertyGroup>
55
<IsPackable>false</IsPackable>
66
<IsTestProject>true</IsTestProject>
7-
<TargetFrameworkVersion Condition="'$(MSBuildProjectName)' != 'System.Net.Http.Formatting.NetStandard.Test'">v4.5.2</TargetFrameworkVersion>
7+
<TargetFrameworkVersion Condition=" !$(MSBuildProjectName.StartsWith('System.Net.Http.Formatting.Net')) ">v4.5.2</TargetFrameworkVersion>
88
</PropertyGroup>
99
</Project>

test/Directory.Build.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<Import Project="..\Directory.Build.targets" />
3-
<Import Project="..\packages\**\xunit.runner.msbuild.props" />
3+
<Import Project="..\packages\**\xunit.runner.msbuild.props"
4+
Condition="$(IsTestProject) and '$(MSBuildRuntimeType)' != 'Core' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />
45

56
<Target Name="Test" DependsOnTargets="_TestWithVSTest;_TestWithDotnetTest;_TestWithRunner" />
67

0 commit comments

Comments
 (0)