diff --git a/.pipelines/cs-build-steps.yaml b/.pipelines/cs-build-steps.yaml index 284decfa..3624ce15 100644 --- a/.pipelines/cs-build-steps.yaml +++ b/.pipelines/cs-build-steps.yaml @@ -42,7 +42,7 @@ steps: publishTestResults: true arguments: '-v:n -c release -p:CodeCoverage=true --no-build' -- task: PublishCodeCoverageResults@1 +- task: PublishCodeCoverageResults@2 displayName: 'Publish code coverage' inputs: codeCoverageTool: Cobertura diff --git a/cs/build/build.props b/cs/build/build.props index 6da060a8..af08f618 100644 --- a/cs/build/build.props +++ b/cs/build/build.props @@ -28,16 +28,9 @@ true - - - netcoreapp3.1 - netstandard2.1 - netstandard2.1 - - - 7.6.812 + 8.9.3 5.4.1 3.3.0 0.3.0 @@ -45,7 +38,7 @@ 15.8.0 4.9.0 3.6.133 - 4.8.13 + 5.3.9 4.7.2 15.5.31 3.12.5 @@ -95,7 +88,7 @@ true - $(TestResultsDirectory)/$(TestBaseName)-coverage.xml + $(TestResultsDirectory)/$(TestBaseName)-coverage.xml Interop|Test|xunit|AltCover|System.Reactive ThisAssembly|System.Runtime|CodeAnalysis $(TestResultsDirectory)/$(TestBaseName)-lcov.info diff --git a/cs/global.json b/cs/global.json index adf50e1f..2920a09a 100644 --- a/cs/global.json +++ b/cs/global.json @@ -1,5 +1,6 @@ { - "sdk": { - "version": "6.0.412" - } -} \ No newline at end of file + "sdk": { + "version": "8.0.400", + "rollForward": "latestFeature" + } +} diff --git a/cs/src/Connections/DevTunnels.Connections.csproj b/cs/src/Connections/DevTunnels.Connections.csproj index cfba0373..e0745d99 100644 --- a/cs/src/Connections/DevTunnels.Connections.csproj +++ b/cs/src/Connections/DevTunnels.Connections.csproj @@ -3,7 +3,7 @@ Microsoft.DevTunnels.Connections Microsoft.DevTunnels.Connections - netcoreapp3.1;net6.0 + net6.0;net8.0 true true false diff --git a/cs/src/Connections/WebSocketStream.cs b/cs/src/Connections/WebSocketStream.cs index b3ae0739..65d0f3df 100644 --- a/cs/src/Connections/WebSocketStream.cs +++ b/cs/src/Connections/WebSocketStream.cs @@ -102,11 +102,16 @@ public static async Task ConnectToWebSocketAsync(Uri uri, Actio } catch (WebSocketException wse) when (wse.WebSocketErrorCode == WebSocketError.NotAWebSocket) { - // The http request didn't upgrade to a web socket and instead may have returned a status code. + // The http request didn't upgrade to a web socket and instead may have returned an error status code. +#if NET8_0_OR_GREATER + if ((int)socket.HttpStatusCode >= 400) + { + TunnelConnectionException.SetHttpStatusCode(wse, socket.HttpStatusCode); + } +#else + // Socket.HttpStatusCode is not available in older versions of .NET. // As a workaround, check for "'{actual response code}'" pattern in the exception message, // which may look like this: "The server returned status code '403' when status code '101' was expected". - // TODO: switch to ClientWebSocket.HttpStatusCode when we get to .NET CORE 7.0, see https://github.com/dotnet/runtime/issues/25918#issuecomment-1132039238 - int i = wse.Message.IndexOf('\''); if (i >= 0) { @@ -120,10 +125,9 @@ public static async Task ConnectToWebSocketAsync(Uri uri, Actio statusCode != 101) { TunnelConnectionException.SetHttpStatusCode(wse, (HttpStatusCode)statusCode); - socket.Dispose(); - throw wse; } } +#endif socket.Dispose(); throw; diff --git a/cs/src/Contracts/DevTunnels.Contracts.csproj b/cs/src/Contracts/DevTunnels.Contracts.csproj index 3326bd26..882716e1 100644 --- a/cs/src/Contracts/DevTunnels.Contracts.csproj +++ b/cs/src/Contracts/DevTunnels.Contracts.csproj @@ -3,7 +3,7 @@ Microsoft.DevTunnels.Contracts Microsoft.DevTunnels.Contracts - netcoreapp3.1;net6.0 + net6.0;net8.0 true true false diff --git a/cs/src/Directory.Build.targets b/cs/src/Directory.Build.targets index 2e6dbb5e..4b938cae 100644 --- a/cs/src/Directory.Build.targets +++ b/cs/src/Directory.Build.targets @@ -6,9 +6,9 @@ - + @@ -19,7 +19,7 @@ - + Microsoft.DevTunnels.Management Microsoft.DevTunnels.Management - netcoreapp3.1;net6.0 + net6.0;net8.0 true true false @@ -11,8 +11,8 @@ CS1591 - - + + diff --git a/cs/src/Management/TunnelRequestOptions.cs b/cs/src/Management/TunnelRequestOptions.cs index 56acbb2b..e092ed29 100644 --- a/cs/src/Management/TunnelRequestOptions.cs +++ b/cs/src/Management/TunnelRequestOptions.cs @@ -49,8 +49,7 @@ public class TunnelRequestOptions /// /// Gets or sets additional http request options - /// for HttpRequestMessage.Options (in net6.0) or - /// HttpRequestMessage.Properties (in netcoreapp3.1). + /// for HttpRequestMessage.Options. /// public IEnumerable>? HttpRequestOptions { get; set; } @@ -193,21 +192,13 @@ protected internal virtual string ToQueryString() /// /// Set HTTP request options. /// - /// - /// On net 6.0+ it sets request.Options. - /// On netcoreapp 3.1 it sets request.Properties. - /// /// Http request, not null. internal void SetRequestOptions(HttpRequestMessage request) { Requires.NotNull(request, nameof(request)); foreach (var kvp in HttpRequestOptions ?? Enumerable.Empty>()) { -#if NET6_0_OR_GREATER request.Options.Set(new HttpRequestOptionsKey(kvp.Key), kvp.Value); -#else - request.Properties[kvp.Key] = kvp.Value; -#endif } } } diff --git a/ts/build.js b/ts/build.js index 37fb5b66..a206957f 100644 --- a/ts/build.js +++ b/ts/build.js @@ -22,41 +22,12 @@ yargs.version(false); const buildGroup = 'Build Options:'; const testGroup = 'Test Options:'; -yargs.option('verbosity', { desc: 'MSBuild verbosity', string: true, group: buildGroup }); -yargs.option('configuration', { - desc: 'MSBuild configuration', - choices: ['Debug', 'Release'], - group: buildGroup, -}); -yargs.option('release', { - desc: 'Use MSBuild Release configuration', - boolean: true, - group: buildGroup, -}); -yargs.option('framework', { - desc: 'Specify .net application framework', - choices: ['netcoreapp2.1', 'netcoreapp2.1', 'net5.0', 'netstandard2.0', 'netstandard2.1'], - group: buildGroup, -}); -yargs.option('msbuild', { - desc: 'Use MSBuild instead of dotnet CLI', // Signing requires msbuild - boolean: true, - group: buildGroup, -}); yargs.option('filter', { desc: 'Filter test cases', string: true, group: testGroup }); -yargs.option('serial', { desc: 'Run tests serially (slower)', boolean: true, group: testGroup }); -yargs.option('coverage', { - desc: 'Collect code coverage when testing', - boolean: true, - group: testGroup, -}); -const namespace = 'Microsoft.VisualStudio.Tunnels'; const srcDir = path.join(__dirname, 'src'); const binDir = path.join(__dirname, 'out', 'bin'); const libDir = path.join(__dirname, 'out', 'lib'); -const intermediateDir = path.join(__dirname, 'out', 'obj'); const packageDir = path.join(__dirname, 'out', 'pkg'); const packageJsonFile = path.join(__dirname, 'package.json'); const testResultsDir = path.join(__dirname, 'out', 'testresults'); diff --git a/version.json b/version.json index b12c365a..63beb128 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.1", + "version": "1.2", "versionHeightOffset": 0, "pathFilters": ["cs", "ts", "./"],