diff --git a/build.cmd b/build.cmd
index 500eb973..6b591d1d 100644
--- a/build.cmd
+++ b/build.cmd
@@ -1,5 +1,4 @@
@echo off
-pushd %~dp0
setlocal
if exist bin goto Build
@@ -29,7 +28,7 @@ for /f "usebackq tokens=*" %%i in (`%vswhere% -version 16 -latest -prerelease -p
-requires Microsoft.Net.Component.4.5.2.TargetingPack ^
-requires Microsoft.Net.Component.4.6.2.TargetingPack ^
-property installationPath`) do (
- set InstallDir="%%i"
+ set "InstallDir=%%i"
)
if not DEFINED InstallDir (
@@ -38,35 +37,53 @@ if not DEFINED InstallDir (
goto BuildFail
)
-REM Find or install MSBuild. Need v17.4 due to our .NET SDK choice.
+REM Find a 64bit MSBuild and add it to path. Require v17.4 or later due to our .NET SDK choice.
+REM Check for VS2022 first.
+set InstallDir=
+for /f "usebackq tokens=*" %%i in (`%vswhere% -version 17.4 -latest -prerelease -products * ^
+ -requires Microsoft.Component.MSBuild ^
+ -property installationPath`) do (
+ set "InstallDir=%%i"
+)
+
+if DEFINED InstallDir (
+ REM Add MSBuild to the path.
+ set "PATH=%InstallDir%\MSBuild\Current\Bin;%PATH%"
+ goto FoundMSBuild
+)
+
+REM Otherwise find or install an xcopy-able MSBuild.
+echo "Could not find a VS2022 installation with the necessary components (MSBuild). Falling back..."
+
set "MSBuildVersion=17.4.1"
set "Command=[System.Threading.Thread]::CurrentThread.CurrentCulture = ''"
set "Command=%Command%; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''"
set "Command=%Command%; try { & '%~dp0eng\GetXCopyMSBuild.ps1' %MSBuildVersion%; exit $LASTEXITCODE }"
set "Command=%Command% catch { write-host $_; exit 1 }"
-PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "%Command%"
+PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "%Command%"
if %ERRORLEVEL% neq 0 goto BuildFail
REM Add MSBuild to the path.
-set "PATH=%CD%\.msbuild\%MSBuildVersion%\tools\MSBuild\Current\Bin\;%PATH%"
+set "PATH=%~dp0.msbuild\%MSBuildVersion%\tools\MSBuild\Current\Bin;%PATH%"
+:FoundMSBuild
REM Configure NuGet operations to work w/in this repo i.e. do not pollute system packages folder.
REM Note this causes two copies of packages restored using packages.config to land in this folder e.g.
REM StyleCpy.5.0.0/ and stylecop/5.0.0/.
-set "NUGET_PACKAGES=%CD%\packages"
+set "NUGET_PACKAGES=%~dp0packages"
REM Are we running in a local dev environment (not on CI)?
if DEFINED CI (set Desktop=false) else if DEFINED TEAMCITY_VERSION (set Desktop=false) else (set Desktop=true)
if "%1" == "" goto BuildDefaults
-MSBuild Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
+MSBuild "%~dp0Runtime.msbuild" /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary /t:%*
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess
:BuildDefaults
-MSBuild Runtime.msbuild /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
+MSBuild "%~dp0Runtime.msbuild" /m /nr:false /p:Platform="Any CPU" /p:Desktop=%Desktop% /v:M ^
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary
if %ERRORLEVEL% neq 0 goto BuildFail
goto BuildSuccess
@@ -74,13 +91,11 @@ goto BuildSuccess
:BuildFail
echo.
echo *** BUILD FAILED ***
-popd
endlocal
exit /B 999
:BuildSuccess
echo.
echo **** BUILD SUCCESSFUL ***
-popd
endlocal
exit /B 0
diff --git a/eng/GetXCopyMSBuild.ps1 b/eng/GetXCopyMSBuild.ps1
index 6ab853c3..66783928 100644
--- a/eng/GetXCopyMSBuild.ps1
+++ b/eng/GetXCopyMSBuild.ps1
@@ -39,4 +39,5 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install, [string
return Join-Path $packageDir 'tools'
}
-InitializeXCopyMSBuild -packageVersion $Version -install $true -ToolsDir (join-path $PWD .msbuild)
+$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\')
+InitializeXCopyMSBuild -packageVersion $Version -install $true -ToolsDir (join-path $RepoRoot .msbuild)
diff --git a/src/System.Net.Http.Formatting/GlobalSuppressions.cs b/src/System.Net.Http.Formatting/GlobalSuppressions.cs
index deefc565..d815e56e 100644
--- a/src/System.Net.Http.Formatting/GlobalSuppressions.cs
+++ b/src/System.Net.Http.Formatting/GlobalSuppressions.cs
@@ -6,3 +6,5 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Net.Http.Headers", Justification = "We follow the layout of System.Net.Http.")]
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "System.Net.Http.Handlers", Justification = "Handlers provide an extensibility hook which we want to keep in a separate namespace.")]
+// Some resources are specific to the netstandard1.3 assembly
+[assembly: SuppressMessage("Microsoft.Web.FxCop", "MW1000:UnusedResourceUsageRule", Justification = "There are a few unused resources due to missing netstandard1.3 features.")]
diff --git a/src/System.Net.Http.Formatting/Properties/Resources.resx b/src/System.Net.Http.Formatting/Properties/Resources.resx
index ef5c4a7d..82d90e68 100644
--- a/src/System.Net.Http.Formatting/Properties/Resources.resx
+++ b/src/System.Net.Http.Formatting/Properties/Resources.resx
@@ -358,9 +358,9 @@
Cannot access a closed stream.
- Unable to validate types on this platform when {0} is 'true'. Please reset {0} or move to a supported platform, one where the 'netstandard2.0' assembly is usable.
+ Unable to validate types on this platform when {0} is 'true'. Please reset {0} or move to a supported platform, one where the .NET Standard 2.0 assembly is usable.
- Unable to validate types on this platform when {0} is 'false'. Please set {0} or move to a supported platform, one where the 'netstandard2.0' assembly is usable.
+ Unable to validate types on this platform when {0} is 'false'. Please set {0} or move to a supported platform, one where the .NET Standard 2.0 assembly is usable.
\ No newline at end of file
diff --git a/test/Microsoft.TestCommon/PortReserver.cs b/test/Microsoft.TestCommon/PortReserver.cs
index f085399a..bfa95d61 100644
--- a/test/Microsoft.TestCommon/PortReserver.cs
+++ b/test/Microsoft.TestCommon/PortReserver.cs
@@ -12,6 +12,11 @@ using System.Threading;
namespace Microsoft.TestCommon
{
+ [Xunit.CollectionDefinition("PortReserver Collection", DisableParallelization = true)]
+ public class PortReserverCollection
+ {
+ }
+
///
/// This class allocates ports while ensuring that:
/// 1. Ports that are permanently taken (or taken for the duration of the test) are not being attempted to be used.
diff --git a/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs
index 7ad93ee2..b94b1959 100644
--- a/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs
+++ b/test/System.Net.Http.Formatting.Test/Formatting/DataContractJsonMediaTypeFormatterTests.cs
@@ -193,7 +193,7 @@ namespace System.Net.Http.Formatting
formatter.ReadFromStreamAsync(variationType, stream, content, formatterLogger: null),
"Unable to validate types on this platform when UseDataContractJsonSerializer is 'true'. " +
"Please reset UseDataContractJsonSerializer or move to a supported platform, one where the " +
- "'netstandard2.0' assembly is usable.");
+ ".NET Standard 2.0 assembly is usable.");
}
}
@@ -211,7 +211,7 @@ namespace System.Net.Http.Formatting
formatter.WriteToStreamAsync(variationType, testData, stream, content, transportContext: null),
"Unable to validate types on this platform when UseDataContractJsonSerializer is 'true'. " +
"Please reset UseDataContractJsonSerializer or move to a supported platform, one where the " +
- "'netstandard2.0' assembly is usable.");
+ ".NET Standard 2.0 assembly is usable.");
}
#else
diff --git a/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs b/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs
index c83f687e..8dd69fe1 100644
--- a/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs
+++ b/test/System.Net.Http.Formatting.Test/Formatting/XmlMediaTypeFormatterTests.cs
@@ -516,7 +516,7 @@ namespace System.Net.Http.Formatting
await Assert.ThrowsAsync(() =>
formatter.ReadFromStreamAsync(variationType, stream, content, formatterLogger: null),
"Unable to validate types on this platform when UseXmlSerializer is 'false'. Please set " +
- "UseXmlSerializer or move to a supported platform, one where the 'netstandard2.0' assembly " +
+ "UseXmlSerializer or move to a supported platform, one where the .NET Standard 2.0 assembly " +
"is usable.");
}
}
@@ -534,7 +534,7 @@ namespace System.Net.Http.Formatting
await Assert.ThrowsAsync(() =>
formatter.WriteToStreamAsync(variationType, testData, stream, content, transportContext: null),
"Unable to validate types on this platform when UseXmlSerializer is 'false'. Please set " +
- "UseXmlSerializer or move to a supported platform, one where the 'netstandard2.0' assembly " +
+ "UseXmlSerializer or move to a supported platform, one where the .NET Standard 2.0 assembly " +
"is usable.");
}
diff --git a/test/System.Web.Http.Owin.Test/OwinHostIntegrationTest.cs b/test/System.Web.Http.Owin.Test/OwinHostIntegrationTest.cs
index 17e2d15d..1300d1fd 100644
--- a/test/System.Web.Http.Owin.Test/OwinHostIntegrationTest.cs
+++ b/test/System.Web.Http.Owin.Test/OwinHostIntegrationTest.cs
@@ -12,6 +12,7 @@ using Owin;
namespace System.Web.Http.Owin
{
+ [Xunit.Collection("PortReserver Collection")] // Avoid conflicts between different PortReserver consumers.
public class OwinHostIntegrationTest
{
[Fact]
diff --git a/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs b/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs
index 0b2a5739..85cde946 100644
--- a/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs
+++ b/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs
@@ -10,6 +10,7 @@ using Microsoft.TestCommon;
namespace System.Web.Http
{
+ [Xunit.Collection("PortReserver Collection")] // Avoid conflicts between different PortReserver consumers.
public class BasicOverHttpTest
{
[Fact]
diff --git a/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs b/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs
index bb192b92..8a891905 100644
--- a/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs
+++ b/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs
@@ -12,6 +12,7 @@ using Microsoft.TestCommon;
namespace System.Web.Http.SelfHost
{
+ [Xunit.Collection("PortReserver Collection")] // Avoid conflicts between different PortReserver consumers.
public class HttpSelfHostResponseTest
{
[Fact]
diff --git a/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs b/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs
index afd3b77c..a53f4ba3 100644
--- a/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs
+++ b/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs
@@ -18,6 +18,7 @@ using Microsoft.TestCommon;
namespace System.Web.Http.SelfHost
{
+ [Xunit.Collection("PortReserver Collection")] // Avoid conflicts between different PortReserver consumers.
public class HttpSelfHostServerTest : IDisposable
{
private HttpSelfHostServer server = null;