Skip to content

Commit ee27d2f

Browse files
committed
dotnet-svcutil: write generated json file using relative path for referenced assembly
1 parent daf69b8 commit ee27d2f

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory)
100100
this.Inputs[idx] = new Uri(relPath, UriKind.Relative);
101101
}
102102
}
103+
104+
// Update references
105+
for (int idx = 0; idx < this.References.Count; idx++)
106+
{
107+
var reference = this.References[idx];
108+
if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary)
109+
{
110+
this.References[idx].ReferenceIdentity = PathHelper.GetRelativePath(reference.FullPath, optionsFileDirectory, out relPath) ? relPath : reference.FullPath;
111+
}
112+
}
103113
}
104114

105115
public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory)
@@ -119,6 +129,18 @@ public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory)
119129
this.Inputs[idx] = fileUri;
120130
}
121131
}
132+
133+
// Update references full path
134+
for (int idx = 0; idx < this.References.Count; idx++)
135+
{
136+
var reference = this.References[idx];
137+
if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary)
138+
{
139+
string fullPath = Path.GetFullPath(Path.Combine(optionsFileDirectory.FullName, reference.ReferenceIdentity));
140+
this.References[idx].FullPath = fullPath;
141+
this.References[idx].ReferenceIdentity = fullPath;
142+
}
143+
}
122144
}
123145
}
124146
}

src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal class ProjectDependency : IComparable<ProjectDependency>
4343
/// <summary>
4444
/// Assembly full path.
4545
/// </summary>
46-
public string FullPath { get; private set; }
46+
public string FullPath { get; set; }
4747

4848
/// <summary>
4949
/// Assembly name.
@@ -63,7 +63,7 @@ internal class ProjectDependency : IComparable<ProjectDependency>
6363
/// <summary>
6464
/// The package identity, used for describing the dependency passed to Svcutil.
6565
/// </summary>
66-
public string ReferenceIdentity { get; private set; }
66+
public string ReferenceIdentity { get; set; }
6767

6868
#region instance contruction methods
6969
// 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
153153

154154
this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ?
155155
string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) :
156-
this.FullPath;
156+
filePath;
157157

158158
this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID;
159159
}

src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"outputFile": "Reference.cs",
1212
"references": [
13-
"$TEMP$MultiTargetTypeReuse//TypeReuseClient//bin//Debug//net6.0//BinLib.dll"
13+
"../bin/Debug/net6.0/BinLib.dll"
1414
],
1515
"targetFramework": "N.N",
1616
"typeReuseMode": "All"

0 commit comments

Comments
 (0)