Skip to content

Commit 634c9d2

Browse files
committed
Move to MSBuild v15.0 and latest xUnit MSBuild runner
- change `CultureUtilTest` to use `Thread.CurrentThread` - when hosted in latest MSBuild, changing `thread.CurrentThread` changes `Thread.CurrentThread` instead - find current Microsoft.Build.Tasks assembly in WebStack.tasks.targets, not just the WebApiHelpPage project - add `$(TestInParallel)` - allows user to e.g. build in parallel but test assemblies serially - default remains doing everything in parallel - change build.cmd to set %ErrorLevel% when exiting - add empty top-level Directory.Build.* files Use only VS 2017 or later - ensure same MSBuild features are available in command-line and VS builds - move `$(MinimumVisualStudioVersion)` project settings to global location and bump required version up Use Microsoft.NET.Sdk and `<PackageReference/>`s in .NET Standard project - create a "real" .NET Standard 1.1 assembly, not .NET Portable v5.0 Move to latest version of the xUnit MSBuild runner - v2.3.0 has a few bugs related to XML results files e.g. xunit/xunit#1515 - switch to current XML results format (required with v2.3.0 but doesn't hurt with later versions) - make runner discovery version-independent - add support for `msbuild /t:test` in test project directories
1 parent f098836 commit 634c9d2

19 files changed

+165
-105
lines changed

.nuget/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
<package id="Microsoft.Web.SkipStrongNames" version="1.0.0" />
44
<package id="Microsoft.Web.StyleCop" version="1.0.0" />
55
<package id="StyleCop" version="5.0.0" />
6-
<package id="xunit.runner.msbuild" version="2.2.0-beta2-build3300" targetFramework="net45" />
6+
<package id="xunit.runner.msbuild" version="2.3.1-rc2-build3844" targetFramework="net452" />
77
</packages>

Directory.Build.props

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<!-- Also stop MsBuild searching parent directories for this file. -->
3+
4+
<PropertyGroup>
5+
<!-- Require VS2017 so VS builds also use MSBuild v15.0. -->
6+
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
7+
</PropertyGroup>
8+
</Project>

Directory.Build.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<!-- Stop MsBuild searching parent directories for this file. -->
3+
</Project>

Runtime.msbuild

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<BuildPortable Condition=" '$(BuildPortable)' == '' ">true</BuildPortable>
1212
<BuildInParallel Condition=" '$(BuildInParallel)' == '' And $(MSBuildNodeCount) &gt; 1 ">true</BuildInParallel>
1313
<BuildInParallel Condition=" '$(BuildInParallel)' == '' ">false</BuildInParallel>
14+
<TestInParallel Condition=" '$(TestInParallel)' == '' ">$(BuildInParallel)</TestInParallel>
1415
<TestResultsDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\test\TestResults\</TestResultsDirectory>
1516
<SkipStrongNamesExe>$(MSBuildThisFileDirectory)packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe>
1617
<SkipStrongNamesXml>$(MSBuildThisFileDirectory)tools\SkipStrongNames.xml</SkipStrongNamesXml>
@@ -107,7 +108,7 @@
107108
<RemoveDir Directories="$(TestResultsDirectory)" />
108109
<MakeDir Directories="$(TestResultsDirectory)" />
109110

110-
<MSBuild Projects="@(XunitProject)" BuildInParallel="$(BuildInParallel)" Targets="Xunit" />
111+
<MSBuild Projects="@(XunitProject)" BuildInParallel="$(TestInParallel)" Targets="Xunit" />
111112
</Target>
112113

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

Runtime.sln

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.30501.0
5-
MinimumVisualStudioVersion = 10.0.40219.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27016.1
5+
MinimumVisualStudioVersion = 15.0
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C40883CD-366D-4534-8B58-3EA0D13136DF}"
@@ -476,4 +476,7 @@ Global
476476
{821A136C-7C6F-44C6-A9E6-C39B5BFB1483} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
477477
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
478478
EndGlobalSection
479+
GlobalSection(ExtensibilityGlobals) = postSolution
480+
SolutionGuid = {A855CFDC-9BEE-43A9-A3EA-4C4624A747DB}
481+
EndGlobalSection
479482
EndGlobal

RuntimePortable.sln

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27019.1
5+
MinimumVisualStudioVersion = 15.0
46
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}"
57
EndProject
68
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C40883CD-366D-4534-8B58-3EA0D13136DF}"
@@ -11,10 +13,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.
1113
EndProject
1214
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}"
1315
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetStandard", "src\System.Net.Http.Formatting.NetStandard\System.Net.Http.Formatting.NetStandard.csproj", "{636CA76A-C85C-42E2-B4AA-88046279B3CA}"
16+
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}"
1517
EndProject
1618
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Net.Http.Formatting.NetStandard.Test", "test\System.Net.Http.Formatting.NetStandard.Test\System.Net.Http.Formatting.NetStandard.Test.csproj", "{DECB05DF-B33A-44A0-B5DE-B14A8CE0740F}"
1719
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A72045D4-B048-4697-9535-C3A6EDCA85B9}"
21+
ProjectSection(SolutionItems) = preProject
22+
global.json = global.json
23+
EndProjectSection
24+
EndProject
1825
Global
1926
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2027
CodeAnalysis|Any CPU = CodeAnalysis|Any CPU
@@ -57,10 +64,13 @@ Global
5764
HideSolutionNode = FALSE
5865
EndGlobalSection
5966
GlobalSection(NestedProjects) = preSolution
60-
{C7060639-719B-4BD2-8A37-2F146B5A0668} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
6167
{FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
68+
{C7060639-719B-4BD2-8A37-2F146B5A0668} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
6269
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
6370
{636CA76A-C85C-42E2-B4AA-88046279B3CA} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
6471
{DECB05DF-B33A-44A0-B5DE-B14A8CE0740F} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
6572
EndGlobalSection
73+
GlobalSection(ExtensibilityGlobals) = postSolution
74+
SolutionGuid = {2A542E86-4A12-4997-B307-DEA9C7EE6539}
75+
EndGlobalSection
6676
EndGlobal

Tools.sln

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
5-
MinimumVisualStudioVersion = 10.0.40219.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27016.1
5+
MinimumVisualStudioVersion = 15.0
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Web.FxCop", "tools\src\Microsoft.Web.FxCop\Microsoft.Web.FxCop.csproj", "{F439D4E6-3FAC-4C30-9585-6D258133A2BF}"
77
EndProject
88
Global
@@ -19,4 +19,7 @@ Global
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {F8728741-0321-4EF6-9359-7DF2DCE6E99E}
24+
EndGlobalSection
2225
EndGlobal

build.cmd

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,34 @@ mkdir bin
77

88
:Build
99

10-
REM Find the most recent 32bit MSBuild.exe on the system. Require v12.0 (installed with VS2013) or later since .NET 4.0
11-
REM is not supported. Also handle x86 operating systems, where %ProgramFiles(x86)% is not defined. Always quote the
12-
REM %MSBuild% value when setting the variable and never quote %MSBuild% references.
13-
set MSBuild="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
14-
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
15-
if not exist %MSBuild% @set MSBuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
16-
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
10+
REM Find the most recent 32bit MSBuild.exe on the system. Require v15.0 (installed with VS2017) or later since .NET
11+
REM Core projects are coming soon.
12+
REM Use `vswhere` for the search since %ProgramFiles(x86)%\msbuild\15.0\Bin\MSBuild.exe almost never exists.
13+
set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
14+
if not exist %vswhere% (
15+
set VsWhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
16+
)
17+
if not exist %vswhere% (
18+
REM vswhere.exe not in normal locations; check the Path.
19+
for %%X in (vswhere.exe) do (
20+
set vswhere="%%~$PATH:X"
21+
)
22+
)
23+
if not exist %vswhere% (
24+
echo Could not find vswhere.exe. Please run this from a Visual Studio developer prompt.
25+
goto BuildFail
26+
)
27+
28+
set InstallDir=
29+
for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -prerelease -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
30+
set InstallDir=%%i
31+
)
32+
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
33+
set MSBuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
34+
) else (
35+
echo Could not find MSBuild.exe. Please install the VS2017 BuildTools component or a workload that includes it.
36+
goto BuildFail
37+
)
1738

1839
if "%1" == "" goto BuildDefaults
1940

@@ -22,20 +43,20 @@ if %ERRORLEVEL% neq 0 goto BuildFail
2243
goto BuildSuccess
2344

2445
:BuildDefaults
25-
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=detailed
46+
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
2647
if %ERRORLEVEL% neq 0 goto BuildFail
2748
goto BuildSuccess
2849

2950
:BuildFail
3051
echo.
3152
echo *** BUILD FAILED ***
32-
goto End
53+
popd
54+
endlocal
55+
exit /B 999
3356

3457
:BuildSuccess
3558
echo.
3659
echo **** BUILD SUCCESSFUL ***
37-
goto end
38-
39-
:End
4060
popd
4161
endlocal
62+
exit /B 0

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "1.0.4"
3+
"version": "2.0.0"
44
}
55
}

src/System.Net.Http.Formatting.NetCore/System.Net.Http.Formatting.NetCore.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT</DefineConstants>
1717
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
1818
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
19-
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
2019
<NoWarn>1591</NoWarn>
2120
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
2221
</PropertyGroup>

src/System.Net.Http.Formatting.NetStandard/System.Net.Http.Formatting.NetStandard.csproj

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
43
<PropertyGroup>
5-
<ProjectGuid>{636CA76A-C85C-42E2-B4AA-88046279B3CA}</ProjectGuid>
6-
<OutputType>Library</OutputType>
7-
<AppDesignerFolder>Properties</AppDesignerFolder>
4+
<TargetFramework>netstandard1.1</TargetFramework>
85
<RootNamespace>System.Net.Http</RootNamespace>
96
<AssemblyName>System.Net.Http.Formatting</AssemblyName>
107
<OutputPath>$(OutputPath)NetStandard\</OutputPath>
118
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
9+
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
1210
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
1311
<CodeAnalysisRuleSet>..\Strict.ruleset</CodeAnalysisRuleSet>
1412
<CodeAnalysisAdditionalOptions> /assemblycomparemode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
1513
<CodeAnalysisSearchGlobalAssemblyCache>false</CodeAnalysisSearchGlobalAssemblyCache>
1614
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT;NETSTANDARD1_1</DefineConstants>
17-
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
18-
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
1915
<NoWarn>1591</NoWarn>
20-
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
16+
<TargetFrameworkVersion></TargetFrameworkVersion>
17+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
18+
<Configurations>$(Configurations);CodeAnalysis</Configurations>
19+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
2120
</PropertyGroup>
21+
22+
<ItemGroup>
23+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
24+
<PackageReference Include="System.ComponentModel.EventBasedAsync" Version="4.0.11" />
25+
<PackageReference Include="System.Diagnostics.Contracts" Version="4.0.1" />
26+
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.1.1" />
27+
<PackageReference Include="System.Xml.XmlSerializer" Version="4.0.11" />
28+
</ItemGroup>
29+
2230
<ItemGroup>
2331
<Compile Include="..\CommonAssemblyInfo.cs">
2432
<Link>Properties\CommonAssemblyInfo.cs</Link>
@@ -256,9 +264,4 @@
256264
<Link>CodeAnalysisDictionary.xml</Link>
257265
</CodeAnalysisDictionary>
258266
</ItemGroup>
259-
<ItemGroup>
260-
<None Include="project.json" />
261-
<None Include="project.lock.json" />
262-
</ItemGroup>
263-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
264-
</Project>
267+
</Project>

src/System.Net.Http.Formatting.NetStandard/project.json

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

src/WebApiHelpPage/WebApiHelpPageMsBuildTasks.targets

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<Import Project="..\..\tools\WebStack.tasks.targets"/>
3-
<PropertyGroup>
4-
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</CodeTaskFactoryAssemblyFile>
5-
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' != '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll</CodeTaskFactoryAssemblyFile>
6-
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskFactoryAssemblyFile>
7-
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">Microsoft.Build.Tasks.Core</BuildTaskAssemblyReference>
8-
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' != '' ">Microsoft.Build.Tasks.v$(MSBuildToolsVersion)</BuildTaskAssemblyReference>
9-
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' ">Microsoft.Build.Tasks.v4.0</BuildTaskAssemblyReference>
10-
</PropertyGroup>
113
<UsingTask TaskName="NuGetPack" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
124
<ParameterGroup>
135
<NuGetExe ParameterType="System.String" Required="true" />

test/Directory.Build.targets

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<Import Project="..\Directory.Build.targets"/>
3+
<Import Project="..\packages\**\xunit.runner.msbuild.props"/>
4+
5+
<Target Name="Test">
6+
<ItemGroup Condition=" '@(TestAssembly)' == '' ">
7+
<TestAssembly Include="$(TargetPath)"/>
8+
</ItemGroup>
9+
10+
<!-- Override AppDomains default (set in xunit.runner.json). Need them with this runner. -->
11+
<xunit AppDomains="true" Assemblies="@(TestAssembly)"/>
12+
</Target>
13+
</Project>

0 commit comments

Comments
 (0)