public bool Execute()
        {
            Enum.TryParse(ReportImportance, true, out MessageImportance outputImportance);

            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 msg = $"CompileAvaloniaXamlTask -> AssemblyFile:{AssemblyFile}, ProjectDirectory:{ProjectDirectory}, OutputPath:{OutputPath}";

            BuildEngine.LogMessage(msg, outputImportance < MessageImportance.Low ? MessageImportance.High : outputImportance);

            var res = XamlCompilerTaskExecutor.Compile(BuildEngine, input,
                                                       File.ReadAllLines(ReferencesFilePath).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray(),
                                                       ProjectDirectory, OutputPath, VerifyIl, outputImportance,
                                                       (SignAssembly && !DelaySign) ? AssemblyOriginatorKeyFile : null,
                                                       EnableComInteropPatching, SkipXamlCompilation, DebuggerLaunch);

            if (!res.Success)
            {
                return(false);
            }
            if (!res.WrittenFile)
            {
                File.Copy(input, OutputPath, true);
                if (File.Exists(inputPdb))
                {
                    File.Copy(inputPdb, outputPdb, true);
                }
            }
            return(true);
        }
Exemple #2
0
        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,
                                                       File.ReadAllLines(ReferencesFilePath).Where(l => !string.IsNullOrWhiteSpace(l)).ToArray(),
                                                       ProjectDirectory, OutputPath, VerifyIl);

            if (!res.Success)
            {
                return(false);
            }
            if (!res.WrittenFile)
            {
                File.Copy(input, OutputPath, true);
                if (File.Exists(inputPdb))
                {
                    File.Copy(inputPdb, outputPdb, true);
                }
            }
            return(true);
        }