diff --git a/src/Agent.Listener/Agent.Listener.csproj b/src/Agent.Listener/Agent.Listener.csproj index dbd3e18546..e9d2241960 100644 --- a/src/Agent.Listener/Agent.Listener.csproj +++ b/src/Agent.Listener/Agent.Listener.csproj @@ -4,6 +4,7 @@ Exe + true diff --git a/src/Agent.PluginHost/Agent.PluginHost.csproj b/src/Agent.PluginHost/Agent.PluginHost.csproj index f68fc56128..7aed7f31dd 100644 --- a/src/Agent.PluginHost/Agent.PluginHost.csproj +++ b/src/Agent.PluginHost/Agent.PluginHost.csproj @@ -4,6 +4,7 @@ Exe + true diff --git a/src/Agent.Plugins/Agent.Plugins.csproj b/src/Agent.Plugins/Agent.Plugins.csproj index f71a17560d..e58759a558 100644 --- a/src/Agent.Plugins/Agent.Plugins.csproj +++ b/src/Agent.Plugins/Agent.Plugins.csproj @@ -4,6 +4,7 @@ Library + true diff --git a/src/Agent.Sdk/Agent.Sdk.csproj b/src/Agent.Sdk/Agent.Sdk.csproj index 25630c0443..fed648de0b 100644 --- a/src/Agent.Sdk/Agent.Sdk.csproj +++ b/src/Agent.Sdk/Agent.Sdk.csproj @@ -3,15 +3,15 @@ Library + true - + - \ No newline at end of file diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index 35dd015be9..950708d5ba 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -451,5 +451,12 @@ public class AgentKnobs "Forces the agent to fetch list of .NET 6 supporting systems from server", new EnvironmentKnobSource("AGENT_ENABLE_FETCHING_NET6_LIST"), new BuiltInDefaultKnobSource("false")); + + public static readonly Knob ForceCreateTasksDirectory = new Knob( + nameof(ForceCreateTasksDirectory), + "Forces the agent to create _tasks folder for tasks.", + new RuntimeKnobSource("AGENT_FORCE_CREATE_TASKS_DIRECTORY"), + new EnvironmentKnobSource("AGENT_FORCE_CREATE_TASKS_DIRECTORY"), + new BuiltInDefaultKnobSource("false")); } } diff --git a/src/Agent.Sdk/Util/PlatformUtil.cs b/src/Agent.Sdk/Util/PlatformUtil.cs index 37590a1f89..9cb7304310 100644 --- a/src/Agent.Sdk/Util/PlatformUtil.cs +++ b/src/Agent.Sdk/Util/PlatformUtil.cs @@ -391,7 +391,7 @@ public static bool DetectDockerContainer() } } } - catch (Exception ex) + catch (Exception) { // Logging exception will be handled by JobRunner throw; @@ -411,7 +411,7 @@ public static bool DetectAzureVM() if (metadataProvider.HasMetadata()) isAzureVM = true; } - catch (Exception ex) + catch (Exception) { // Logging exception will be handled by JobRunner throw; diff --git a/src/Agent.Worker/Agent.Worker.csproj b/src/Agent.Worker/Agent.Worker.csproj index 9172bf1f75..3328d9276a 100644 --- a/src/Agent.Worker/Agent.Worker.csproj +++ b/src/Agent.Worker/Agent.Worker.csproj @@ -4,6 +4,7 @@ Exe + true @@ -14,7 +15,6 @@ - diff --git a/src/Agent.Worker/ExecutionContext.cs b/src/Agent.Worker/ExecutionContext.cs index 2f9c3ddfc7..9bde7ea22f 100644 --- a/src/Agent.Worker/ExecutionContext.cs +++ b/src/Agent.Worker/ExecutionContext.cs @@ -8,6 +8,7 @@ using System.Collections.Specialized; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Web; @@ -262,8 +263,11 @@ public void Start(string currentOperation = null) { var buildLogsJobFolder = Path.Combine(_buildLogsFolderPath, _mainTimelineId.ToString()); Directory.CreateDirectory(buildLogsJobFolder); + string pattern = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); + Regex regex = new Regex(string.Format("[{0}]", Regex.Escape(pattern))); + var recordName = regex.Replace(_record.Name, string.Empty); - _buildLogsFile = Path.Combine(buildLogsJobFolder, $"{_record.Name}-{_record.Id.ToString()}.log"); + _buildLogsFile = Path.Combine(buildLogsJobFolder, $"{recordName}-{_record.Id.ToString()}.log"); _buildLogsData = new FileStream(_buildLogsFile, FileMode.CreateNew); _buildLogsWriter = new StreamWriter(_buildLogsData, System.Text.Encoding.UTF8); diff --git a/src/Agent.Worker/JobExtension.cs b/src/Agent.Worker/JobExtension.cs index 4f556dc94b..ff40e64b44 100644 --- a/src/Agent.Worker/JobExtension.cs +++ b/src/Agent.Worker/JobExtension.cs @@ -146,6 +146,22 @@ public async Task> InitializeJob(IExecutionContext jobContext, Pipel Trace.Info($"Run initial step from extension {this.GetType().Name}."); InitializeJobExtension(context, message?.Steps, message?.Workspace); + if (AgentKnobs.ForceCreateTasksDirectory.GetValue(context).AsBoolean()) + { + var tasksDir = HostContext.GetDirectory(WellKnownDirectory.Tasks); + try + { + Trace.Info($"Pre-creating {tasksDir} directory"); + Directory.CreateDirectory(tasksDir); + IOUtil.ValidateExecutePermission(tasksDir); + } + catch (Exception ex) + { + Trace.Error(ex); + context.Error(ex); + } + } + // Download tasks if not already in the cache Trace.Info("Downloading task definitions."); var taskManager = HostContext.GetService(); @@ -639,7 +655,8 @@ private void OutputSetupInfo(IExecutionContext context) } } - public class UnsupportedOsException : Exception { + public class UnsupportedOsException : Exception + { public UnsupportedOsException(string message) : base(message) { } } } \ No newline at end of file diff --git a/src/Common.props b/src/Common.props index f86030796a..535fa1bddc 100644 --- a/src/Common.props +++ b/src/Common.props @@ -10,7 +10,7 @@ OS_UNKNOWN ARCH_UNKNOWN - 0.5.181-private + 0.5.183-private $(CodeAnalysis) false diff --git a/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobFileInfo.cs b/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobFileInfo.cs index 9e1906547e..56b61483f6 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobFileInfo.cs +++ b/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobFileInfo.cs @@ -13,7 +13,7 @@ public DedupIdentifier DedupId { get { - return Node.GetDedupIdentifier(HashType.Dedup64K); + return Node.GetDedupIdentifier(); } } public bool Success { get; set; } diff --git a/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobStoreUtils.cs b/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobStoreUtils.cs index 662ed20a92..56928caca8 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobStoreUtils.cs +++ b/src/Microsoft.VisualStudio.Services.Agent/Blob/BlobStoreUtils.cs @@ -43,7 +43,7 @@ public static class BlobStoreUtils foreach (var file in fileNodes.Where(x => x.Success)) { // ChunkHelper uses 64k block default size - var dedupId = file.Node.GetDedupIdentifier(HashType.Dedup64K); + var dedupId = file.Node.GetDedupIdentifier(); fileDedupIds[dedupId] = file.Path; } @@ -180,7 +180,7 @@ private static DedupNode CreateNodeToUpload(IEnumerable nodes) var chunk = await ChunkerHelper.CreateFromFileAsync(FileSystem.Instance, itemPath, cancellationToken, false); var rootNode = new DedupNode(new[] { chunk }); // ChunkHelper uses 64k block default size - var dedupId = rootNode.GetDedupIdentifier(HashType.Dedup64K); + var dedupId = rootNode.GetDedupIdentifier(); // Setup upload session to keep file for at mimimum one day // Blobs will need to be associated with the server with an ID ref otherwise they will be diff --git a/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj b/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj index 85fa0623ca..30103259b4 100644 --- a/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj +++ b/src/Microsoft.VisualStudio.Services.Agent/Microsoft.VisualStudio.Services.Agent.csproj @@ -4,6 +4,7 @@ Library + true @@ -13,8 +14,7 @@ - - + diff --git a/src/Test/L1/Mock/FakeJobServer.cs b/src/Test/L1/Mock/FakeJobServer.cs index c19de4341b..c69c153457 100644 --- a/src/Test/L1/Mock/FakeJobServer.cs +++ b/src/Test/L1/Mock/FakeJobServer.cs @@ -142,7 +142,7 @@ public Task UploadLogToBlobStore(Stream blob, string h UploadedAttachmentBlobFiles.Add(itemPath); var chunk = await ChunkerHelper.CreateFromFileAsync(FileSystem.Instance, itemPath, cancellationToken, false); var rootNode = new DedupNode(new[] { chunk }); - var dedupId = rootNode.GetDedupIdentifier(HashType.Dedup64K); + var dedupId = rootNode.GetDedupIdentifier(); return (dedupId, rootNode.TransitiveContentBytes); } diff --git a/src/Test/Test.csproj b/src/Test/Test.csproj index b3f8cf3b98..3d4ff03b59 100644 --- a/src/Test/Test.csproj +++ b/src/Test/Test.csproj @@ -8,13 +8,16 @@ + + true + + - diff --git a/src/agentversion b/src/agentversion index 9ca90a026f..e6501e63d0 100644 --- a/src/agentversion +++ b/src/agentversion @@ -1 +1 @@ -3.220.0 \ No newline at end of file +2.999.999 \ No newline at end of file