Пример #1
0
        // Same as TryGetProject but it doesn't throw
        private bool TryGetProject(string projectFile, out ProjectModel.Project project, out string errorMessage)
        {
            try
            {
                if (!ProjectReader.TryGetProject(projectFile, out project))
                {
                    if (project?.Diagnostics != null && project.Diagnostics.Any())
                    {
                        errorMessage = string.Join(Environment.NewLine, project.Diagnostics.Select(e => e.ToString()));
                    }
                    else
                    {
                        errorMessage = "Failed to read project.json";
                    }
                }
                else
                {
                    errorMessage = null;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                errorMessage = CollectMessages(ex);
            }

            project = null;
            return(false);
        }
Пример #2
0
        public Project(ProjectModel.Project runtimeProject)
        {
            ProjectFile      = runtimeProject.ProjectFilePath;
            ProjectDirectory = runtimeProject.ProjectDirectory;

            var compilerOptions = runtimeProject.GetCompilerOptions(targetFramework: null, configurationName: null);

            var filesToWatch = new List <string>()
            {
                runtimeProject.ProjectFilePath
            };

            if (compilerOptions?.CompileInclude != null)
            {
                filesToWatch.AddRange(compilerOptions.CompileInclude.ResolveFiles());
            }
            else
            {
                filesToWatch.AddRange(runtimeProject.Files.SourceFiles);
            }

            if (compilerOptions?.EmbedInclude != null)
            {
                filesToWatch.AddRange(compilerOptions.EmbedInclude.ResolveFiles());
            }
            else
            {
                filesToWatch.AddRange(runtimeProject.Files.ResourceFiles.Values);
            }

            filesToWatch.AddRange(runtimeProject.Files.SharedFiles);
            filesToWatch.AddRange(runtimeProject.Files.PreprocessSourceFiles);

            Files = filesToWatch;

            var projectLockJsonPath = Path.Combine(runtimeProject.ProjectDirectory, "project.lock.json");

            if (File.Exists(projectLockJsonPath))
            {
                var lockFile = LockFileReader.Read(projectLockJsonPath, designTime: false);
                ProjectDependencies = lockFile.ProjectLibraries.Select(dep => GetProjectRelativeFullPath(dep.Path)).ToList();
            }
            else
            {
                ProjectDependencies = new string[0];
            }
        }
Пример #3
0
        // Same as TryGetProject but it doesn't throw
        private bool TryGetProject(string projectFile, out ProjectModel.Project project, out string errorMessage)
        {
            try
            {
                var errors = new List <DiagnosticMessage>();
                if (!ProjectReader.TryGetProject(projectFile, out project, errors))
                {
                    errorMessage = string.Join(Environment.NewLine, errors.Select(e => e.ToString()));
                }
                else
                {
                    errorMessage = null;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                errorMessage = CollectMessages(ex);
            }

            project = null;
            return(false);
        }
Пример #4
0
        public Project(ProjectModel.Project runtimeProject)
        {
            ProjectFile      = runtimeProject.ProjectFilePath;
            ProjectDirectory = runtimeProject.ProjectDirectory;

            Files = runtimeProject.Files.SourceFiles.Concat(
                runtimeProject.Files.ResourceFiles.Values.Concat(
                    runtimeProject.Files.PreprocessSourceFiles.Concat(
                        runtimeProject.Files.SharedFiles))).Concat(
                new string[] { runtimeProject.ProjectFilePath })
                    .ToList();

            var projectLockJsonPath = Path.Combine(runtimeProject.ProjectDirectory, "project.lock.json");

            if (File.Exists(projectLockJsonPath))
            {
                var lockFile = LockFileReader.Read(projectLockJsonPath, designTime: false);
                ProjectDependencies = lockFile.ProjectLibraries.Select(dep => GetProjectRelativeFullPath(dep.Path)).ToList();
            }
            else
            {
                ProjectDependencies = new string[0];
            }
        }
Пример #5
0
 public void AddProject(ProjectModel.Project project)
 {
     throw new NotImplementedException();
 }