Compare commits

...

1 Commits

Author SHA1 Message Date
Pavel Iakovenko
f8cd472d17 Upgrade to .net6 2021-11-11 21:44:58 -05:00
28 changed files with 59 additions and 84 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -243,6 +243,7 @@ namespace GitHub.Runner.Listener
validator: Validators.ServerUrlValidator);
}
#if OS_WINDOWS
public string GetWindowsLogonAccount(string defaultValue, string descriptionMsg)
{
return GetArgOrPrompt(
@@ -251,6 +252,7 @@ namespace GitHub.Runner.Listener
defaultValue: defaultValue,
validator: Validators.NTAccountValidator);
}
#endif
public string GetWindowsLogonPassword(string accountName)
{

View File

@@ -67,6 +67,7 @@ namespace GitHub.Runner.Listener.Configuration
return !string.IsNullOrEmpty(value);
}
#if OS_WINDOWS
public static bool NTAccountValidator(string arg)
{
if (string.IsNullOrEmpty(arg) || String.IsNullOrEmpty(arg.TrimStart('.', '\\')))
@@ -87,5 +88,6 @@ namespace GitHub.Runner.Listener.Configuration
return true;
}
#endif
}
}

View File

@@ -129,7 +129,7 @@ namespace GitHub.Runner.Listener
private static void LoadAndSetEnv()
{
var binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
var binDir = Path.GetDirectoryName(AppContext.BaseDirectory);
var rootDir = new DirectoryInfo(binDir).Parent.FullName;
string envFile = Path.Combine(rootDir, ".env");
if (File.Exists(envFile))

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -95,7 +95,7 @@ namespace GitHub.Runner.PluginHost
string assemblyFilename = assembly.Name + ".dll";
if (string.IsNullOrEmpty(executingAssemblyLocation))
{
executingAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
executingAssemblyLocation = Path.GetDirectoryName(AppContext.BaseDirectory);
}
return context.LoadFromAssemblyPath(Path.Combine(executingAssemblyLocation, assemblyFilename));
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -444,7 +444,7 @@ namespace GitHub.Runner.Plugins.Artifact
{
// We should never
context.Error($"Error '{ex.Message}' when downloading file '{fileToDownload}'. (Downloader {downloaderId})");
throw ex;
throw;
}
}
@@ -528,7 +528,7 @@ namespace GitHub.Runner.Plugins.Artifact
catch (Exception ex)
{
context.Output($"File error '{ex.Message}' when uploading file '{fileToUpload}'.");
throw ex;
throw;
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -59,7 +59,7 @@ namespace GitHub.Runner.Worker.Expressions
context.Trace.Info($"Search root directory: '{githubWorkspace}'");
context.Trace.Info($"Search pattern: '{string.Join(", ", patterns)}'");
string binDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
string binDir = Path.GetDirectoryName(AppContext.BaseDirectory);
string runnerRoot = new DirectoryInfo(binDir).Parent.FullName;
string node = Path.Combine(runnerRoot, "externals", "node12", "bin", $"node{IOUtil.ExeExtension}");

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -28,14 +28,6 @@ namespace GitHub.Services.Common
}
}
public IDictionary<string, object> Properties
{
get
{
return m_request.Properties;
}
}
IEnumerable<String> IHttpHeaders.GetValues(String name)
{
IEnumerable<String> values;

View File

@@ -14,10 +14,5 @@ namespace GitHub.Services.Common
{
get;
}
IDictionary<string, object> Properties
{
get;
}
}
}

View File

@@ -20,12 +20,11 @@ namespace GitHub.Services.Common.Diagnostics
public static VssTraceActivity GetActivity(this HttpRequestMessage message)
{
Object traceActivity;
if (!message.Properties.TryGetValue(VssTraceActivity.PropertyName, out traceActivity))
if (!message.Options.TryGetValue(VssTraceActivity.PropertyName, out VssTraceActivity traceActivity))
{
return VssTraceActivity.Empty;
}
return (VssTraceActivity)traceActivity;
return traceActivity;
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Net.Http;
namespace GitHub.Services.Common.Diagnostics
{
@@ -98,7 +99,7 @@ namespace GitHub.Services.Common.Diagnostics
/// <summary>
/// Gets the property name used to cache this object on extensible objects.
/// </summary>
public const String PropertyName = "MS.VSS.Diagnostics.TraceActivity";
public static readonly HttpRequestOptionsKey<VssTraceActivity> PropertyName = new HttpRequestOptionsKey<VssTraceActivity>("MS.VSS.Diagnostics.TraceActivity");
private static Lazy<VssTraceActivity> s_empty = new Lazy<VssTraceActivity>(() => new VssTraceActivity(Guid.Empty));
private sealed class CorrelationScope : IDisposable

View File

@@ -110,7 +110,7 @@ namespace GitHub.Services.Common
}
}
internal static readonly String PropertyName = "MS.VS.MessageHandler";
internal static readonly HttpRequestOptionsKey<VssHttpMessageHandler> PropertyName = new HttpRequestOptionsKey<VssHttpMessageHandler>("MS.VS.MessageHandler");
/// <summary>
/// Handles the authentication hand-shake for a Visual Studio service.
@@ -169,7 +169,7 @@ namespace GitHub.Services.Common
}
// Add ourselves to the message so the underlying token issuers may use it if necessary
request.Properties[VssHttpMessageHandler.PropertyName] = this;
request.Options.Set(VssHttpMessageHandler.PropertyName, this);
Boolean succeeded = false;
Boolean lastResponseDemandedProxyAuth = false;
@@ -409,7 +409,7 @@ namespace GitHub.Services.Common
// 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;
}

View File

@@ -11,7 +11,7 @@ namespace GitHub.Services.Common
{
DateTime _lastTime;
static readonly String TfsTraceInfoKey = "TFS_TraceInfo";
private static readonly HttpRequestOptionsKey<VssHttpMessageHandlerTraceInfo> TfsTraceInfoKey = new HttpRequestOptionsKey<VssHttpMessageHandlerTraceInfo>("TFS_TraceInfo");
public int TokenRetries { get; internal set; }
@@ -76,10 +76,9 @@ namespace GitHub.Services.Common
/// <param name="traceInfo"></param>
public static void SetTraceInfo(HttpRequestMessage message, VssHttpMessageHandlerTraceInfo traceInfo)
{
object existingTraceInfo;
if (!message.Properties.TryGetValue(TfsTraceInfoKey, out existingTraceInfo))
if (!message.Options.TryGetValue(TfsTraceInfoKey, out var _))
{
message.Properties.Add(TfsTraceInfoKey, traceInfo);
message.Options.Set(TfsTraceInfoKey, traceInfo);
}
}
@@ -90,13 +89,8 @@ namespace GitHub.Services.Common
/// <returns></returns>
public static VssHttpMessageHandlerTraceInfo GetTraceInfo(HttpRequestMessage message)
{
VssHttpMessageHandlerTraceInfo traceInfo = null;
if (message.Properties.TryGetValue(TfsTraceInfoKey, out object traceInfoObject))
{
traceInfo = traceInfoObject as VssHttpMessageHandlerTraceInfo;
}
VssHttpMessageHandlerTraceInfo traceInfo;
message.Options.TryGetValue(TfsTraceInfoKey, out traceInfo);
return traceInfo;
}

View File

@@ -291,12 +291,12 @@ namespace GitHub.Services.Common
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(PropertyName, out var _))
{
return false;
}
request.Properties.Add(PropertyName, this);
request.Options.Set(PropertyName, this);
if (this.AcceptLanguages != null && this.AcceptLanguages.Count > 0)
{
@@ -366,12 +366,12 @@ namespace GitHub.Services.Common
/// <summary>
/// Gets the property name used to reference this object.
/// </summary>
public const String PropertyName = "MS.VS.RequestSettings";
public static readonly HttpRequestOptionsKey<VssHttpRequestSettings> PropertyName = new HttpRequestOptionsKey<VssHttpRequestSettings>("MS.VS.RequestSettings");
/// <summary>
/// Gets the property name used to reference the completion option for a specific request.
/// </summary>
public const String HttpCompletionOptionPropertyName = "MS.VS.HttpCompletionOption";
public static readonly HttpRequestOptionsKey<HttpCompletionOption> HttpCompletionOptionPropertyName = new HttpRequestOptionsKey<HttpCompletionOption>("MS.VS.HttpCompletionOption");
/// <summary>
/// Header to include the light weight response client option.

View File

@@ -53,23 +53,14 @@ namespace GitHub.Services.Common
VssTraceActivity traceActivity = VssTraceActivity.Current;
// 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
{
// Fallback to default options if object of unexpected type was passed
retryOptions = retryOptionsObject as VssHttpRetryOptions ?? m_retryOptions;
}
VssHttpRetryOptions retryOptions;
request.Options.TryGetValue(HttpRetryOptionsKey, out retryOptions);
TimeSpan minBackoff = retryOptions.MinBackoff;
Int32 maxAttempts = retryOptions.MaxRetries + 1;
TimeSpan minBackoff = (retryOptions ?? m_retryOptions).MinBackoff;
Int32 maxAttempts = (retryOptions ?? m_retryOptions).MaxRetries + 1;
IVssHttpRetryInfo retryInfo = null;
object retryInfoObject;
if (request.Properties.TryGetValue(HttpRetryInfoKey, out retryInfoObject)) // NETSTANDARD compliant, TryGetValue<T> is not
{
retryInfo = retryInfoObject as IVssHttpRetryInfo;
}
request.Options.TryGetValue(HttpRetryInfoKey, out retryInfo);
if (IsLowPriority(request))
{
@@ -225,8 +216,8 @@ namespace GitHub.Services.Common
}
private VssHttpRetryOptions m_retryOptions;
public const string HttpRetryInfoKey = "HttpRetryInfo";
public const string HttpRetryOptionsKey = "VssHttpRetryOptions";
public static readonly HttpRequestOptionsKey<IVssHttpRetryInfo> HttpRetryInfoKey = new HttpRequestOptionsKey<IVssHttpRetryInfo>("HttpRetryInfo");
public static readonly HttpRequestOptionsKey<VssHttpRetryOptions> HttpRetryOptionsKey = new HttpRequestOptionsKey<VssHttpRetryOptions>("VssHttpRetryOptions");
private string m_clientName = "";
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>

View File

@@ -833,7 +833,7 @@ namespace GitHub.Services.WebApi
{
if (userState != null)
{
message.Properties[UserStatePropertyName] = userState;
message.Options.Set(UserStatePropertyName, userState);
}
if (!message.Headers.Contains(Common.Internal.HttpHeaders.VssE2EID))
@@ -842,11 +842,11 @@ namespace GitHub.Services.WebApi
}
VssHttpEventSource.Log.HttpRequestStart(traceActivity, message);
message.Trace();
message.Properties[VssTraceActivity.PropertyName] = traceActivity;
message.Options.Set(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(VssHttpRequestSettings.HttpCompletionOptionPropertyName, completionOption);
//ConfigureAwait(false) enables the continuation to be run outside
//any captured SyncronizationContext (such as ASP.NET's) which keeps things
@@ -1154,7 +1154,9 @@ namespace GitHub.Services.WebApi
{
if (BaseAddress != null)
{
#pragma warning disable SYSLIB0014
ServicePoint servicePoint = ServicePointManager.FindServicePoint(BaseAddress);
#pragma warning restore SYSLIB0014
servicePoint.UseNagleAlgorithm = false;
servicePoint.SetTcpKeepAlive(
enabled: true,
@@ -1272,7 +1274,7 @@ namespace GitHub.Services.WebApi
private const String c_jsonMediaType = "application/json";
public readonly static String UserStatePropertyName = "VssClientBaseUserState";
public static readonly HttpRequestOptionsKey<object> UserStatePropertyName = new HttpRequestOptionsKey<object>("VssClientBaseUserState");
protected sealed class OperationScope : IDisposable
{

View File

@@ -138,7 +138,7 @@ namespace GitHub.Services.WebApi
if (routeReplacementOptions.HasFlag(RouteReplacementOptions.EscapeUri))
{
sbResult = new StringBuilder(Uri.EscapeUriString(sbResult.ToString()));
sbResult = new StringBuilder(Uri.EscapeDataString(sbResult.ToString()));
}
if (routeReplacementOptions.HasFlag(RouteReplacementOptions.AppendUnusedAsQueryParams) && unusedValues.Count > 0)

View File

@@ -6,27 +6,24 @@ using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Runtime.InteropServices;
namespace GitHub.Services.WebApi
{
internal static class HttpMessageExtensions
{
private const string tracerKey = "VSS_HTTP_TIMER_TRACE";
private static readonly HttpRequestOptionsKey<VssRequestTimerTrace> tracerKey = new HttpRequestOptionsKey<VssRequestTimerTrace>("VSS_HTTP_TIMER_TRACE");
internal static void Trace(this HttpRequestMessage request)
{
Object tracerObj = null;
VssRequestTimerTrace tracer = null;
if (request.Properties.TryGetValue(tracerKey, out tracerObj))
VssRequestTimerTrace tracer;
if (request.Options.TryGetValue(tracerKey, out tracer))
{
tracer = tracerObj as VssRequestTimerTrace;
Debug.Assert(tracer != null, "Tracer object is the wrong type!");
}
else
{
tracer = new VssRequestTimerTrace();
request.Properties[tracerKey] = tracer;
request.Options.Set(tracerKey, tracer);
}
if (tracer != null)
@@ -37,11 +34,9 @@ namespace GitHub.Services.WebApi
internal static void Trace(this HttpResponseMessage response)
{
Object tracerObj = null;
VssRequestTimerTrace tracer = null;
if (response.RequestMessage.Properties.TryGetValue(tracerKey, out tracerObj))
VssRequestTimerTrace tracer;
if (response.RequestMessage.Options.TryGetValue(tracerKey, out tracer))
{
tracer = tracerObj as VssRequestTimerTrace;
Debug.Assert(tracer != null, "Tracer object is the wrong type!");
}

View File

@@ -547,6 +547,7 @@ namespace GitHub.Runner.Common.Tests
}
}
#if OS_WINDOWS
[Fact]
[Trait("Level", "L0")]
[Trait("Category", nameof(CommandSettings))]
@@ -574,6 +575,7 @@ namespace GitHub.Runner.Common.Tests
Assert.Equal("some windows logon account", actual);
}
}
#endif
[Fact]
[Trait("Level", "L0")]

View File

@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6</TargetFramework>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;NU1603;xUnit2013;</NoWarn>

View File

@@ -14,10 +14,10 @@ DEV_TARGET_RUNTIME=$3
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LAYOUT_DIR="$SCRIPT_DIR/../_layout"
DOWNLOAD_DIR="$SCRIPT_DIR/../_downloads/netcore2x"
DOWNLOAD_DIR="$SCRIPT_DIR/../_downloads/net6"
PACKAGE_DIR="$SCRIPT_DIR/../_package"
DOTNETSDK_ROOT="$SCRIPT_DIR/../_dotnetsdk"
DOTNETSDK_VERSION="3.1.302"
DOTNETSDK_VERSION="6.0.100"
DOTNETSDK_INSTALLDIR="$DOTNETSDK_ROOT/$DOTNETSDK_VERSION"
RUNNER_VERSION=$(cat runnerversion)

View File

@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.1.302"
"version": "net6"
}
}