diff --git a/src/dotnet-ef/Project.cs b/src/dotnet-ef/Project.cs index ee15537fe52..c894ac9d745 100644 --- a/src/dotnet-ef/Project.cs +++ b/src/dotnet-ef/Project.cs @@ -99,10 +99,14 @@ public static Project FromFile( var designAssembly = runtimeCopyLocalItems .Select(i => i["FullPath"]) - .FirstOrDefault(i => i.Contains("Microsoft.EntityFrameworkCore.Design", StringComparison.InvariantCulture)); + .FirstOrDefault(i => i.Contains("Microsoft.EntityFrameworkCore.Design", StringComparison.InvariantCulture)) + ?.Replace('\\', Path.DirectorySeparatorChar); var properties = metadata.Properties; - var outputPath = Path.GetFullPath(Path.Combine(properties[nameof(ProjectDir)]!, properties[nameof(OutputPath)]!)); + var normalizedOutputPath = properties[nameof(OutputPath)]!.Replace('\\', Path.DirectorySeparatorChar); + var normalizedProjectDir = properties[nameof(ProjectDir)]!.Replace('\\', Path.DirectorySeparatorChar); + var normalizedProjectAssetsFile = properties[nameof(ProjectAssetsFile)]?.Replace('\\', Path.DirectorySeparatorChar); + var outputPath = Path.GetFullPath(Path.Combine(normalizedProjectDir, normalizedOutputPath)); CopyBuildHost(runtimeCopyLocalItems, outputPath); var platformTarget = properties[nameof(PlatformTarget)]; @@ -116,10 +120,10 @@ public static Project FromFile( AssemblyName = properties[nameof(AssemblyName)], DesignAssembly = designAssembly, Language = properties[nameof(Language)], - OutputPath = properties[nameof(OutputPath)], + OutputPath = normalizedOutputPath, PlatformTarget = platformTarget, - ProjectAssetsFile = properties[nameof(ProjectAssetsFile)], - ProjectDir = properties[nameof(ProjectDir)], + ProjectAssetsFile = normalizedProjectAssetsFile, + ProjectDir = normalizedProjectDir, RootNamespace = properties[nameof(RootNamespace)], RuntimeFrameworkVersion = properties[nameof(RuntimeFrameworkVersion)], TargetFileName = properties[nameof(TargetFileName)], diff --git a/src/dotnet-ef/RootCommand.cs b/src/dotnet-ef/RootCommand.cs index 686ea398b30..5561d1fb116 100644 --- a/src/dotnet-ef/RootCommand.cs +++ b/src/dotnet-ef/RootCommand.cs @@ -95,8 +95,7 @@ protected override int Execute(string[] _) Path.GetDirectoryName(typeof(Program).Assembly.Location)!, "tools"); - var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir!, startupProject.OutputPath!)) - .Replace('\\', Path.DirectorySeparatorChar); + var targetDir = Path.GetFullPath(Path.Combine(startupProject.ProjectDir!, startupProject.OutputPath!)); var targetPath = Path.Combine(targetDir, project.TargetFileName!); var startupTargetPath = Path.Combine(targetDir, startupProject.TargetFileName!); var depsFile = Path.Combine(