|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using Microsoft.Build.Framework; |
|
|
|
@ -10,9 +11,10 @@ namespace Avalonia.Build.Tasks |
|
|
|
public bool Execute() |
|
|
|
{ |
|
|
|
Enum.TryParse(ReportImportance, true, out MessageImportance outputImportance); |
|
|
|
var writtenFilePaths = new List<string>(); |
|
|
|
|
|
|
|
OutputPath = OutputPath ?? AssemblyFile; |
|
|
|
RefOutputPath = RefOutputPath ?? RefAssemblyFile; |
|
|
|
OutputPath ??= AssemblyFile; |
|
|
|
RefOutputPath ??= RefAssemblyFile; |
|
|
|
var outputPdb = GetPdbPath(OutputPath); |
|
|
|
var input = AssemblyFile; |
|
|
|
var refInput = RefOutputPath; |
|
|
|
@ -21,8 +23,9 @@ namespace Avalonia.Build.Tasks |
|
|
|
if (OriginalCopyPath != null) |
|
|
|
{ |
|
|
|
var originalCopyPathRef = Path.ChangeExtension(OriginalCopyPath, ".ref.dll"); |
|
|
|
|
|
|
|
|
|
|
|
File.Copy(AssemblyFile, OriginalCopyPath, true); |
|
|
|
writtenFilePaths.Add(OriginalCopyPath); |
|
|
|
input = OriginalCopyPath; |
|
|
|
File.Delete(AssemblyFile); |
|
|
|
|
|
|
|
@ -30,6 +33,7 @@ namespace Avalonia.Build.Tasks |
|
|
|
{ |
|
|
|
var copyPdb = GetPdbPath(OriginalCopyPath); |
|
|
|
File.Copy(inputPdb, copyPdb, true); |
|
|
|
writtenFilePaths.Add(copyPdb); |
|
|
|
File.Delete(inputPdb); |
|
|
|
inputPdb = copyPdb; |
|
|
|
} |
|
|
|
@ -39,6 +43,7 @@ namespace Avalonia.Build.Tasks |
|
|
|
// We also copy ref assembly just for case if needed later for testing.
|
|
|
|
// But do not remove the original one, as MSBuild actually complains about it with multi-thread compiling.
|
|
|
|
File.Copy(RefAssemblyFile, originalCopyPathRef, true); |
|
|
|
writtenFilePaths.Add(originalCopyPathRef); |
|
|
|
refInput = originalCopyPathRef; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -53,13 +58,25 @@ namespace Avalonia.Build.Tasks |
|
|
|
ProjectDirectory, VerifyIl, DefaultCompileBindings, outputImportance, |
|
|
|
(SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null, SkipXamlCompilation, DebuggerLaunch); |
|
|
|
if (!res.Success) |
|
|
|
{ |
|
|
|
WrittenFilePaths = writtenFilePaths.ToArray(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (!res.WrittenFile) |
|
|
|
{ |
|
|
|
File.Copy(input, OutputPath, true); |
|
|
|
if(File.Exists(inputPdb)) |
|
|
|
if (File.Exists(inputPdb)) |
|
|
|
File.Copy(inputPdb, outputPdb, true); |
|
|
|
} |
|
|
|
else if (!string.IsNullOrWhiteSpace(RefOutputPath) && File.Exists(RefOutputPath)) |
|
|
|
writtenFilePaths.Add(RefOutputPath); |
|
|
|
|
|
|
|
writtenFilePaths.Add(OutputPath); |
|
|
|
if (File.Exists(outputPdb)) |
|
|
|
writtenFilePaths.Add(outputPdb); |
|
|
|
|
|
|
|
WrittenFilePaths = writtenFilePaths.ToArray(); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@ -103,5 +120,8 @@ namespace Avalonia.Build.Tasks |
|
|
|
public ITaskHost HostObject { get; set; } |
|
|
|
|
|
|
|
public bool DebuggerLaunch { get; set; } |
|
|
|
|
|
|
|
[Output] |
|
|
|
public string[] WrittenFilePaths { get; private set; } = Array.Empty<string>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|