From e9e6d8fc3965c1c81c4cad2b0e02b15a7aa7f764 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Tue, 16 Apr 2024 03:17:13 +0000 Subject: [PATCH 1/2] dotnet-svcutil: write generated json file using relative path for referenced assembly --- .../lib/src/Shared/Options/UpdateOptions.cs | 22 +++++++++++++++++++ .../lib/src/Shared/ProjectDependency.cs | 6 ++--- .../dotnet-svcutil.params.json | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index 8fe3eee7ffb..38321f27a4e 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -103,6 +103,16 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = new Uri(relPath, UriKind.Relative); } } + + // Update references + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) + { + this.References[idx].ReferenceIdentity = PathHelper.GetRelativePath(reference.FullPath, optionsFileDirectory, out relPath) ? relPath : reference.FullPath; + } + } } public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) @@ -122,6 +132,18 @@ public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = fileUri; } } + + // Update references full path + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) + { + string fullPath = Path.GetFullPath(Path.Combine(optionsFileDirectory.FullName, reference.ReferenceIdentity)); + this.References[idx].FullPath = fullPath; + this.References[idx].ReferenceIdentity = fullPath; + } + } } } } diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index 8e392855b6f..4ba6b138400 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -43,7 +43,7 @@ internal class ProjectDependency : IComparable /// /// Assembly full path. /// - public string FullPath { get; private set; } + public string FullPath { get; set; } /// /// Assembly name. @@ -63,7 +63,7 @@ internal class ProjectDependency : IComparable /// /// The package identity, used for describing the dependency passed to Svcutil. /// - public string ReferenceIdentity { get; private set; } + public string ReferenceIdentity { get; set; } #region instance contruction methods // this ctr is private to ensure the integrity of the data which can be done only by the provided static instance creation (FromXXX) methods. @@ -153,7 +153,7 @@ private ProjectDependency(string filePath = "", string packageName = "", string this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ? string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) : - this.FullPath; + filePath; this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID; } 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 db493e18ee4..04374f6339f 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" + "../bin/Debug/net6.0/BinLib.dll" ], "targetFramework": "N.N", "typeReuseMode": "All" From 06111a4d49a568e1869699b3502f3ca310ef8da1 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Thu, 11 Jun 2026 14:27:06 +0800 Subject: [PATCH 2/2] Update test baselines after rebase and bump TFMs in MultiTargetTypeReuse Follow-up to the dotnet-svcutil fix that writes referenced assembly paths relative to the params.json file (issue #5495): - ReuseIXmlSerializableType: this test was added on main after PR #5500 was opened; update its baseline params.json so the CommonTypes.dll reference matches the relative path now emitted by svcutil. - MultiTargetTypeReuse: bump TypeReuseClient TFMs from net6.0;net7.0 (both out of support) to net10.0;net8.0, and update the baseline csproj and params.json (bin/Debug/net10.0/BinLib.dll) accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ServiceReference/dotnet-svcutil.params.json | 2 +- .../TypeReuseClient/TypeReuseClient.csproj | 4 +--- .../ServiceReference/dotnet-svcutil.params.json | 2 +- .../TypeReuseClient/TypeReuseClient.csproj | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) 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 04374f6339f..e57502a6d54 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": [ - "../bin/Debug/net6.0/BinLib.dll" + "../bin/Debug/net10.0/BinLib.dll" ], "targetFramework": "N.N", "typeReuseMode": "All" diff --git a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj index b4229d93d02..aa4272f215c 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj +++ b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj @@ -2,7 +2,7 @@ Exe - net6.0;net7.0 + net10.0;net8.0 @@ -13,7 +13,5 @@ - - \ No newline at end of file diff --git a/src/dotnet-svcutil/lib/tests/Baselines/ReuseIXmlSerializableType/ReuseIXmlSerializableType/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/ReuseIXmlSerializableType/ReuseIXmlSerializableType/ServiceReference/dotnet-svcutil.params.json index e0cc04dd28f..e6ffb58430e 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/ReuseIXmlSerializableType/ReuseIXmlSerializableType/ServiceReference/dotnet-svcutil.params.json +++ b/src/dotnet-svcutil/lib/tests/Baselines/ReuseIXmlSerializableType/ReuseIXmlSerializableType/ServiceReference/dotnet-svcutil.params.json @@ -10,7 +10,7 @@ ], "outputFile": "Reference.cs", "references": [ - "$testCasesPath$//TypeReuse//CommonTypes.dll" + "../../../../../../src/dotnet-svcutil/lib/tests/TestCases/TypeReuse/CommonTypes.dll" ], "targetFramework": "N.N", "typeReuseMode": "Specified" diff --git a/src/dotnet-svcutil/lib/tests/TestCases/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj b/src/dotnet-svcutil/lib/tests/TestCases/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj index 256904df2a5..691e3960de7 100644 --- a/src/dotnet-svcutil/lib/tests/TestCases/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj +++ b/src/dotnet-svcutil/lib/tests/TestCases/MultiTargetTypeReuse/TypeReuseClient/TypeReuseClient.csproj @@ -2,7 +2,7 @@ Exe - net6.0;net7.0 + net10.0;net8.0