Skip to content

Commit fd19bf8

Browse files
authored
Make assembly version logic more robust Fixes #44042 (#45518)
Fixes #44042 Replaces the way we look for assembly version.
1 parent 4ab59c9 commit fd19bf8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,12 +537,10 @@ private RuntimeLibrary GetRuntimeLibrary(DependencyLibrary library, string[] use
537537
{
538538
var fileName = Path.GetFileNameWithoutExtension(library.Path);
539539
var assemblyPath = userRuntimeAssemblies?.FirstOrDefault(p => Path.GetFileNameWithoutExtension(p).Equals(fileName));
540-
runtimeAssemblyGroups.Add(new RuntimeAssetGroup(string.Empty,
541-
[ new RuntimeFile(
542-
referenceProjectInfo.OutputName,
543-
library.Version.ToString(),
544-
assemblyPath is null || !File.Exists(assemblyPath) ? string.Empty : FileVersionInfo.GetVersionInfo(assemblyPath).FileVersion)
545-
]));
540+
var runtimeFile = !string.IsNullOrWhiteSpace(assemblyPath) && File.Exists(assemblyPath) ? CreateRuntimeFile(referenceProjectInfo.OutputName, assemblyPath) :
541+
!string.IsNullOrWhiteSpace(library.Path) && File.Exists(library.Path) ? CreateRuntimeFile(referenceProjectInfo.OutputName, library.Path) :
542+
new RuntimeFile(referenceProjectInfo.OutputName, string.Empty, string.Empty);
543+
runtimeAssemblyGroups.Add(new RuntimeAssetGroup(string.Empty, [runtimeFile]));
546544

547545
resourceAssemblies.AddRange(referenceProjectInfo.ResourceAssemblies
548546
.Select(r => new ResourceAssembly(r.RelativePath, r.Culture)));

0 commit comments

Comments
 (0)