Skip to content

CompileAvaloniaXamlTask - handle no-pdb compilations #15509

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

Merged
merged 2 commits into from
May 2, 2024
Merged
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
14 changes: 12 additions & 2 deletions src/Avalonia.Build.Tasks/CompileAvaloniaXamlTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public bool Execute()
{
// To simplify incremental build checks, copy the input files to the expected output locations even if the Xaml compiler didn't do anything.
CopyAndTouch(AssemblyFile.ItemSpec, outputPath);
CopyAndTouch(Path.ChangeExtension(AssemblyFile.ItemSpec, ".pdb"), Path.ChangeExtension(outputPath, ".pdb"));
CopyAndTouch(Path.ChangeExtension(AssemblyFile.ItemSpec, ".pdb"), Path.ChangeExtension(outputPath, ".pdb"), false);

if (!string.IsNullOrEmpty(refOutputPath))
{
Expand All @@ -49,8 +49,18 @@ public bool Execute()
return res.Success;
}

private static void CopyAndTouch(string source, string destination)
private static void CopyAndTouch(string source, string destination, bool shouldExist = true)
{
if (!File.Exists(source))
{
if (shouldExist)
{
throw new FileNotFoundException($"Could not copy file '{source}'. File does not exist.");
}

return;
}

File.Copy(source, destination, overwrite: true);
File.SetLastWriteTimeUtc(destination, DateTime.UtcNow);
}
Expand Down