Пример #1
0
        internal static Project GetProjectFromStream(Stream stream, string projectName, string projectPath, ICollection <ICompilationMessage> diagnostics = null)
        {
            var project = new Project();

            var reader     = new StreamReader(stream);
            var rawProject = JsonDeserializer.Deserialize(reader) as JsonObject;

            if (rawProject == null)
            {
                throw FileFormatException.Create(
                          "The JSON file can't be deserialized to a JSON object.",
                          projectPath);
            }

            // Meta-data properties
            project.Name            = projectName;
            project.ProjectFilePath = Path.GetFullPath(projectPath);

            var version = rawProject.Value("version") as JsonString;

            if (version == null)
            {
                project.Version = new SemanticVersion("1.0.0");
            }
            else
            {
                try
                {
                    var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION");
                    project.Version = SpecifySnapshot(version, buildVersion);
                }
                catch (Exception ex)
                {
                    throw FileFormatException.Create(ex, version, project.ProjectFilePath);
                }
            }

            var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION");

            if (string.IsNullOrWhiteSpace(fileVersion))
            {
                project.AssemblyFileVersion = project.Version.Version;
            }
            else
            {
                try
                {
                    var simpleVersion = project.Version.Version;
                    project.AssemblyFileVersion = new Version(simpleVersion.Major,
                                                              simpleVersion.Minor,
                                                              simpleVersion.Build,
                                                              int.Parse(fileVersion));
                }
                catch (FormatException ex)
                {
                    throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
                }
            }

            project.Description = rawProject.ValueAsString("description");
            project.Summary     = rawProject.ValueAsString("summary");
            project.Copyright   = rawProject.ValueAsString("copyright");
            project.Title       = rawProject.ValueAsString("title");
            project.WebRoot     = rawProject.ValueAsString("webroot");
            project.EntryPoint  = rawProject.ValueAsString("entryPoint");
            project.ProjectUrl  = rawProject.ValueAsString("projectUrl");
            project.LicenseUrl  = rawProject.ValueAsString("licenseUrl");
            project.IconUrl     = rawProject.ValueAsString("iconUrl");

            project.Authors = rawProject.ValueAsStringArray("authors") ?? new string[] { };
            project.Owners  = rawProject.ValueAsStringArray("owners") ?? new string[] { };
            project.Tags    = rawProject.ValueAsStringArray("tags") ?? new string[] { };

            project.Language     = rawProject.ValueAsString("language");
            project.ReleaseNotes = rawProject.ValueAsString("releaseNotes");

            project.RequireLicenseAcceptance = rawProject.ValueAsBoolean("requireLicenseAcceptance", defaultValue: false);
            project.IsLoadable = rawProject.ValueAsBoolean("loadable", defaultValue: true);
            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = rawProject.ValueAsBoolean("embedInteropTypes", defaultValue: false);

            project.Dependencies = new List <LibraryDependency>();

            // Project files
            project.Files = new ProjectFilesCollection(rawProject,
                                                       project.ProjectDirectory,
                                                       project.ProjectFilePath,
                                                       diagnostics);

            var compilerInfo = rawProject.ValueAsJsonObject("compiler");

            if (compilerInfo != null)
            {
                var languageName     = compilerInfo.ValueAsString("name") ?? "C#";
                var compilerAssembly = compilerInfo.ValueAsString("compilerAssembly");
                var compilerType     = compilerInfo.ValueAsString("compilerType");

                var compiler = new TypeInformation(compilerAssembly, compilerType);
                project.CompilerServices = new CompilerServices(languageName, compiler);
            }

            var commands = rawProject.Value("commands") as JsonObject;

            if (commands != null)
            {
                foreach (var key in commands.Keys)
                {
                    var value = commands.ValueAsString(key);
                    if (value != null)
                    {
                        project.Commands[key] = value;
                    }
                }
            }

            var scripts = rawProject.Value("scripts") as JsonObject;

            if (scripts != null)
            {
                foreach (var key in scripts.Keys)
                {
                    var stringValue = scripts.ValueAsString(key);
                    if (stringValue != null)
                    {
                        project.Scripts[key] = new string[] { stringValue };
                        continue;
                    }

                    var arrayValue = scripts.ValueAsStringArray(key);
                    if (arrayValue != null)
                    {
                        project.Scripts[key] = arrayValue;
                        continue;
                    }

                    throw FileFormatException.Create(
                              string.Format("The value of a script in {0} can only be a string or an array of strings", ProjectFileName),
                              scripts.Value(key),
                              project.ProjectFilePath);
                }
            }

            var repository = rawProject.Value("repository") as JsonObject;

            if (repository != null)
            {
                project.Repository = repository
                                     .Keys
                                     .ToDictionary(
                    key => key,
                    key => repository.ValueAsString(key).Value);
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject, diagnostics);

            PopulateDependencies(
                project.ProjectFilePath,
                project.Dependencies,
                rawProject,
                "dependencies",
                isGacOrFrameworkReference: false);

            return(project);
        }
Пример #2
0
        internal static Project GetProjectFromStream(Stream stream, string projectName, string projectPath, ICollection <ICompilationMessage> diagnostics = null)
        {
            var project = new Project();

            var reader     = new JsonTextReader(new StreamReader(stream));
            var rawProject = JObject.Load(reader);

            // Meta-data properties
            var version      = rawProject["version"];
            var authors      = rawProject["authors"];
            var owners       = rawProject["owners"];
            var tags         = rawProject["tags"];
            var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION");

            project.Name            = projectName;
            project.ProjectFilePath = Path.GetFullPath(projectPath);

            if (version == null)
            {
                project.Version = new SemanticVersion("1.0.0");
            }
            else
            {
                try
                {
                    project.Version = SpecifySnapshot(version.Value <string>(), buildVersion);
                }
                catch (Exception ex)
                {
                    var lineInfo = (IJsonLineInfo)version;

                    throw FileFormatException.Create(ex, version, project.ProjectFilePath);
                }
            }

            var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION");

            if (string.IsNullOrWhiteSpace(fileVersion))
            {
                project.AssemblyFileVersion = project.Version.Version;
            }
            else
            {
                try
                {
                    var simpleVersion = project.Version.Version;
                    project.AssemblyFileVersion = new Version(simpleVersion.Major,
                                                              simpleVersion.Minor,
                                                              simpleVersion.Build,
                                                              int.Parse(fileVersion));
                }
                catch (FormatException ex)
                {
                    throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
                }
            }

            project.Description              = rawProject.GetValue <string>("description");
            project.Summary                  = rawProject.GetValue <string>("summary");
            project.Copyright                = rawProject.GetValue <string>("copyright");
            project.Title                    = rawProject.GetValue <string>("title");
            project.Authors                  = authors == null ? new string[] { } : authors.ValueAsArray <string>();
            project.Owners                   = owners == null ? new string[] { } : owners.ValueAsArray <string>();
            project.Dependencies             = new List <LibraryDependency>();
            project.WebRoot                  = rawProject.GetValue <string>("webroot");
            project.EntryPoint               = rawProject.GetValue <string>("entryPoint");
            project.ProjectUrl               = rawProject.GetValue <string>("projectUrl");
            project.LicenseUrl               = rawProject.GetValue <string>("licenseUrl");
            project.IconUrl                  = rawProject.GetValue <string>("iconUrl");
            project.RequireLicenseAcceptance = rawProject.GetValue <bool?>("requireLicenseAcceptance") ?? false;
            project.Tags       = tags == null ? new string[] { } : tags.ValueAsArray <string>();
            project.IsLoadable = rawProject.GetValue <bool?>("loadable") ?? true;

            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = rawProject.GetValue <bool>("embedInteropTypes");

            // Project files
            project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath, diagnostics);

            var languageInfo = rawProject["language"] as JObject;

            if (languageInfo != null)
            {
                var languageName                 = languageInfo.GetValue <string>("name") ?? "C#";
                var languageServicesAssembly     = languageInfo.GetValue <string>("assembly");
                var projectReferenceProviderType = languageInfo.GetValue <string>("projectReferenceProviderType");

                var libraryExporter = new TypeInformation(languageServicesAssembly, projectReferenceProviderType);
                project.LanguageServices = new LanguageServices(languageName, libraryExporter);
            }

            var commands = rawProject["commands"] as JObject;

            if (commands != null)
            {
                foreach (var command in commands)
                {
                    project.Commands[command.Key] = command.Value.Value <string>();
                }
            }

            var scripts = rawProject["scripts"] as JObject;

            if (scripts != null)
            {
                foreach (var script in scripts)
                {
                    var value = script.Value;
                    if (value.Type == JTokenType.String)
                    {
                        project.Scripts[script.Key] = new string[] { value.Value <string>() };
                    }
                    else if (value.Type == JTokenType.Array)
                    {
                        project.Scripts[script.Key] = script.Value.ValueAsArray <string>();
                    }
                    else
                    {
                        throw FileFormatException.Create(
                                  string.Format("The value of a script in {0} can only be a string or an array of strings", ProjectFileName),
                                  value,
                                  project.ProjectFilePath);
                    }
                }
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject);

            PopulateDependencies(
                project.ProjectFilePath,
                project.Dependencies,
                rawProject,
                "dependencies",
                isGacOrFrameworkReference: false);

            return(project);
        }
Пример #3
0
        public static Project GetProject(Stream stream, string projectName, string projectPath)
        {
            var project = new Project();

            var reader     = new JsonTextReader(new StreamReader(stream));
            var rawProject = JObject.Load(reader);

            // Metadata properties
            var version      = rawProject["version"];
            var authors      = rawProject["authors"];
            var tags         = rawProject["tags"];
            var buildVersion = Environment.GetEnvironmentVariable("K_BUILD_VERSION");

            project.Name            = projectName;
            project.ProjectFilePath = Path.GetFullPath(projectPath);

            if (version == null)
            {
                project.Version = new SemanticVersion("1.0.0");
            }
            else
            {
                try
                {
                    project.Version = SpecifySnapshot(version.Value <string>(), buildVersion);
                }
                catch (Exception ex)
                {
                    var lineInfo = (IJsonLineInfo)version;

                    throw FileFormatException.Create(ex, version, project.ProjectFilePath);
                }
            }

            project.Description              = GetValue <string>(rawProject, "description");
            project.Authors                  = authors == null ? new string[] { } : authors.ToObject <string[]>();
            project.Dependencies             = new List <LibraryDependency>();
            project.WebRoot                  = GetValue <string>(rawProject, "webroot");
            project.EntryPoint               = GetValue <string>(rawProject, "entryPoint");
            project.ProjectUrl               = GetValue <string>(rawProject, "projectUrl");
            project.RequireLicenseAcceptance = GetValue <bool?>(rawProject, "requireLicenseAcceptance") ?? false;
            project.Tags       = tags == null ? new string[] { } : tags.ToObject <string[]>();
            project.IsLoadable = GetValue <bool?>(rawProject, "loadable") ?? true;

            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = GetValue <bool>(rawProject, "embedInteropTypes");

            // Source file patterns
            project.SourcePatterns        = GetSourcePattern(project, rawProject, "code", _defaultSourcePatterns);
            project.ExcludePatterns       = GetSourcePattern(project, rawProject, "exclude", _defaultExcludePatterns);
            project.BundleExcludePatterns = GetSourcePattern(project, rawProject, "bundleExclude", _defaultBundleExcludePatterns);
            project.PreprocessPatterns    = GetSourcePattern(project, rawProject, "preprocess", _defaultPreprocessPatterns);
            project.SharedPatterns        = GetSourcePattern(project, rawProject, "shared", _defaultSharedPatterns);
            project.ResourcesPatterns     = GetSourcePattern(project, rawProject, "resources", _defaultResourcesPatterns);
            project.ContentsPatterns      = GetSourcePattern(project, rawProject, "files", _defaultContentsPatterns);

            // Set the default loader information for projects
            var languageServicesAssembly     = DefaultLanguageServicesAssembly;
            var projectReferenceProviderType = DefaultProjectReferenceProviderType;
            var languageName = "C#";

            var languageInfo = rawProject["language"] as JObject;

            if (languageInfo != null)
            {
                languageName                 = GetValue <string>(languageInfo, "name");
                languageServicesAssembly     = GetValue <string>(languageInfo, "assembly");
                projectReferenceProviderType = GetValue <string>(languageInfo, "projectReferenceProviderType");
            }

            var libraryExporter = new TypeInformation(languageServicesAssembly, projectReferenceProviderType);

            project.LanguageServices = new LanguageServices(languageName, libraryExporter);

            var commands = rawProject["commands"] as JObject;

            if (commands != null)
            {
                foreach (var command in commands)
                {
                    project.Commands[command.Key] = command.Value.ToObject <string>();
                }
            }

            var scripts = rawProject["scripts"] as JObject;

            if (scripts != null)
            {
                foreach (var script in scripts)
                {
                    var value = script.Value;
                    if (value.Type == JTokenType.String)
                    {
                        project.Scripts[script.Key] = new string[] { value.ToObject <string>() };
                    }
                    else if (value.Type == JTokenType.Array)
                    {
                        project.Scripts[script.Key] = script.Value.ToObject <string[]>();
                    }
                    else
                    {
                        throw FileFormatException.Create(
                                  string.Format("The value of a script in {0} can only be a string or an array of strings", ProjectFileName),
                                  value,
                                  project.ProjectFilePath);
                    }
                }
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject);

            PopulateDependencies(
                project.ProjectFilePath,
                project.Dependencies,
                rawProject,
                "dependencies",
                isGacOrFrameworkReference: false);

            return(project);
        }
Пример #4
0
        internal static Project GetProjectFromStream(Stream stream, string projectName, string projectPath, ICollection<ICompilationMessage> diagnostics = null)
        {
            var project = new Project();

            var reader = new StreamReader(stream);
            var rawProject = JsonDeserializer.Deserialize(reader) as JsonObject;
            if (rawProject == null)
            {
                throw FileFormatException.Create(
                    "The JSON file can't be deserialized to a JSON object.",
                    projectPath);
            }

            // Meta-data properties
            project.Name = projectName;
            project.ProjectFilePath = Path.GetFullPath(projectPath);

            var version = rawProject.Value("version") as JsonString;
            if (version == null)
            {
                project.Version = new SemanticVersion("1.0.0");
            }
            else
            {
                try
                {
                    var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION");
                    project.Version = SpecifySnapshot(version, buildVersion);
                }
                catch (Exception ex)
                {
                    throw FileFormatException.Create(ex, version, project.ProjectFilePath);
                }
            }

            var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION");
            if (string.IsNullOrWhiteSpace(fileVersion))
            {
                project.AssemblyFileVersion = project.Version.Version;
            }
            else
            {
                try
                {
                    var simpleVersion = project.Version.Version;
                    project.AssemblyFileVersion = new Version(simpleVersion.Major,
                        simpleVersion.Minor,
                        simpleVersion.Build,
                        int.Parse(fileVersion));
                }
                catch (FormatException ex)
                {
                    throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
                }
            }

            project.Description = rawProject.ValueAsString("description");
            project.Summary = rawProject.ValueAsString("summary");
            project.Copyright = rawProject.ValueAsString("copyright");
            project.Title = rawProject.ValueAsString("title");
            project.WebRoot = rawProject.ValueAsString("webroot");
            project.EntryPoint = rawProject.ValueAsString("entryPoint");
            project.ProjectUrl = rawProject.ValueAsString("projectUrl");
            project.LicenseUrl = rawProject.ValueAsString("licenseUrl");
            project.IconUrl = rawProject.ValueAsString("iconUrl");

            project.Authors = rawProject.ValueAsStringArray("authors") ?? new string[] { };
            project.Owners = rawProject.ValueAsStringArray("owners") ?? new string[] { };
            project.Tags = rawProject.ValueAsStringArray("tags") ?? new string[] { };

            project.Language = rawProject.ValueAsString("language");
            project.ReleaseNotes = rawProject.ValueAsString("releaseNotes");

            project.RequireLicenseAcceptance = rawProject.ValueAsBoolean("requireLicenseAcceptance", defaultValue: false);
            project.IsLoadable = rawProject.ValueAsBoolean("loadable", defaultValue: true);
            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = rawProject.ValueAsBoolean("embedInteropTypes", defaultValue: false);

            project.Dependencies = new List<LibraryDependency>();

            // Project files
            project.Files = new ProjectFilesCollection(rawProject,
                                                       project.ProjectDirectory,
                                                       project.ProjectFilePath,
                                                       diagnostics);

            var compilerInfo = rawProject.ValueAsJsonObject("compiler");
            if (compilerInfo != null)
            {
                var languageName = compilerInfo.ValueAsString("name") ?? "C#";
                var compilerAssembly = compilerInfo.ValueAsString("compilerAssembly");
                var compilerType = compilerInfo.ValueAsString("compilerType");

                var compiler = new TypeInformation(compilerAssembly, compilerType);
                project.CompilerServices = new CompilerServices(languageName, compiler);
            }

            var commands = rawProject.Value("commands") as JsonObject;
            if (commands != null)
            {
                foreach (var key in commands.Keys)
                {
                    var value = commands.ValueAsString(key);
                    if (value != null)
                    {
                        project.Commands[key] = value;
                    }
                }
            }

            var scripts = rawProject.Value("scripts") as JsonObject;
            if (scripts != null)
            {
                foreach (var key in scripts.Keys)
                {
                    var stringValue = scripts.ValueAsString(key);
                    if (stringValue != null)
                    {
                        project.Scripts[key] = new string[] { stringValue };
                        continue;
                    }

                    var arrayValue = scripts.ValueAsStringArray(key);
                    if (arrayValue != null)
                    {
                        project.Scripts[key] = arrayValue;
                        continue;
                    }

                    throw FileFormatException.Create(
                        string.Format("The value of a script in {0} can only be a string or an array of strings", ProjectFileName),
                        scripts.Value(key),
                        project.ProjectFilePath);
                }
            }

            var repository = rawProject.Value("repository") as JsonObject;
            if (repository != null)
            {
                project.Repository = repository
                    .Keys
                    .ToDictionary(
                        key => key,
                        key => repository.ValueAsString(key).Value);
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject, diagnostics);

            PopulateDependencies(
                project.ProjectFilePath,
                project.Dependencies,
                rawProject,
                "dependencies",
                isGacOrFrameworkReference: false);

            return project;
        }
Пример #5
0
        public static Project GetProject(string json, string projectName, string projectPath)
        {
            var project = new Project();

            var rawProject = JObject.Parse(json);

            // Metadata properties
            var version = rawProject["version"];
            var authors = rawProject["authors"];

            project.Name            = projectName;
            project.Version         = version == null ? new SemanticVersion("1.0.0") : new SemanticVersion(version.Value <string>());
            project.Description     = GetValue <string>(rawProject, "description");
            project.Authors         = authors == null ? new string[] { } : authors.ToObject <string[]>();
            project.Dependencies    = new List <Library>();
            project.ProjectFilePath = projectPath;

            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = GetValue <bool>(rawProject, "embedInteropTypes");

            // Source file patterns
            project.SourcePatterns      = GetSourcePattern(rawProject, "code", _defaultSourcePatterns);
            project.ExcludePatterns     = GetSourcePattern(rawProject, "exclude", _defaultExcludePatterns);
            project.PackExcludePatterns = GetSourcePattern(rawProject, "pack-exclude", _defaultPackExcludePatterns);
            project.PreprocessPatterns  = GetSourcePattern(rawProject, "preprocess", _defaultPreprocessPatterns);
            project.SharedPatterns      = GetSourcePattern(rawProject, "shared", _defaultSharedPatterns);
            project.ResourcesPatterns   = GetSourcePattern(rawProject, "resources", _defaultResourcesPatterns);
            project.ContentsPatterns    = GetSourcePattern(rawProject, "files", _defaultContentsPatterns);

            // Set the default loader information for projects
            var languageServicesAssembly     = "Microsoft.Framework.Runtime.Roslyn";
            var projectReferenceProviderType = "Microsoft.Framework.Runtime.Roslyn.RoslynProjectReferenceProvider";
            var languageName = "C#";

            var languageInfo = rawProject["language"] as JObject;

            if (languageInfo != null)
            {
                languageName                 = GetValue <string>(languageInfo, "name");
                languageServicesAssembly     = GetValue <string>(languageInfo, "assembly");
                projectReferenceProviderType = GetValue <string>(languageInfo, "projectReferenceProviderType");
            }

            var libraryExporter = new TypeInformation(languageServicesAssembly, projectReferenceProviderType);

            project.LanguageServices = new LanguageServices(languageName, libraryExporter);

            var commands = rawProject["commands"] as JObject;

            if (commands != null)
            {
                foreach (var command in commands)
                {
                    project.Commands[command.Key] = command.Value.ToObject <string>();
                }
            }

            var scripts = rawProject["scripts"] as JObject;

            if (scripts != null)
            {
                foreach (var script in scripts)
                {
                    project.Scripts[script.Key] = script.Value.ToObject <string>();
                }
            }

            if (project.Version.IsSnapshot)
            {
                var buildVersion = Environment.GetEnvironmentVariable("K_BUILD_VERSION") ?? "SNAPSHOT";
                project.Version = project.Version.SpecifySnapshot(buildVersion);
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject);

            PopulateDependencies(project.Dependencies, rawProject);

            return(project);
        }
Пример #6
0
        internal static Project GetProjectFromStream(Stream stream, string projectName, string projectPath, ICollection<ICompilationMessage> diagnostics = null)
        {
            var project = new Project();

            var reader = new JsonTextReader(new StreamReader(stream));
            var rawProject = JObject.Load(reader);

            // Meta-data properties
            var version = rawProject["version"];
            var authors = rawProject["authors"];
            var owners = rawProject["owners"];
            var tags = rawProject["tags"];
            var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION");

            project.Name = projectName;
            project.ProjectFilePath = Path.GetFullPath(projectPath);

            if (version == null)
            {
                project.Version = new SemanticVersion("1.0.0");
            }
            else
            {
                try
                {
                    project.Version = SpecifySnapshot(version.Value<string>(), buildVersion);
                }
                catch (Exception ex)
                {
                    var lineInfo = (IJsonLineInfo)version;

                    throw FileFormatException.Create(ex, version, project.ProjectFilePath);
                }
            }

            var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION");
            if (string.IsNullOrWhiteSpace(fileVersion))
            {
                project.AssemblyFileVersion = project.Version.Version;
            }
            else
            {
                try
                {
                    var simpleVersion = project.Version.Version;
                    project.AssemblyFileVersion = new Version(simpleVersion.Major,
                        simpleVersion.Minor,
                        simpleVersion.Build,
                        int.Parse(fileVersion));
                }
                catch (FormatException ex)
                {
                    throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
                }
            }

            project.Description = rawProject.GetValue<string>("description");
            project.Summary = rawProject.GetValue<string>("summary");
            project.Copyright = rawProject.GetValue<string>("copyright");
            project.Title = rawProject.GetValue<string>("title");
            project.Authors = authors == null ? new string[] { } : authors.ValueAsArray<string>();
            project.Owners = owners == null ? new string[] { } : owners.ValueAsArray<string>();
            project.Dependencies = new List<LibraryDependency>();
            project.WebRoot = rawProject.GetValue<string>("webroot");
            project.EntryPoint = rawProject.GetValue<string>("entryPoint");
            project.ProjectUrl = rawProject.GetValue<string>("projectUrl");
            project.LicenseUrl = rawProject.GetValue<string>("licenseUrl");
            project.IconUrl = rawProject.GetValue<string>("iconUrl");
            project.RequireLicenseAcceptance = rawProject.GetValue<bool?>("requireLicenseAcceptance") ?? false;
            project.Tags = tags == null ? new string[] { } : tags.ValueAsArray<string>();
            project.IsLoadable = rawProject.GetValue<bool?>("loadable") ?? true;

            // TODO: Move this to the dependencies node
            project.EmbedInteropTypes = rawProject.GetValue<bool>("embedInteropTypes");

            // Project files
            project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath, diagnostics);

            var languageInfo = rawProject["language"] as JObject;

            if (languageInfo != null)
            {
                var languageName = languageInfo.GetValue<string>("name") ?? "C#";
                var languageServicesAssembly = languageInfo.GetValue<string>("assembly");
                var projectReferenceProviderType = languageInfo.GetValue<string>("projectReferenceProviderType");

                var libraryExporter = new TypeInformation(languageServicesAssembly, projectReferenceProviderType);
                project.LanguageServices = new LanguageServices(languageName, libraryExporter);
            }

            var commands = rawProject["commands"] as JObject;
            if (commands != null)
            {
                foreach (var command in commands)
                {
                    project.Commands[command.Key] = command.Value.Value<string>();
                }
            }

            var scripts = rawProject["scripts"] as JObject;
            if (scripts != null)
            {
                foreach (var script in scripts)
                {
                    var value = script.Value;
                    if (value.Type == JTokenType.String)
                    {
                        project.Scripts[script.Key] = new string[] { value.Value<string>() };
                    }
                    else if (value.Type == JTokenType.Array)
                    {
                        project.Scripts[script.Key] = script.Value.ValueAsArray<string>();
                    }
                    else
                    {
                        throw FileFormatException.Create(
                            string.Format("The value of a script in {0} can only be a string or an array of strings", ProjectFileName),
                            value,
                            project.ProjectFilePath);
                    }
                }
            }

            project.BuildTargetFrameworksAndConfigurations(rawProject);

            PopulateDependencies(
                project.ProjectFilePath,
                project.Dependencies,
                rawProject,
                "dependencies",
                isGacOrFrameworkReference: false);

            return project;
        }