Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump runtime to dotnet 6 #1471

Merged
merged 6 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Runner.Common/Runner.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is enabled by default since dotnet 5

</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Runner.Listener/CommandSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ public string GetUrl(bool suppressPromptIfEmpty = false)
validator: Validators.ServerUrlValidator);
}

#if OS_WINDOWS
public string GetWindowsLogonAccount(string defaultValue, string descriptionMsg)
{
return GetArgOrPrompt(
Expand All @@ -260,7 +261,7 @@ public string GetWindowsLogonPassword(string accountName)
defaultValue: string.Empty,
validator: Validators.NonEmptyValidator);
}

#endif
public string GetWork()
{
return GetArgOrPrompt(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if OS_WINDOWS
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotnet 6 introduced api platform check at compile time.
We already did our platform check using #if OS_WINDOWS, so we can just disable the working everywhere we have #if OS_WINDOWS

#pragma warning disable CA1416
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this pragma is needed. I didn't experience any problems on my branch with these warnings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking it back. This is within If Windows block and I didn't test building on Windows

using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -1327,4 +1328,5 @@ public struct PROFILEINFO
public IntPtr hProfile;
}
}
#pragma warning restore CA1416
#endif
4 changes: 4 additions & 0 deletions src/Runner.Listener/Configuration/Validators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public static bool NonEmptyValidator(string value)
return !string.IsNullOrEmpty(value);
}

#if OS_WINDOWS
#pragma warning disable CA1416
public static bool NTAccountValidator(string arg)
{
if (string.IsNullOrEmpty(arg) || String.IsNullOrEmpty(arg.TrimStart('.', '\\')))
Expand All @@ -87,5 +89,7 @@ public static bool NTAccountValidator(string arg)

return true;
}
#pragma warning restore CA1416
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if OS_WINDOWS
#pragma warning disable CA1416
using System;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -169,4 +170,5 @@ private void GetAccountSegments(string account, out string domain, out string us
}
}
}
#pragma warning restore CA1416
#endif
5 changes: 2 additions & 3 deletions src/Runner.Listener/Runner.Listener.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublishReadyToRunComposite is a replacing for PublishReadyToRun for self-contained app.

</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions src/Runner.PluginHost/Runner.PluginHost.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/Runner.Plugins/Artifact/FileContainerServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private async Task<DownloadResult> DownloadAsync(RunnerActionPluginExecutionCont
{
// We should never
context.Error($"Error '{ex.Message}' when downloading file '{fileToDownload}'. (Downloader {downloaderId})");
throw ex;
throw;
}
}

Expand Down Expand Up @@ -528,7 +528,7 @@ private async Task<UploadResult> UploadAsync(RunnerActionPluginExecutionContext
catch (Exception ex)
{
context.Output($"File error '{ex.Message}' when uploading file '{fileToUpload}'.");
throw ex;
throw;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/Runner.Plugins/Runner.Plugins.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/Runner.Sdk/Runner.Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/Runner.Worker/ContainerOperationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ public async Task StartContainersAsync(IExecutionContext executionContext, objec
// Our container feature requires to map working directory from host to the container.
// If we are already inside a container, we will not able to find out the real working direcotry path on the host.
#if OS_WINDOWS
#pragma warning disable CA1416
// service CExecSvc is Container Execution Agent.
ServiceController[] scServices = ServiceController.GetServices();
if (scServices.Any(x => String.Equals(x.ServiceName, "cexecsvc", StringComparison.OrdinalIgnoreCase) && x.Status == ServiceControllerStatus.Running))
{
throw new NotSupportedException("Container feature is not supported when runner is already running inside container.");
}
#pragma warning restore CA1416
#else
var initProcessCgroup = File.ReadLines("/proc/1/cgroup");
if (initProcessCgroup.Any(x => x.IndexOf(":/docker/", StringComparison.OrdinalIgnoreCase) >= 0))
Expand All @@ -70,6 +72,7 @@ public async Task StartContainersAsync(IExecutionContext executionContext, objec
#endif

#if OS_WINDOWS
#pragma warning disable CA1416
// Check OS version (Windows server 1803 is required)
object windowsInstallationType = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "InstallationType", defaultValue: null);
ArgUtil.NotNull(windowsInstallationType, nameof(windowsInstallationType));
Expand All @@ -88,6 +91,7 @@ public async Task StartContainersAsync(IExecutionContext executionContext, objec
{
throw new ArgumentOutOfRangeException(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId");
}
#pragma warning restore CA1416
#endif

// Check docker client/server version
Expand Down
5 changes: 2 additions & 3 deletions src/Runner.Worker/Runner.Worker.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishReadyToRunComposite>true</PublishReadyToRunComposite>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public IDictionary<string, object> Properties
{
get
{
return m_request.Properties;
TingluoHuang marked this conversation as resolved.
Show resolved Hide resolved
return m_request.Options;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static VssHttpMethod GetHttpMethod(this HttpRequestMessage message)
public static VssTraceActivity GetActivity(this HttpRequestMessage message)
{
Object traceActivity;
if (!message.Properties.TryGetValue(VssTraceActivity.PropertyName, out traceActivity))
if (!message.Options.TryGetValue(VssTraceActivity.PropertyName, out traceActivity))
{
return VssTraceActivity.Empty;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/Common/Common/VssHttpMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
}

// Add ourselves to the message so the underlying token issuers may use it if necessary
request.Properties[VssHttpMessageHandler.PropertyName] = this;
request.Options.Set(new HttpRequestOptionsKey<VssHttpMessageHandler>(VssHttpMessageHandler.PropertyName), this);

Boolean succeeded = false;
Boolean lastResponseDemandedProxyAuth = false;
Expand Down Expand Up @@ -409,7 +409,7 @@ protected virtual async Task BufferResponseContentAsync(
// Read the completion option provided by the caller. If we don't find the property then we
// assume it is OK to buffer by default.
HttpCompletionOption completionOption;
if (!request.Properties.TryGetValue(VssHttpRequestSettings.HttpCompletionOptionPropertyName, out completionOption))
if (!request.Options.TryGetValue(VssHttpRequestSettings.HttpCompletionOptionPropertyName, out completionOption))
{
completionOption = HttpCompletionOption.ResponseContentRead;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sdk/Common/Common/VssHttpMessageHandlerTraceInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ internal void TraceTrailingTime()
public static void SetTraceInfo(HttpRequestMessage message, VssHttpMessageHandlerTraceInfo traceInfo)
{
object existingTraceInfo;
if (!message.Properties.TryGetValue(TfsTraceInfoKey, out existingTraceInfo))
if (!message.Options.TryGetValue(TfsTraceInfoKey, out existingTraceInfo))
{
message.Properties.Add(TfsTraceInfoKey, traceInfo);
message.Options.Set(new HttpRequestOptionsKey<VssHttpMessageHandlerTraceInfo>(TfsTraceInfoKey), traceInfo);
}
}

Expand All @@ -92,7 +92,7 @@ public static VssHttpMessageHandlerTraceInfo GetTraceInfo(HttpRequestMessage mes
{
VssHttpMessageHandlerTraceInfo traceInfo = null;

if (message.Properties.TryGetValue(TfsTraceInfoKey, out object traceInfoObject))
if (message.Options.TryGetValue(TfsTraceInfoKey, out object traceInfoObject))
{
traceInfo = traceInfoObject as VssHttpMessageHandlerTraceInfo;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/Common/Common/VssHttpRequestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ protected internal virtual Boolean IsHostLocal(String hostName)
protected internal virtual Boolean ApplyTo(HttpRequestMessage request)
{
// Make sure we only apply the settings to the request once
if (request.Properties.ContainsKey(PropertyName))
if (request.Options.TryGetValue(new HttpRequestOptionsKey<VssHttpRequestSettings>(PropertyName), out _))
TingluoHuang marked this conversation as resolved.
Show resolved Hide resolved
{
return false;
}

request.Properties.Add(PropertyName, this);
request.Options.Set(new HttpRequestOptionsKey<VssHttpRequestSettings>(PropertyName), this);

if (this.AcceptLanguages != null && this.AcceptLanguages.Count > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions src/Sdk/Common/Common/VssHttpRetryMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public VssHttpRetryMessageHandler(VssHttpRetryOptions options)
}

public VssHttpRetryMessageHandler(
VssHttpRetryOptions options,
VssHttpRetryOptions options,
HttpMessageHandler innerHandler)
: base(innerHandler)
{
Expand All @@ -55,7 +55,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
// Allow overriding default retry options per request
VssHttpRetryOptions retryOptions = m_retryOptions;
object retryOptionsObject;
if (request.Properties.TryGetValue(HttpRetryOptionsKey, out retryOptionsObject)) // NETSTANDARD compliant, TryGetValue<T> is not
if (request.Options.TryGetValue(HttpRetryOptionsKey, out retryOptionsObject)) // NETSTANDARD compliant, TryGetValue<T> is not
{
// Fallback to default options if object of unexpected type was passed
retryOptions = retryOptionsObject as VssHttpRetryOptions ?? m_retryOptions;
Expand All @@ -66,7 +66,7 @@ protected override async Task<HttpResponseMessage> SendAsync(

IVssHttpRetryInfo retryInfo = null;
object retryInfoObject;
if (request.Properties.TryGetValue(HttpRetryInfoKey, out retryInfoObject)) // NETSTANDARD compliant, TryGetValue<T> is not
if (request.Options.TryGetValue(HttpRetryInfoKey, out retryInfoObject)) // NETSTANDARD compliant, TryGetValue<T> is not
{
retryInfo = retryInfoObject as IVssHttpRetryInfo;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ protected virtual void TraceRaw(HttpRequestMessage request, int tracepoint, Trac
{
// implement in Server so retries are recorded in ProductTrace
}

protected virtual void TraceHttpRequestFailed(VssTraceActivity activity, HttpRequestMessage request, HttpStatusCode statusCode, string afdRefInfo)
{
VssHttpEventSource.Log.HttpRequestFailed(activity, request, statusCode, afdRefInfo);
Expand Down Expand Up @@ -212,7 +212,7 @@ protected virtual void TraceHttpRequestRetrying(VssTraceActivity activity, HttpR
private static bool IsLowPriority(HttpRequestMessage request)
{
bool isLowPriority = false;

IEnumerable<string> headers;

if (request.Headers.TryGetValues(HttpHeaders.VssRequestPriority, out headers) && headers != null)
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/Sdk.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
Expand All @@ -10,7 +10,7 @@
<DefineConstants>TRACE</DefineConstants>
<LangVersion>7.3</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TieredCompilationQuickJit>true</TieredCompilationQuickJit>
<EnableTrimAnalyzer>false</EnableTrimAnalyzer>
TingluoHuang marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 7 additions & 5 deletions src/Sdk/WebApi/WebApi/VssHttpClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -833,20 +833,20 @@ protected async Task<HttpResponseMessage> SendAsync(
{
if (userState != null)
{
message.Properties[UserStatePropertyName] = userState;
message.Options.Set(new HttpRequestOptionsKey<object>(UserStatePropertyName), userState);
}

if (!message.Headers.Contains(Common.Internal.HttpHeaders.VssE2EID))
{
message.Headers.Add(Common.Internal.HttpHeaders.VssE2EID, Guid.NewGuid().ToString("D"));
}
VssHttpEventSource.Log.HttpRequestStart(traceActivity, message);
message.Trace();
message.Properties[VssTraceActivity.PropertyName] = traceActivity;
message.Options.Set(new HttpRequestOptionsKey<VssTraceActivity>(VssTraceActivity.PropertyName), traceActivity);

// Send the completion option to the inner handler stack so we know when it's safe to buffer
// and when we should avoid buffering.
message.Properties[VssHttpRequestSettings.HttpCompletionOptionPropertyName] = completionOption;
message.Options.Set(new HttpRequestOptionsKey<HttpCompletionOption>(VssHttpRequestSettings.HttpCompletionOptionPropertyName), completionOption);

//ConfigureAwait(false) enables the continuation to be run outside
//any captured SyncronizationContext (such as ASP.NET's) which keeps things
Expand All @@ -872,7 +872,7 @@ protected virtual void HandleResponse(HttpResponseMessage response)
}

protected virtual async Task HandleResponseAsync(
HttpResponseMessage response,
HttpResponseMessage response,
CancellationToken cancellationToken)
{
response.Trace();
Expand Down Expand Up @@ -1154,12 +1154,14 @@ private void SetServicePointOptions()
{
if (BaseAddress != null)
{
#pragma warning disable SYSLIB0014
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServicePointManager is deprecated, but I didn't find an equivalent in dotnet 6, so I disable the warning and keep using the old API.

ServicePoint servicePoint = ServicePointManager.FindServicePoint(BaseAddress);
servicePoint.UseNagleAlgorithm = false;
servicePoint.SetTcpKeepAlive(
enabled: true,
keepAliveTime: c_keepAliveTime,
keepAliveInterval: c_keepAliveInterval);
#pragma warning restore SYSLIB0014
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sdk/WebApi/WebApi/VssHttpUriUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static String ReplaceRouteValues(

if (routeReplacementOptions.HasFlag(RouteReplacementOptions.EscapeUri))
{
sbResult = new StringBuilder(Uri.EscapeUriString(sbResult.ToString()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EscapeUriString is deprecated...

sbResult = new StringBuilder(Uri.EscapeDataString(sbResult.ToString()));
}

if (routeReplacementOptions.HasFlag(RouteReplacementOptions.AppendUnusedAsQueryParams) && unusedValues.Count > 0)
Expand Down
Loading