Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet-svcutil: write generated json file with relative path for referenced assembly. #5500

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,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)
Expand All @@ -116,6 +126,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;
}
}
}
}
}
6 changes: 3 additions & 3 deletions src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal class ProjectDependency : IComparable<ProjectDependency>
/// <summary>
/// Assembly full path.
/// </summary>
public string FullPath { get; private set; }
public string FullPath { get; set; }

/// <summary>
/// Assembly name.
Expand All @@ -63,7 +63,7 @@ internal class ProjectDependency : IComparable<ProjectDependency>
/// <summary>
/// The package identity, used for describing the dependency passed to Svcutil.
/// </summary>
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.
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading