Skip to content

Commit

Permalink
Add .NET 8 target, remove .NET Core 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin committed Sep 27, 2024
1 parent 106b4e9 commit cf93882
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .pipelines/cs-build-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 3 additions & 10 deletions cs/build/build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,17 @@
<Deterministic>true</Deterministic>
</PropertyGroup>

<!-- .Net Targets -->
<PropertyGroup>
<NetCoreAppTargetFramework>netcoreapp3.1</NetCoreAppTargetFramework>
<NetStandardTargetFramework>netstandard2.1</NetStandardTargetFramework>
<NetStandardTargetFrameworkMT>netstandard2.1</NetStandardTargetFrameworkMT>
</PropertyGroup>

<!-- NuGet Package Versions -->
<PropertyGroup>
<AltcoverVersion>7.6.812</AltcoverVersion>
<AltcoverVersion>8.9.3</AltcoverVersion>
<FluentAssertionsVersion>5.4.1</FluentAssertionsVersion>
<FxCopAnalyzersPackageVersion>3.3.0</FxCopAnalyzersPackageVersion>
<MicroBuildCoreVersion>0.3.0</MicroBuildCoreVersion>
<MicrosoftAspNetCoreWebUtilitiesPackageVersion>1.0.3</MicrosoftAspNetCoreWebUtilitiesPackageVersion>
<MicrosoftNETTestSdkVersion>15.8.0</MicrosoftNETTestSdkVersion>
<MoqVersion>4.9.0</MoqVersion>
<NerdBankGitVersioningVersion>3.6.133</NerdBankGitVersioningVersion>
<ReportGeneratorVersion>4.8.13</ReportGeneratorVersion>
<ReportGeneratorVersion>5.3.9</ReportGeneratorVersion>
<SystemTextEncodingsWebPackageVersion>4.7.2</SystemTextEncodingsWebPackageVersion>
<VisualStudioValidationVersion>15.5.31</VisualStudioValidationVersion>
<DevTunnelsSshPackageVersion>3.12.5</DevTunnelsSshPackageVersion>
Expand Down Expand Up @@ -95,7 +88,7 @@
<!-- AltCover properties -->
<PropertyGroup Condition=" '$(CodeCoverage)' == 'true' ">
<AltCover>true</AltCover>
<AltCoverXmlReport>$(TestResultsDirectory)/$(TestBaseName)-coverage.xml</AltCoverXmlReport>
<AltCoverReport>$(TestResultsDirectory)/$(TestBaseName)-coverage.xml</AltCoverReport>
<AltCoverAssemblyExcludeFilter>Interop|Test|xunit|AltCover|System.Reactive</AltCoverAssemblyExcludeFilter>
<AltCoverTypeFilter>ThisAssembly|System.Runtime|CodeAnalysis</AltCoverTypeFilter>
<AltCoverLcovReport>$(TestResultsDirectory)/$(TestBaseName)-lcov.info</AltCoverLcovReport>
Expand Down
2 changes: 1 addition & 1 deletion cs/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.412"
"version": "8.0.400"
}
}
2 changes: 1 addition & 1 deletion cs/src/Connections/DevTunnels.Connections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>Microsoft.DevTunnels.Connections</AssemblyName>
<RootNamespace>Microsoft.DevTunnels.Connections</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<IsPackable>true</IsPackable>
<UseVsSaaSSdk>false</UseVsSaaSSdk>
Expand Down
14 changes: 9 additions & 5 deletions cs/src/Connections/WebSocketStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,16 @@ public static async Task<WebSocketStream> 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)
{
Expand All @@ -120,10 +125,9 @@ public static async Task<WebSocketStream> ConnectToWebSocketAsync(Uri uri, Actio
statusCode != 101)
{
TunnelConnectionException.SetHttpStatusCode(wse, (HttpStatusCode)statusCode);
socket.Dispose();
throw wse;
}
}
#endif

socket.Dispose();
throw;
Expand Down
2 changes: 1 addition & 1 deletion cs/src/Contracts/DevTunnels.Contracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<RootNamespace>Microsoft.DevTunnels.Contracts</RootNamespace>
<AssemblyName>Microsoft.DevTunnels.Contracts</AssemblyName>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<IsPackable>true</IsPackable>
<UseVsSaaSSdk>false</UseVsSaaSSdk>
Expand Down
6 changes: 3 additions & 3 deletions cs/src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Target
Name="GenerateDocumentation"
AfterTargets="Build"
Condition="'$(GenerateDocs)'=='true' AND '$(TargetFramework)' == 'netcoreapp3.1'"
Condition="'$(GenerateDocs)'=='true' AND '$(TargetFramework)' == 'net6.0'"
>
<!-- This target only runs for the .NET 3.1 target; xmldocmd tool currently does not work on .NET 6. -->
<!-- This target only runs for the .NET 6 target; xmldocmd does not yet support .NET 8. -->
<!-- It requires the `xmldocmd` tool: dotnet tool install -g xmldocmd -->
<!-- Invoke this target with: dotnet build -c Release TunnelsSDK.sln -p:GenerateDocs=true -->

Expand All @@ -19,7 +19,7 @@
</PropertyGroup>

<Message Importance="High" Text="Generating documentation for $(TargetName)..." />
<Exec Command="xmldocmd $(TargetPath) docs $(DocumentationReferenceAssemblies) --skip-unbrowsable" WorkingDirectory="$(MSBuildThisFileDirectory)" />
<Exec Command="xmldocmd $(TargetPath) docs $(DocumentationReferenceAssemblies) --skip-unbrowsable" WorkingDirectory="$(MSBuildThisFileDirectory).." />
</Target>

<Target
Expand Down
6 changes: 3 additions & 3 deletions cs/src/Management/DevTunnels.Management.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<PropertyGroup>
<AssemblyName>Microsoft.DevTunnels.Management</AssemblyName>
<RootNamespace>Microsoft.DevTunnels.Management</RootNamespace>
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<IsPackable>true</IsPackable>
<UseVsSaaSSdk>false</UseVsSaaSSdk>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<WarningsNotAsErrors>CS1591</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
11 changes: 1 addition & 10 deletions cs/src/Management/TunnelRequestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public class TunnelRequestOptions

/// <summary>
/// Gets or sets additional http request options
/// for <code>HttpRequestMessage.Options</code> (in net6.0) or
/// <code>HttpRequestMessage.Properties</code> (in netcoreapp3.1).
/// for <code>HttpRequestMessage.Options</code>.
/// </summary>
public IEnumerable<KeyValuePair<string, object?>>? HttpRequestOptions { get; set; }

Expand Down Expand Up @@ -193,21 +192,13 @@ protected internal virtual string ToQueryString()
/// <summary>
/// Set HTTP request options.
/// </summary>
/// <remarks>
/// On net 6.0+ it sets <code>request.Options</code>.
/// On netcoreapp 3.1 it sets <code>request.Properties</code>.
/// </remarks>
/// <param name="request">Http request, not null.</param>
internal void SetRequestOptions(HttpRequestMessage request)
{
Requires.NotNull(request, nameof(request));
foreach (var kvp in HttpRequestOptions ?? Enumerable.Empty<KeyValuePair<string, object?>>())
{
#if NET6_0_OR_GREATER
request.Options.Set(new HttpRequestOptionsKey<object?>(kvp.Key), kvp.Value);
#else
request.Properties[kvp.Key] = kvp.Value;
#endif
}
}
}
Expand Down
29 changes: 0 additions & 29 deletions ts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -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", "./"],

Expand Down

0 comments on commit cf93882

Please sign in to comment.