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
This commit is contained in:
Родитель
f09883601d
Коммит
634c9d2863
|
@ -3,5 +3,5 @@
|
|||
<package id="Microsoft.Web.SkipStrongNames" version="1.0.0" />
|
||||
<package id="Microsoft.Web.StyleCop" version="1.0.0" />
|
||||
<package id="StyleCop" version="5.0.0" />
|
||||
<package id="xunit.runner.msbuild" version="2.2.0-beta2-build3300" targetFramework="net45" />
|
||||
<package id="xunit.runner.msbuild" version="2.3.1-rc2-build3844" targetFramework="net452" />
|
||||
</packages>
|
|
@ -0,0 +1,8 @@
|
|||
<Project>
|
||||
<!-- Also stop MsBuild searching parent directories for this file. -->
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Require VS2017 so VS builds also use MSBuild v15.0. -->
|
||||
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,3 @@
|
|||
<Project>
|
||||
<!-- Stop MsBuild searching parent directories for this file. -->
|
||||
</Project>
|
|
@ -11,6 +11,7 @@
|
|||
<BuildPortable Condition=" '$(BuildPortable)' == '' ">true</BuildPortable>
|
||||
<BuildInParallel Condition=" '$(BuildInParallel)' == '' And $(MSBuildNodeCount) > 1 ">true</BuildInParallel>
|
||||
<BuildInParallel Condition=" '$(BuildInParallel)' == '' ">false</BuildInParallel>
|
||||
<TestInParallel Condition=" '$(TestInParallel)' == '' ">$(BuildInParallel)</TestInParallel>
|
||||
<TestResultsDirectory>$(MSBuildThisFileDirectory)bin\$(Configuration)\test\TestResults\</TestResultsDirectory>
|
||||
<SkipStrongNamesExe>$(MSBuildThisFileDirectory)packages\Microsoft.Web.SkipStrongNames.1.0.0\tools\SkipStrongNames.exe</SkipStrongNamesExe>
|
||||
<SkipStrongNamesXml>$(MSBuildThisFileDirectory)tools\SkipStrongNames.xml</SkipStrongNamesXml>
|
||||
|
@ -107,7 +108,7 @@
|
|||
<RemoveDir Directories="$(TestResultsDirectory)" />
|
||||
<MakeDir Directories="$(TestResultsDirectory)" />
|
||||
|
||||
<MSBuild Projects="@(XunitProject)" BuildInParallel="$(BuildInParallel)" Targets="Xunit" />
|
||||
<MSBuild Projects="@(XunitProject)" BuildInParallel="$(TestInParallel)" Targets="Xunit" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CheckSkipStrongNames" DependsOnTargets="RestoreSkipStrongNames">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30501.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27016.1
|
||||
MinimumVisualStudioVersion = 15.0
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C40883CD-366D-4534-8B58-3EA0D13136DF}"
|
||||
|
@ -476,4 +476,7 @@ Global
|
|||
{821A136C-7C6F-44C6-A9E6-C39B5BFB1483} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{C3BEF382-C7C4-454D-B017-1EAC03E9A82C} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A855CFDC-9BEE-43A9-A3EA-4C4624A747DB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27019.1
|
||||
MinimumVisualStudioVersion = 15.0
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}"
|
||||
EndProject
|
||||
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.
|
|||
EndProject
|
||||
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}"
|
||||
EndProject
|
||||
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}"
|
||||
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}"
|
||||
EndProject
|
||||
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}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A72045D4-B048-4697-9535-C3A6EDCA85B9}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
global.json = global.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CodeAnalysis|Any CPU = CodeAnalysis|Any CPU
|
||||
|
@ -57,10 +64,13 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{FCCC4CB7-BAF7-4A57-9F89-E5766FE536C0} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{C7060639-719B-4BD2-8A37-2F146B5A0668} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{8DA61DAC-FF7E-4CA1-93A0-6148DB66FD08} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
{636CA76A-C85C-42E2-B4AA-88046279B3CA} = {A9836F9E-6DB3-4D9F-ADCA-CF42D8C8BA93}
|
||||
{DECB05DF-B33A-44A0-B5DE-B14A8CE0740F} = {C40883CD-366D-4534-8B58-3EA0D13136DF}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {2A542E86-4A12-4997-B307-DEA9C7EE6539}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27016.1
|
||||
MinimumVisualStudioVersion = 15.0
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Web.FxCop", "tools\src\Microsoft.Web.FxCop\Microsoft.Web.FxCop.csproj", "{F439D4E6-3FAC-4C30-9585-6D258133A2BF}"
|
||||
EndProject
|
||||
Global
|
||||
|
@ -19,4 +19,7 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F8728741-0321-4EF6-9359-7DF2DCE6E99E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
45
build.cmd
45
build.cmd
|
@ -7,13 +7,34 @@ mkdir bin
|
|||
|
||||
:Build
|
||||
|
||||
REM Find the most recent 32bit MSBuild.exe on the system. Require v12.0 (installed with VS2013) or later since .NET 4.0
|
||||
REM is not supported. Also handle x86 operating systems, where %ProgramFiles(x86)% is not defined. Always quote the
|
||||
REM %MSBuild% value when setting the variable and never quote %MSBuild% references.
|
||||
set MSBuild="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
|
||||
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
|
||||
if not exist %MSBuild% @set MSBuild="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
|
||||
if not exist %MSBuild% @set MSBuild="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
|
||||
REM Find the most recent 32bit MSBuild.exe on the system. Require v15.0 (installed with VS2017) or later since .NET
|
||||
REM Core projects are coming soon.
|
||||
REM Use `vswhere` for the search since %ProgramFiles(x86)%\msbuild\15.0\Bin\MSBuild.exe almost never exists.
|
||||
set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if not exist %vswhere% (
|
||||
set VsWhere="%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
)
|
||||
if not exist %vswhere% (
|
||||
REM vswhere.exe not in normal locations; check the Path.
|
||||
for %%X in (vswhere.exe) do (
|
||||
set vswhere="%%~$PATH:X"
|
||||
)
|
||||
)
|
||||
if not exist %vswhere% (
|
||||
echo Could not find vswhere.exe. Please run this from a Visual Studio developer prompt.
|
||||
goto BuildFail
|
||||
)
|
||||
|
||||
set InstallDir=
|
||||
for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -prerelease -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
|
||||
set InstallDir=%%i
|
||||
)
|
||||
if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
|
||||
set MSBuild="%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe"
|
||||
) else (
|
||||
echo Could not find MSBuild.exe. Please install the VS2017 BuildTools component or a workload that includes it.
|
||||
goto BuildFail
|
||||
)
|
||||
|
||||
if "%1" == "" goto BuildDefaults
|
||||
|
||||
|
@ -22,20 +43,20 @@ if %ERRORLEVEL% neq 0 goto BuildFail
|
|||
goto BuildSuccess
|
||||
|
||||
:BuildDefaults
|
||||
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=detailed
|
||||
%MSBuild% Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=true /v:M /fl /flp:LogFile=bin\msbuild.log;Verbosity=Normal
|
||||
if %ERRORLEVEL% neq 0 goto BuildFail
|
||||
goto BuildSuccess
|
||||
|
||||
:BuildFail
|
||||
echo.
|
||||
echo *** BUILD FAILED ***
|
||||
goto End
|
||||
popd
|
||||
endlocal
|
||||
exit /B 999
|
||||
|
||||
:BuildSuccess
|
||||
echo.
|
||||
echo **** BUILD SUCCESSFUL ***
|
||||
goto end
|
||||
|
||||
:End
|
||||
popd
|
||||
endlocal
|
||||
exit /B 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "1.0.4"
|
||||
"version": "2.0.0"
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT</DefineConstants>
|
||||
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,24 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Runtime.sln))\tools\WebStack.settings.targets" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{636CA76A-C85C-42E2-B4AA-88046279B3CA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<TargetFramework>netstandard1.1</TargetFramework>
|
||||
<RootNamespace>System.Net.Http</RootNamespace>
|
||||
<AssemblyName>System.Net.Http.Formatting</AssemblyName>
|
||||
<OutputPath>$(OutputPath)NetStandard\</OutputPath>
|
||||
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
|
||||
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
|
||||
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
|
||||
<CodeAnalysisRuleSet>..\Strict.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisAdditionalOptions> /assemblycomparemode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
|
||||
<CodeAnalysisSearchGlobalAssemblyCache>false</CodeAnalysisSearchGlobalAssemblyCache>
|
||||
<DefineConstants>$(DefineConstants);NETFX_CORE;ASPNETMVC;NOT_CLS_COMPLIANT;NETSTANDARD1_1</DefineConstants>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
||||
<NoWarn>1591</NoWarn>
|
||||
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion></TargetFrameworkVersion>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<Configurations>$(Configurations);CodeAnalysis</Configurations>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="System.ComponentModel.EventBasedAsync" Version="4.0.11" />
|
||||
<PackageReference Include="System.Diagnostics.Contracts" Version="4.0.1" />
|
||||
<PackageReference Include="System.Runtime.Serialization.Xml" Version="4.1.1" />
|
||||
<PackageReference Include="System.Xml.XmlSerializer" Version="4.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>Properties\CommonAssemblyInfo.cs</Link>
|
||||
|
@ -256,9 +264,4 @@
|
|||
<Link>CodeAnalysisDictionary.xml</Link>
|
||||
</CodeAnalysisDictionary>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="project.json" />
|
||||
<None Include="project.lock.json" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"supports": {},
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.6.0",
|
||||
"Newtonsoft.Json": "9.0.1",
|
||||
"System.ComponentModel.EventBasedAsync": "4.0.11",
|
||||
"System.Diagnostics.Contracts": "4.0.1",
|
||||
"System.Runtime.Serialization.Xml": "4.1.1",
|
||||
"System.Xml.XmlSerializer": "4.0.11"
|
||||
},
|
||||
"frameworks": {
|
||||
"netstandard1.1": {}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,5 @@
|
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\..\tools\WebStack.tasks.targets"/>
|
||||
<PropertyGroup>
|
||||
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll</CodeTaskFactoryAssemblyFile>
|
||||
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' And '$(MSBuildToolsVersion)' != '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll</CodeTaskFactoryAssemblyFile>
|
||||
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</CodeTaskFactoryAssemblyFile>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' == '14.0' ">Microsoft.Build.Tasks.Core</BuildTaskAssemblyReference>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And '$(MSBuildToolsVersion)' != '' ">Microsoft.Build.Tasks.v$(MSBuildToolsVersion)</BuildTaskAssemblyReference>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' ">Microsoft.Build.Tasks.v4.0</BuildTaskAssemblyReference>
|
||||
</PropertyGroup>
|
||||
<UsingTask TaskName="NuGetPack" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
|
||||
<ParameterGroup>
|
||||
<NuGetExe ParameterType="System.String" Required="true" />
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<Project>
|
||||
<Import Project="..\Directory.Build.targets"/>
|
||||
<Import Project="..\packages\**\xunit.runner.msbuild.props"/>
|
||||
|
||||
<Target Name="Test">
|
||||
<ItemGroup Condition=" '@(TestAssembly)' == '' ">
|
||||
<TestAssembly Include="$(TargetPath)"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Override AppDomains default (set in xunit.runner.json). Need them with this runner. -->
|
||||
<xunit AppDomains="true" Assemblies="@(TestAssembly)"/>
|
||||
</Target>
|
||||
</Project>
|
|
@ -13,11 +13,12 @@ namespace System.Web.WebPages.Test
|
|||
public class CultureUtilTest
|
||||
{
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureWithNoUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(null);
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentCulture;
|
||||
|
||||
// Act
|
||||
|
@ -28,11 +29,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureWithNoUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(null);
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentUICulture;
|
||||
|
||||
// Act
|
||||
|
@ -43,11 +45,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureWithEmptyUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(Enumerable.Empty<string>());
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentCulture;
|
||||
|
||||
// Act
|
||||
|
@ -58,11 +61,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureWithEmptyUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(Enumerable.Empty<string>());
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentUICulture;
|
||||
|
||||
// Act
|
||||
|
@ -73,11 +77,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureWithBlankUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { " " });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentCulture;
|
||||
|
||||
// Act
|
||||
|
@ -88,11 +93,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureWithBlankUserLanguagesDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { " " });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentUICulture;
|
||||
|
||||
// Act
|
||||
|
@ -103,12 +109,13 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureWithInvalidLanguageDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
// "sans-culture" is an invalid culture name everywhere -- even on Windows 10.
|
||||
var context = GetContextForSetCulture(new[] { "sans-culture", "bb-BB", "cc-CC" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentCulture;
|
||||
|
||||
// Act
|
||||
|
@ -119,12 +126,13 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureWithInvalidLanguageDoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
// "sans-culture" is an invalid culture name everywhere -- even on Windows 10.
|
||||
var context = GetContextForSetCulture(new[] { "sans-culture", "bb-BB", "cc-CC" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
CultureInfo culture = thread.CurrentUICulture;
|
||||
|
||||
// Act
|
||||
|
@ -135,11 +143,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureDetectsUserLanguageCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { "en-GB", "en-US", "ar-eg" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetCulture(thread, context, "auto");
|
||||
|
@ -150,11 +159,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureDetectsUserLanguageCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { "en-GB", "en-US", "ar-eg" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetUICulture(thread, context, "auto");
|
||||
|
@ -165,11 +175,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoCultureUserLanguageWithQParameterCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { "en-GB;q=0.3", "en-US", "ar-eg;q=0.5" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetCulture(thread, context, "auto");
|
||||
|
@ -180,11 +191,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetAutoUICultureDetectsUserLanguageWithQParameterCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture(new[] { "en-GB;q=0.3", "en-US", "ar-eg;q=0.5" });
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetUICulture(thread, context, "auto");
|
||||
|
@ -195,33 +207,36 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetCultureWithInvalidCultureThrows()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture();
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act and Assert
|
||||
Assert.Throws<CultureNotFoundException>(() => CultureUtil.SetCulture(thread, context, "sans-culture"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetUICultureWithInvalidCultureThrows()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture();
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act and Assert
|
||||
Assert.Throws<CultureNotFoundException>(() => CultureUtil.SetUICulture(thread, context, "sans-culture"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetCultureWithValidCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture();
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetCulture(thread, context, "en-GB");
|
||||
|
@ -232,11 +247,12 @@ namespace System.Web.WebPages.Test
|
|||
}
|
||||
|
||||
[Fact]
|
||||
[ReplaceCulture(Culture = "es-PR", UICulture = "es-PR")]
|
||||
public void SetUICultureWithValidCulture()
|
||||
{
|
||||
// Arrange
|
||||
var context = GetContextForSetCulture();
|
||||
Thread thread = GetThread();
|
||||
Thread thread = Thread.CurrentThread;
|
||||
|
||||
// Act
|
||||
CultureUtil.SetUICulture(thread, context, "en-GB");
|
||||
|
@ -246,11 +262,6 @@ namespace System.Web.WebPages.Test
|
|||
Assert.Equal("05/01/1979", new DateTime(1979, 1, 5).ToString("d", thread.CurrentUICulture));
|
||||
}
|
||||
|
||||
private static Thread GetThread()
|
||||
{
|
||||
return new Thread(() => { });
|
||||
}
|
||||
|
||||
private static HttpContextBase GetContextForSetCulture(IEnumerable<string> userLanguages = null)
|
||||
{
|
||||
Mock<HttpContextBase> contextMock = new Mock<HttpContextBase>();
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
<!-- Use CustomAfterMicrosoftCommonTargets property (defined in Microsoft.Common.targets) to
|
||||
inject post-Common targets files without requiring the inclusion -->
|
||||
<CustomAfterMicrosoftCommonTargets>$(WebStackToolsPath)WebStack.targets</CustomAfterMicrosoftCommonTargets>
|
||||
|
||||
|
||||
<!-- Force rebuild if this file changes -->
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<!-- Project Defaults -->
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<!-- Target 4.5 by default -->
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
|
||||
<!-- Disable C# 6.0 features in Visual Studio since those features are not always available in command-line builds. -->
|
||||
<!-- Disable C# 6.0 features in Visual Studio. -->
|
||||
<LangVersion Condition=" '$(MSBuildProjectExtension)' == '.csproj' ">5</LangVersion>
|
||||
|
||||
<!-- Everything is delay signed by default -->
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And Exists('$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll') ">Microsoft.Build.Tasks.Core</BuildTaskAssemblyReference>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And Exists('$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll') ">Microsoft.Build.Tasks.v$(MSBuildToolsVersion)</BuildTaskAssemblyReference>
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' And Exists('$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll') ">Microsoft.Build.Tasks.v4.0</BuildTaskAssemblyReference>
|
||||
<!-- Know this file does not exist. But, error message will contain meaningful information. -->
|
||||
<BuildTaskAssemblyReference Condition=" '$(BuildTaskAssemblyReference)' == '' ">Microsoft.Build.Tasks.Core</BuildTaskAssemblyReference>
|
||||
<CodeTaskFactoryAssemblyFile Condition=" '$(CodeTaskFactoryAssemblyFile)' == '' ">$(MSBuildToolsPath)\$(BuildTaskAssemblyReference).dll</CodeTaskFactoryAssemblyFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- This task does not support concurrent execution from multiple project files. Its use is only appropriate when
|
||||
NuGet.exe is not in use. -->
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
|
||||
<ParameterGroup>
|
||||
<OutputFileName ParameterType="System.String" Required="true" />
|
||||
<MinimumVersion ParameterType="System.String" Required="true" />
|
||||
|
@ -17,24 +26,24 @@
|
|||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
Version minimumRequiredVersion;
|
||||
|
||||
|
||||
if (!Version.TryParse(MinimumVersion, out minimumRequiredVersion))
|
||||
{
|
||||
Log.LogError("MinimumVersion '{0}' is not a valid Version.", MinimumVersion);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
OutputFileName = Path.GetFullPath(OutputFileName);
|
||||
|
||||
|
||||
if (File.Exists(OutputFileName))
|
||||
{
|
||||
// If NuGet.exe exists but is less than the minimum required version, delete it so that the
|
||||
// latest version will be downloaded.
|
||||
FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(OutputFileName);
|
||||
|
||||
|
||||
string toParse;
|
||||
|
||||
|
||||
if (versionInfo != null && versionInfo.ProductVersion != null)
|
||||
{
|
||||
toParse = versionInfo.ProductVersion;
|
||||
|
@ -43,10 +52,10 @@
|
|||
{
|
||||
toParse = null;
|
||||
}
|
||||
|
||||
|
||||
Version current;
|
||||
Version parsed;
|
||||
|
||||
|
||||
if (toParse != null && Version.TryParse(toParse, out parsed))
|
||||
{
|
||||
current = parsed;
|
||||
|
@ -56,13 +65,13 @@
|
|||
// Treat a missing or invalid version like V0.0 (which will trigger a delete and download).
|
||||
current = new Version(0, 0);
|
||||
}
|
||||
|
||||
|
||||
if (current < minimumRequiredVersion)
|
||||
{
|
||||
File.Delete(OutputFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!File.Exists(OutputFileName))
|
||||
{
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
|
@ -82,7 +91,7 @@
|
|||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
<UsingTask TaskName="RegexReplace" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<UsingTask TaskName="RegexReplace" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
|
||||
<ParameterGroup>
|
||||
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
|
||||
<Find ParameterType="System.String" Required="true" />
|
||||
|
@ -134,7 +143,7 @@
|
|||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
<UsingTask TaskName="PrintTestRunSummary" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<UsingTask TaskName="PrintTestRunSummary" TaskFactory="CodeTaskFactory" AssemblyFile="$(CodeTaskFactoryAssemblyFile)">
|
||||
<ParameterGroup>
|
||||
<TestResultsDirectory ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
|
@ -178,7 +187,7 @@
|
|||
|
||||
if (failures > 0)
|
||||
{
|
||||
foreach (XElement classWithFailure in assembly.Elements(XName.Get("class"))
|
||||
foreach (XElement classWithFailure in assembly.Elements(XName.Get("collection"))
|
||||
.Where(c => Int32.Parse(c.Attribute(XName.Get("failed")).Value) > 0))
|
||||
{
|
||||
foreach (XElement failure in classWithFailure.Elements(XName.Get("test"))
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
|
||||
<!-- This is a separate MSBuild file so that we can survive upgrades of the xunit NuGet package
|
||||
and also still work with NuGet Package Restore. -->
|
||||
<ItemGroup>
|
||||
<XunitMsBuildRunner Include="..\packages\**\xunit.runner.msbuild.dll"/>
|
||||
</ItemGroup>
|
||||
<UsingTask TaskName="Xunit.Runner.MSBuild.xunit" AssemblyFile="@(XunitMsBuildRunner)"/>
|
||||
<Import Project="..\packages\**\xunit.runner.msbuild.props"/>
|
||||
|
||||
<Target Name="Xunit">
|
||||
<!-- Override AppDomains default (set in xunit.runner.json). Need them with this runner. -->
|
||||
<xunit AppDomains="true" Assemblies="$(TestAssembly)" XmlV1="$(XmlPath)"/>
|
||||
<!-- Replace potentially illegal escaped characters (if they get through validations done during Save) -->
|
||||
<xunit AppDomains="true" Assemblies="$(TestAssembly)" Xml="$(XmlPath)"/>
|
||||
|
||||
<!-- Replace potentially illegal escaped characters (if they get through validations done during Save). -->
|
||||
<RegexReplace
|
||||
Files="$(XmlPath)"
|
||||
Find="&#x(?<char>[0-9A-Fa-f]+);"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<FxCopLocation>$(MSBuildProgramFiles32)\Microsoft Visual Studio $(VisualStudioVersion)\Team Tools\Static Analysis Tools\FxCop\</FxCopLocation>
|
||||
<FxCopLocation>$(VsInstallRoot)\Team Tools\Static Analysis Tools\FxCop\</FxCopLocation>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FxCopSdk">
|
||||
|
|
Загрузка…
Ссылка в новой задаче