Skip to content

Commit 922458c

Browse files
authored
.NET Core WPF Build error on custom BaseIntermediateOutputPath #1718 (#3120)
* Use more robust relative path calculation in markup code generation
1 parent cd95e7a commit 922458c

File tree

3 files changed

+389
-13
lines changed

3 files changed

+389
-13
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,19 +1575,11 @@ private string ParentFolderPrefix
15751575
{
15761576
get
15771577
{
1578-
string parentFolderPrefix = string.Empty;
1579-
if (TargetPath.StartsWith(SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase))
1580-
{
1581-
string relPath = TargetPath.Substring(SourceFileInfo.SourcePath.Length);
1582-
relPath += SourceFileInfo.RelativeSourceFilePath;
1583-
string[] dirs = relPath.Split(new Char[] { Path.DirectorySeparatorChar });
1584-
for (int i = 1; i < dirs.Length; i++)
1585-
{
1586-
parentFolderPrefix += PARENTFOLDER;
1587-
}
1588-
}
1589-
1590-
return parentFolderPrefix;
1578+
#if NETFX
1579+
return PathInternal.GetRelativePath(TargetPath, SourceFileInfo.SourcePath, StringComparison.OrdinalIgnoreCase);
1580+
#else
1581+
return Path.GetRelativePath(TargetPath, SourceFileInfo.SourcePath);
1582+
#endif
15911583
}
15921584
}
15931585

0 commit comments

Comments
 (0)