Skip to content

Commit

Permalink
CompileAvaloniaXamlTask - handle no-pdb compilations (#15509)
Browse files Browse the repository at this point in the history
* CompileAvaloniaXamlTask - handle no-pdb compilations

* handle PDBs separately
  • Loading branch information
ltetak authored and maxkatz6 committed May 8, 2024
1 parent aa64283 commit f9a9023
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit f9a9023

Please sign in to comment.