diff --git a/TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1 b/TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1 index c6d0b144..2ae12255 100644 --- a/TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1 +++ b/TeamscaleEmbeddedResourceUpdater/TeamscaleResourceUpdate.ps1 @@ -43,13 +43,17 @@ function Update-ResxFile { $dataNode.InnerXml = "$value" # Add or update the 'Project' property - $projectNode = $resxXml.SelectSingleNode("/root/data[@name='Project']") - if ($projectNode -eq $null) { - $projectNode = $resxXml.CreateElement("data") - $projectNode.SetAttribute("name", 'Project') - $rootNode.AppendChild($projectNode) + if ($project -ne $null) { + + $projectNode = $resxXml.SelectSingleNode("/root/data[@name='Project']") + if ($projectNode -eq $null) { + $projectNode = $resxXml.CreateElement("data") + $projectNode.SetAttribute("name", 'Project') + $rootNode.AppendChild($projectNode) + } $projectNode.InnerXml = "$project" } + # Write updated content back to .resx file $resxXml.Save($resxPath) } @@ -65,5 +69,9 @@ if ($revision) { # Update the .resx file Update-ResxFile -resxPath $path -key $key -value $value -project $project -Write-Host "Updated Teamscale Resource with $($key): $($value) and $($project)" +if ($project -eq $null){ + Write-Host "Updated Teamscale Resource with $($key): $($value)" +} else { + Write-Host "Updated Teamscale Resource with $($key): $($value) and $($project)" +} diff --git a/UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs b/UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs index 6072f9a0..af4455d8 100644 --- a/UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs +++ b/UploadDaemon/SymbolAnalysis/ParsedTraceFile.cs @@ -81,11 +81,12 @@ private void SearchForEmbeddedUploadTargets() foreach ((_, string path) in this.LoadedAssemblies) { Assembly assembly = LoadAssemblyFromPath(path); - if (assembly == null || assembly.DefinedTypes == null) + IEnumerable definedTypes = assembly.DefinedTypes; + if(assembly == null || definedTypes == null) { continue; } - TypeInfo teamscaleResourceType = assembly.DefinedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null; + TypeInfo teamscaleResourceType = definedTypes.FirstOrDefault(x => x.Name == TeamscaleResourceName) ?? null; if (teamscaleResourceType == null) { continue; @@ -141,10 +142,13 @@ private Assembly LoadAssemblyFromPath(string path) try { assembly = Assembly.LoadFrom(path); + // Check that defined types can actually be loaded (this is implicetly a null check as well) + IEnumerable definedTypes = assembly.DefinedTypes; } catch (Exception e) { logger.Warn("Could not load {assembly}. Skipping upload resource discovery. {e}", path, e); + return null; } return assembly; } diff --git a/UploadDaemon/Upload/MessageFormatter.cs b/UploadDaemon/Upload/MessageFormatter.cs index d1526ad5..56c1067f 100644 --- a/UploadDaemon/Upload/MessageFormatter.cs +++ b/UploadDaemon/Upload/MessageFormatter.cs @@ -36,7 +36,7 @@ public string Format(string assemblyVersion) public string Format(RevisionFileUtils.RevisionOrTimestamp revision) { string formattedTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); - return server.Message.Replace("version %v", revision.GetType() + " " + revision.Value).Replace("%p", server.Partition).Replace("%t", formattedTime); + return server.Message.Replace("version %v", revision.ToRevisionFileContent()).Replace("%p", server.Partition).Replace("%t", formattedTime); } } } diff --git a/documentation/userguide.md b/documentation/userguide.md index 87e37ca0..cb8fadf8 100644 --- a/documentation/userguide.md +++ b/documentation/userguide.md @@ -360,7 +360,7 @@ This is an example how to integrate it into an Azure DevOps Pipeline: displayName: 'Update Teamscale Resource' workingDirectory: $(Build.Repository.LocalPath) -**_Note:_** The Teamscale Resource can work in combination with a revision file. So you can create a resource for your libraries and add a revision/uploadTarget file for your "main" application. +**_Note:_** The Teamscale Resource can work in combination with a revision file. So you can create a resource for your libraries and add a revision file for your "main" application. Finally, please configure sensible `assemblyPatterns` in order to only include your application's assemblies in the coverage analysis. This prevents lots of useless error log entries both in the