Skip to content

Commit c01cbed

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 c98af89 commit c01cbed

File tree

9 files changed

+99
-348
lines changed

9 files changed

+99
-348
lines changed

Runtime.msbuild

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,17 @@
102102
<Target Name="RunTests" DependsOnTargets="CheckSkipStrongNames">
103103
<ItemGroup>
104104
<_TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.dll" />
105-
<_TestDLLsXunit Include="bin\$(Configuration)\test\*.Test.*.dll" />
106-
<_TestDLLsXunit Include="bin\$(Configuration)\Test\NetCore\*.Test.dll" Condition="'$(BuildPortable)' == 'true'" />
105+
<_TestDLLsXunit Include="bin\$(Configuration)\test\*\net4*\*.Test.dll" Condition="'$(BuildPortable)' == 'true'" />
107106
<_XunitProject Include="tools\WebStack.xunit.targets">
108107
<Properties>TestAssembly=%(_TestDLLsXunit.FullPath);XmlPath=$(TestResultsDirectory)%(_TestDLLsXunit.FileName)-XunitResults.xml</Properties>
109108
</_XunitProject>
109+
110+
<_VSTestDLLs Include="bin\$(Configuration)\test\*\netcoreapp*\*.Test.dll" />
111+
</ItemGroup>
112+
<ItemGroup>
113+
<_VSTestDLLs>
114+
<TestResultsPath>$(TestResultsDirectory)%(FileName)-NetCoreApp-XunitResults.xml</TestResultsPath>
115+
</_VSTestDLLs>
110116
</ItemGroup>
111117

112118
<!-- Recreate the test results directory so that print summary doesn't run on old test results. -->
@@ -117,12 +123,11 @@
117123
<Output TaskParameter="TargetOutputs" ItemName="_ExitCodes" />
118124
</MSBuild>
119125

120-
<!-- Failures in this project will fail build. But, results will not be included in test run summary. -->
121-
<MSBuild
122-
Properties="Configuration=$(Configuration)"
123-
Projects="test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj"
124-
Targets="Test"
125-
Condition="'$(BuildPortable)' == 'true'" />
126+
<Exec Command="dotnet vstest @(_VSTestDLLs) --logger:&quot;xunit;LogFilePath=%(_VSTestDLLs.TestResultsPath)&quot;"
127+
Condition=" '$(BuildPortable)' == 'true' "
128+
IgnoreExitCode="true">
129+
<Output TaskParameter="ExitCode" ItemName="_VSTestErrorCode" />
130+
</Exec>
126131
</Target>
127132

128133
<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.2.3.1\**\xunit.runner.msbuild.props" />
3+
<Import Project="..\packages\xunit.runner.msbuild.2.3.1\**\xunit.runner.msbuild.props"
4+
Condition="$(IsTestProject) and '$(MSBuildRuntimeType)' != 'Core' and '$(TargetFrameworkIdentifier)' == '.NETFramework'" />
45

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

test/System.Net.Http.Formatting.NetCore.Test/System.Net.Http.Formatting.NetCore.Test.csproj

Lines changed: 73 additions & 305 deletions
Large diffs are not rendered by default.

test/System.Net.Http.Formatting.NetCore.Test/app.config

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/System.Net.Http.Formatting.NetCore.Test/packages.config

Lines changed: 0 additions & 17 deletions
This file was deleted.

test/System.Net.Http.Formatting.NetStandard.Test/System.Net.Http.Formatting.NetStandard.Test.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>
55
<RootNamespace>System.Net.Http</RootNamespace>
66
<AssemblyName>System.Net.Http.Formatting.NetStandard.Test</AssemblyName>
7-
<OutputPath>..\..\bin\$(Configuration)\Test\</OutputPath>
7+
<OutputPath>..\..\bin\$(Configuration)\Test\NetStandard\</OutputPath>
88
<Configurations>$(Configurations);CodeAnalysis</Configurations>
99
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
10+
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1011
</PropertyGroup>
1112
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
1214
<PackageReference Include="Moq" Version="4.7.142.0" />
1315
<PackageReference Include="xunit" Version="2.3.0" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
19+
</PackageReference>
20+
<PackageReference Include="XunitXml.TestLogger" Version="3.0.70" />
1521
</ItemGroup>
1622
<ItemGroup>
1723
<Compile Include="..\System.Net.Http.Formatting.Test\**\*.cs" Exclude="..\System.Net.Http.Formatting.Test\obj\**\*.cs">

0 commit comments

Comments
 (0)