From f70768c9111bdc3d64d94d72f64894a03b6f629c Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Tue, 16 Apr 2024 03:17:13 +0000 Subject: [PATCH] dotnet-svcutil: write referenced assembly name instead of absolute path to generated json file --- src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs | 7 ++++++- .../lib/src/Shared/Options/UpdateOptions.cs | 10 ++++++++++ .../ServiceReference/dotnet-svcutil.params.json | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index f9b7b294b08a..9a43bb790d3f 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -627,7 +627,12 @@ private async Task ProcessReferencesOptionAsync(CancellationToken cancellationTo { for (int idx = this.References.Count - 1; idx >= 0; idx--) { - if (!references.Contains(this.References[idx])) + var selected = references.Where(x => this.References[idx].Name == x.Name).FirstOrDefault(); + if (selected != null) + { + this.References[idx] = selected; + } + else { this.References.RemoveAt(idx); } diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index b1c5781515d3..017e879fc740 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -97,6 +97,16 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = new Uri(relPath, UriKind.Relative); } } + + //update referenced assembly path + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType.Equals(ProjectDependencyType.Binary)) + { + this.References[idx] = ProjectDependency.FromAssembly(reference.AssemblyName); + } + } } public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) diff --git a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json index db493e18ee4c..0b2ee6e8299a 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json +++ b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json @@ -10,7 +10,7 @@ ], "outputFile": "Reference.cs", "references": [ - "$TEMP$MultiTargetTypeReuse//TypeReuseClient//bin//Debug//net6.0//BinLib.dll" + "BinLib" ], "targetFramework": "N.N", "typeReuseMode": "All"