|
|
|
@ -2,6 +2,7 @@ using System; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Threading; |
|
|
|
using Microsoft.Build.Framework; |
|
|
|
|
|
|
|
@ -12,13 +13,23 @@ namespace Avalonia.Build.Tasks |
|
|
|
public bool Execute() |
|
|
|
{ |
|
|
|
OutputPath = OutputPath ?? AssemblyFile; |
|
|
|
var outputPdb = GetPdbPath(OutputPath); |
|
|
|
var input = AssemblyFile; |
|
|
|
var inputPdb = GetPdbPath(input); |
|
|
|
// Make a copy and delete the original file to prevent MSBuild from thinking that everything is OK
|
|
|
|
if (OriginalCopyPath != null) |
|
|
|
{ |
|
|
|
File.Copy(AssemblyFile, OriginalCopyPath, true); |
|
|
|
input = OriginalCopyPath; |
|
|
|
File.Delete(AssemblyFile); |
|
|
|
|
|
|
|
if (File.Exists(inputPdb)) |
|
|
|
{ |
|
|
|
var copyPdb = GetPdbPath(OriginalCopyPath); |
|
|
|
File.Copy(inputPdb, copyPdb, true); |
|
|
|
File.Delete(inputPdb); |
|
|
|
inputPdb = copyPdb; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var res = XamlCompilerTaskExecutor.Compile(BuildEngine, input, |
|
|
|
@ -27,14 +38,30 @@ namespace Avalonia.Build.Tasks |
|
|
|
if (!res.Success) |
|
|
|
return false; |
|
|
|
if (res.Data == null) |
|
|
|
File.Copy(input, OutputPath); |
|
|
|
{ |
|
|
|
File.Copy(input, OutputPath, true); |
|
|
|
if(File.Exists(inputPdb)) |
|
|
|
File.Copy(inputPdb, OutputPath, true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
File.WriteAllBytes(OutputPath, res.Data); |
|
|
|
if (res.Symbols != null) |
|
|
|
File.WriteAllBytes(outputPdb, res.Symbols); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string GetPdbPath(string p) |
|
|
|
{ |
|
|
|
var d = Path.GetDirectoryName(p); |
|
|
|
var f = Path.GetFileNameWithoutExtension(p); |
|
|
|
var rv = f + ".pdb"; |
|
|
|
if (d != null) |
|
|
|
rv = Path.Combine(d, rv); |
|
|
|
return rv; |
|
|
|
} |
|
|
|
|
|
|
|
[Required] |
|
|
|
public string AssemblyFile { get; set; } |
|
|
|
|