Exemplo n.º 1
0
        public CompileResult Compile(AmmyProject project, bool generateMetaFile = false, bool needBamlGeneration = false, bool needUpdate = true)
        {
            var compileResult = new CompileResult(needBamlGeneration)
            {
                AmmyProject = project
            };

            if (project.ProjectSupport == null)
            {
                return(compileResult);
            }

            try {
                if (project.MissingFiles.Count > 0)
                {
                    foreach (var missingFile in project.MissingFiles)
                    {
                        compileResult.AddError(missingFile + " does not exist.");
                    }

                    return(compileResult);
                }

                foreach (var file in project.Files)
                {
                    compileResult.Files.Add(file);
                }

                compileResult.CompilationData = project.RefreshReferences();

                project.Context.ProjectDir        = project.FsProject.ProjectDir;
                project.Context.SourceCodeProject = project.CSharpProject;
                project.Context.NeedUpdate        = project.Platform.SupportsRuntimeUpdate && needUpdate;

                project.RefreshProject(project.OutputPath, project.RootNamespace, project.AssemblyName);

                EnsureOutputDirectoryExists(project.OutputPath.ToAbsolutePath(project.FsProject.ProjectDir));

                var anyErrors        = compileResult.CompilerMessages.Any(msg => msg.Type == CompilerMessageType.Error || msg.Type == CompilerMessageType.FatalError);
                var fileOutputWriter = new FileOutputWriter(compileResult, project.Context, project.Files, project.FsProject.ProjectDir, project.OutputPath);
                var bamlCompiler     = new BamlCompiler(_isMsBuildCompilation);

                if (!anyErrors)
                {
                    fileOutputWriter.WriteFiles(generateMetaFile);

                    if (needBamlGeneration)
                    {
                        bamlCompiler.CompileBamlFiles(compileResult, project);
                    }
                }
            } catch (Exception e) {
                compileResult.AddError("Ammy compilation error: " + e);
            }

            return(compileResult);
        }
Exemplo n.º 2
0
        public void GenerateXamlFiles(CompileResult compileResult, bool generateMetaFile)
        {
            var fileOutputWriter = new FileOutputWriter(compileResult);

            fileOutputWriter.WriteFiles(generateMetaFile);
        }