Skip to content

Commit 8796083

Browse files
CopilotAndriySvyryd
andcommitted
Consolidate path normalization in Project.cs
Move path normalization for OutputPath to Project.FromFile() so that the OutputPath property is already normalized when used in RootCommand.cs. This removes duplicated path normalization logic. Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
1 parent 7b3adaa commit 8796083

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

src/dotnet-ef/Project.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public static Project FromFile(
102102
.FirstOrDefault(i => i.Contains("Microsoft.EntityFrameworkCore.Design", StringComparison.InvariantCulture));
103103
var properties = metadata.Properties;
104104

105-
var outputPath = Path.GetFullPath(Path.Combine(properties[nameof(ProjectDir)]!, properties[nameof(OutputPath)]!))
106-
.Replace('\\', Path.DirectorySeparatorChar);
105+
var normalizedOutputPath = properties[nameof(OutputPath)]!.Replace('\\', Path.DirectorySeparatorChar);
106+
var outputPath = Path.GetFullPath(Path.Combine(properties[nameof(ProjectDir)]!, normalizedOutputPath));
107107
CopyBuildHost(runtimeCopyLocalItems, outputPath);
108108

109109
var platformTarget = properties[nameof(PlatformTarget)];
@@ -117,7 +117,7 @@ public static Project FromFile(
117117
AssemblyName = properties[nameof(AssemblyName)],
118118
DesignAssembly = designAssembly,
119119
Language = properties[nameof(Language)],
120-
OutputPath = properties[nameof(OutputPath)],
120+
OutputPath = normalizedOutputPath,
121121
PlatformTarget = platformTarget,
122122
ProjectAssetsFile = properties[nameof(ProjectAssetsFile)],
123123
ProjectDir = properties[nameof(ProjectDir)],

src/dotnet-ef/RootCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ protected override int Execute(string[] _)
9595
Path.GetDirectoryName(typeof(Program).Assembly.Location)!,
9696
"tools");
9797

98-
var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir!, startupProject.OutputPath!))
99-
.Replace('\\', Path.DirectorySeparatorChar);
98+
var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir!, startupProject.OutputPath!));
10099
var targetPath = Path.Combine(targetDir, project.TargetFileName!);
101100
var startupTargetPath = Path.Combine(targetDir, startupProject.TargetFileName!);
102101
var depsFile = Path.Combine(

0 commit comments

Comments
 (0)