コード例 #1
0
ファイル: ProjectDescription.cs プロジェクト: leloulight/dnx
 public ProjectDescription(
     LibraryRange libraryRange,
     Project project,
     IEnumerable<LibraryDependency> dependencies,
     IEnumerable<string> assemblies,
     TargetFrameworkInformation targetFrameworkInfo,
     bool resolved) :
         base(
             libraryRange,
             new LibraryIdentity(project.Name, project.Version, isGacOrFrameworkReference: false),
             project.ProjectFilePath,
             LibraryTypes.Project,
             dependencies,
             assemblies,
             targetFrameworkInfo.FrameworkName)
 {
     Project = project;
     Resolved = resolved;
     Compatible = resolved;
     TargetFrameworkInfo = targetFrameworkInfo;
 }
コード例 #2
0
ファイル: ProjectReader.cs プロジェクト: adwardliu/dnx
        /// <summary>
        /// Parse a Json object which represents project configuration for a specified framework
        /// </summary>
        /// <param name="frameworkKey">The name of the framework</param>
        /// <param name="frameworkValue">The Json object represent the settings</param>
        /// <returns>Returns true if it successes.</returns>
        private bool BuildTargetFrameworkNode(Project project, string frameworkKey, JsonObject frameworkValue)
        {
            // If no compilation options are provided then figure them out from the node
            var compilerOptions = GetCompilationOptions(frameworkValue) ??
                                  new CompilerOptions();

            var frameworkName = FrameworkNameHelper.ParseFrameworkName(frameworkKey);

            // If it's not unsupported then keep it
            if (frameworkName == VersionUtility.UnsupportedFrameworkName)
            {
                // REVIEW: Should we skip unsupported target frameworks
                return false;
            }

            // Add the target framework specific define
            var defines = new HashSet<string>(compilerOptions.Defines ?? Enumerable.Empty<string>());
            var frameworkDefinition = Tuple.Create(frameworkKey, frameworkName);
            var frameworkDefine = FrameworkNameHelper.MakeDefaultTargetFrameworkDefine(frameworkDefinition);

            if (!string.IsNullOrEmpty(frameworkDefine))
            {
                defines.Add(frameworkDefine);
            }

            compilerOptions.Defines = defines;

            var targetFrameworkInformation = new TargetFrameworkInformation
            {
                FrameworkName = frameworkName,
                Dependencies = new List<LibraryDependency>()
            };

            var frameworkDependencies = new List<LibraryDependency>();

            PopulateDependencies(
                project.ProjectFilePath,
                frameworkDependencies,
                frameworkValue,
                "dependencies",
                isGacOrFrameworkReference: false);

            var frameworkAssemblies = new List<LibraryDependency>();
            PopulateDependencies(
                project.ProjectFilePath,
                frameworkAssemblies,
                frameworkValue,
                "frameworkAssemblies",
                isGacOrFrameworkReference: true);

            frameworkDependencies.AddRange(frameworkAssemblies);
            targetFrameworkInformation.Dependencies = frameworkDependencies;

            targetFrameworkInformation.WrappedProject = frameworkValue.ValueAsString("wrappedProject");

            var binNode = frameworkValue.ValueAsJsonObject("bin");
            if (binNode != null)
            {
                targetFrameworkInformation.AssemblyPath = binNode.ValueAsString("assembly");
                targetFrameworkInformation.PdbPath = binNode.ValueAsString("pdb");
            }

            project._compilerOptionsByFramework[frameworkName] = compilerOptions;
            project._targetFrameworks[frameworkName] = targetFrameworkInformation;

            return true;
        }
コード例 #3
0
ファイル: ProjectReader.cs プロジェクト: leloulight/dnx
        /// <summary>
        /// Parse a Json object which represents project configuration for a specified framework
        /// </summary>
        /// <param name="frameworkKey">The name of the framework</param>
        /// <param name="frameworkValue">The Json object represent the settings</param>
        /// <returns>Returns true if it successes.</returns>
        private bool BuildTargetFrameworkNode(Project project, string frameworkKey, JsonObject frameworkValue)
        {
            // If no compilation options are provided then figure them out from the node
            var compilerOptions = GetCompilationOptions(frameworkValue) ??
                                  new CompilerOptions();

            var frameworkName = FrameworkNameHelper.ParseFrameworkName(frameworkKey);

            // If it's not unsupported then keep it
            if (frameworkName == VersionUtility.UnsupportedFrameworkName)
            {
                // REVIEW: Should we skip unsupported target frameworks
                return(false);
            }

            // Add the target framework specific define
            var defines             = new HashSet <string>(compilerOptions.Defines ?? Enumerable.Empty <string>());
            var frameworkDefinition = Tuple.Create(frameworkKey, frameworkName);
            var frameworkDefine     = FrameworkNameHelper.MakeDefaultTargetFrameworkDefine(frameworkDefinition);

            if (!string.IsNullOrEmpty(frameworkDefine))
            {
                defines.Add(frameworkDefine);
            }

            compilerOptions.Defines = defines;

            var targetFrameworkInformation = new TargetFrameworkInformation
            {
                FrameworkName = frameworkName,
                Dependencies  = new List <LibraryDependency>()
            };

            var frameworkDependencies = new List <LibraryDependency>();

            PopulateDependencies(
                project.ProjectFilePath,
                frameworkDependencies,
                frameworkValue,
                "dependencies",
                isGacOrFrameworkReference: false);

            var frameworkAssemblies = new List <LibraryDependency>();

            PopulateDependencies(
                project.ProjectFilePath,
                frameworkAssemblies,
                frameworkValue,
                "frameworkAssemblies",
                isGacOrFrameworkReference: true);

            frameworkDependencies.AddRange(frameworkAssemblies);
            targetFrameworkInformation.Dependencies = frameworkDependencies;

            targetFrameworkInformation.WrappedProject = frameworkValue.ValueAsString("wrappedProject");

            var binNode = frameworkValue.ValueAsJsonObject("bin");

            if (binNode != null)
            {
                targetFrameworkInformation.AssemblyPath = binNode.ValueAsString("assembly");
                targetFrameworkInformation.PdbPath      = binNode.ValueAsString("pdb");
            }

            project._compilerOptionsByFramework[frameworkName] = compilerOptions;
            project._targetFrameworks[frameworkName]           = targetFrameworkInformation;

            return(true);
        }
コード例 #4
0
        private void BuildTargetFrameworksAndConfigurations(JsonObject projectJsonObject,
                                                            ICollection <DiagnosticMessage> diagnostics)
        {
            // Get the shared compilationOptions
            _defaultCompilerOptions = GetCompilationOptions(projectJsonObject) ?? new CompilerOptions();

            _defaultTargetFrameworkConfiguration = new TargetFrameworkInformation
            {
                Dependencies = new List <LibraryDependency>()
            };

            // Add default configurations
            _configurations["Debug"] = new CompilerOptions
            {
                Defines  = new[] { "DEBUG", "TRACE" },
                Optimize = false
            };

            _configurations["Release"] = new CompilerOptions
            {
                Defines  = new[] { "RELEASE", "TRACE" },
                Optimize = true
            };

            // The configuration node has things like debug/release compiler settings

            /*
             *  {
             *      "configurations": {
             *          "Debug": {
             *          },
             *          "Release": {
             *          }
             *      }
             *  }
             */

            var configurations = projectJsonObject.ValueAsJsonObject("configurations");

            if (configurations != null)
            {
                foreach (var configKey in configurations.Keys)
                {
                    var compilerOptions = GetCompilationOptions(configurations.ValueAsJsonObject(configKey));

                    // Only use this as a configuration if it's not a target framework
                    _configurations[configKey] = compilerOptions;
                }
            }

            // The frameworks node is where target frameworks go

            /*
             *  {
             *      "frameworks": {
             *          "net45": {
             *          },
             *          "k10": {
             *          }
             *      }
             *  }
             */

            var frameworks = projectJsonObject.ValueAsJsonObject("frameworks");

            if (frameworks != null)
            {
                foreach (var frameworkKey in frameworks.Keys)
                {
                    try
                    {
                        var frameworkToken = frameworks.ValueAsJsonObject(frameworkKey);
                        var success        = BuildTargetFrameworkNode(frameworkKey, frameworkToken);
                        if (!success)
                        {
                            diagnostics?.Add(
                                new DiagnosticMessage(
                                    $"\"{frameworkKey}\" is an unsupported framework",
                                    ProjectFilePath,
                                    DiagnosticMessageSeverity.Error,
                                    frameworkToken.Line,
                                    frameworkToken.Column));
                        }
                    }
                    catch (Exception ex)
                    {
                        throw FileFormatException.Create(ex, frameworks.Value(frameworkKey), ProjectFilePath);
                    }
                }
            }
        }
コード例 #5
0
ファイル: Project.cs プロジェクト: cemoses/aspnet
        private void BuildTargetFrameworksAndConfigurations(JsonObject projectJsonObject,
            ICollection<DiagnosticMessage> diagnostics)
        {
            // Get the shared compilationOptions
            _defaultCompilerOptions = GetCompilationOptions(projectJsonObject) ?? new CompilerOptions();

            _defaultTargetFrameworkConfiguration = new TargetFrameworkInformation
            {
                Dependencies = new List<LibraryDependency>()
            };

            // Add default configurations
            _configurations["Debug"] = new CompilerOptions
            {
                Defines = new[] { "DEBUG", "TRACE" },
                Optimize = false
            };

            _configurations["Release"] = new CompilerOptions
            {
                Defines = new[] { "RELEASE", "TRACE" },
                Optimize = true
            };

            // The configuration node has things like debug/release compiler settings
            /*
                {
                    "configurations": {
                        "Debug": {
                        },
                        "Release": {
                        }
                    }
                }
            */

            var configurations = projectJsonObject.ValueAsJsonObject("configurations");
            if (configurations != null)
            {
                foreach (var configKey in configurations.Keys)
                {
                    var compilerOptions = GetCompilationOptions(configurations.ValueAsJsonObject(configKey));

                    // Only use this as a configuration if it's not a target framework
                    _configurations[configKey] = compilerOptions;
                }
            }

            // The frameworks node is where target frameworks go
            /*
                {
                    "frameworks": {
                        "net45": {
                        },
                        "k10": {
                        }
                    }
                }
            */

            var frameworks = projectJsonObject.ValueAsJsonObject("frameworks");
            if (frameworks != null)
            {
                foreach (var frameworkKey in frameworks.Keys)
                {
                    try
                    {
                        var frameworkToken = frameworks.ValueAsJsonObject(frameworkKey);
                        var success = BuildTargetFrameworkNode(frameworkKey, frameworkToken);
                        if (!success)
                        {
                            diagnostics?.Add(
                                new DiagnosticMessage(
                                    $"\"{frameworkKey}\" is an unsupported framework",
                                    ProjectFilePath,
                                    DiagnosticMessageSeverity.Error,
                                    frameworkToken.Line,
                                    frameworkToken.Column));
                        }
                    }
                    catch (Exception ex)
                    {
                        throw FileFormatException.Create(ex, frameworks.Value(frameworkKey), ProjectFilePath);
                    }
                }
            }
        }