• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ProjectModel.ProjectContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.DotNet.ProjectModel.ProjectContext的典型用法代码示例。如果您正苦于以下问题:C# ProjectContext类的具体用法?C# ProjectContext怎么用?C# ProjectContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProjectContext类属于Microsoft.DotNet.ProjectModel命名空间,在下文中一共展示了ProjectContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProcessContext

        protected virtual void ProcessContext(ProjectContext context)
        {
            PopulateDependencies(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
            var outputName = GetProjectOutputName(context.TargetFramework);

            var resourceCultures = context.ProjectFile.Files.ResourceFiles
                    .Select(resourceFile => ResourceUtility.GetResourceCultureName(resourceFile.Key))
                    .Distinct();

            foreach (var culture in resourceCultures)
            {
                if (string.IsNullOrEmpty(culture))
                {
                    continue;
                }

                var resourceFilePath = Path.Combine(culture, $"{Project.Name}.resources.dll");
                TryAddOutputFile(context, inputFolder, resourceFilePath);
            }

            TryAddOutputFile(context, inputFolder, outputName);
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.xml");
        }
开发者ID:xier2012,项目名称:cli,代码行数:25,代码来源:PackageGenerator.cs


示例2: GetCompileIO

        // computes all the inputs and outputs that would be used in the compilation of a project
        // ensures that all paths are files
        // ensures no missing inputs
        public static CompilerIO GetCompileIO(ProjectContext project, string config, string outputPath, string intermediaryOutputPath, ProjectDependenciesFacade dependencies)
        {
            var compilerIO = new CompilerIO(new List<string>(), new List<string>());
            var compilationOutput = CompilerUtil.GetCompilationOutput(project.ProjectFile, project.TargetFramework, config, outputPath);

            // input: project.json
            compilerIO.Inputs.Add(project.ProjectFile.ProjectFilePath);

            // input: lock file; find when dependencies change
            AddLockFile(project, compilerIO);

            // input: source files
            compilerIO.Inputs.AddRange(CompilerUtil.GetCompilationSources(project));

            // todo: Factor out dependency resolution between Build and Compile. Ideally Build injects the dependencies into Compile
            // input: dependencies
            AddDependencies(dependencies, compilerIO);

            // output: compiler output
            compilerIO.Outputs.Add(compilationOutput);

            // input / output: compilation options files
            AddFilesFromCompilationOptions(project, config, compilationOutput, compilerIO);

            // input / output: resources without culture
            AddCultureResources(project, intermediaryOutputPath, compilerIO);

            // input / output: resources with culture
            AddNonCultureResources(project, outputPath, compilerIO);

            return compilerIO;
        }
开发者ID:jhendrixMSFT,项目名称:cli,代码行数:35,代码来源:CompileContext.cs


示例3: ResolveCompilerName

        public static string ResolveCompilerName(ProjectContext context)
        {
            var compilerName = context.ProjectFile.CompilerName;
            compilerName = compilerName ?? "csc";

            return compilerName;
        }
开发者ID:jinujoseph,项目名称:cli,代码行数:7,代码来源:CompilerUtil.cs


示例4: InputPathForContext

 public string InputPathForContext(ProjectContext context)
 {
     return Path.Combine(
         CompiledArtifactsPath,
         _configuration,
         context.TargetFramework.GetTwoDigitShortFolderName());
 }        
开发者ID:xier2012,项目名称:cli,代码行数:7,代码来源:ArtifactPathsCalculator.cs


示例5: CreateForProject

        public static AssemblyInfoOptions CreateForProject(ProjectContext context)
        {
            var project = context.ProjectFile;
            NuGetFramework targetFramework = null;
            // force .NETFramework instead of DNX
            if (context.TargetFramework.IsDesktop())
            {
                targetFramework = new NuGetFramework(FrameworkConstants.FrameworkIdentifiers.Net, context.TargetFramework.Version);
            }
            else
            {
                targetFramework = context.TargetFramework;
            }

            return new AssemblyInfoOptions()
            {
                AssemblyVersion = project.Version?.Version.ToString(),
                AssemblyFileVersion = project.AssemblyFileVersion.ToString(),
                InformationalVersion = project.Version.ToString(),
                Copyright = project.Copyright,
                Description = project.Description,
                Title = project.Title,
                NeutralLanguage = project.Language,
                TargetFramework = targetFramework.DotNetFrameworkName
            };
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:26,代码来源:AssemblyInfoOptions.cs


示例6: TraverseProject

        private ProjectGraphNode TraverseProject(ProjectDescription project, IDictionary<string, LibraryDescription> lookup, ProjectContext context = null)
        {
            var isRoot = context != null;
            var deps = new List<ProjectGraphNode>();
            if (isRoot || _collectDependencies)
            {
                foreach (var dependency in project.Dependencies)
                {
                    LibraryDescription libraryDescription;
                    if ((lookup.TryGetValue(dependency.Name, out libraryDescription)) && (!libraryDescription.Identity.Name.Equals(project.Identity.Name)))
                    {
                        if (libraryDescription.Resolved && libraryDescription.Identity.Type.Equals(LibraryType.Project))
                        {
                            deps.Add(TraverseProject((ProjectDescription)libraryDescription, lookup));
                        }
                        else
                        {
                            deps.AddRange(TraverseNonProject(libraryDescription, lookup));
                        }
                    }
                }
            }

            var task = context != null ? Task.FromResult(context) : Task.Run(() => _projectContextFactory(project.Path, project.Framework));
            return new ProjectGraphNode(task, deps, isRoot);
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:26,代码来源:ProjectGraphCollector.cs


示例7: CalculateDefaultsForNonAssigned

        private void CalculateDefaultsForNonAssigned()
        {
            if (string.IsNullOrWhiteSpace(Project))
            {
                Project = Directory.GetCurrentDirectory();
            }

            if (string.IsNullOrWhiteSpace(Configuration))
            {
                Configuration = Constants.DefaultConfiguration;
            }

            var contexts = ProjectContext.CreateContextForEachFramework(Project);
            if (Framework == null)
            {
                _context = contexts.First();
            }
            else
            {
                var fx = NuGetFramework.Parse(Framework);
                _context = contexts.FirstOrDefault(c => c.TargetFramework.Equals(fx));
            }

            if (Args == null)
            {
                _args = new List<string>();
            }
            else
            {
                _args = new List<string>(Args);
            }
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:32,代码来源:RunCommand.cs


示例8: ResolveLanguageId

 public static string ResolveLanguageId(ProjectContext context)
 {
     var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId;
     languageId = languageId ?? "cs";
     
     return languageId;
 }
开发者ID:Auxon,项目名称:cli,代码行数:7,代码来源:CompilerUtil.cs


示例9: GetRuntimeDependencies

        private static IEnumerable<string> GetRuntimeDependencies(ProjectContext projectContext, string buildConfiguration)
        {
            // We collect the full list of runtime dependencies here and pass them back so they can be
            // referenced by the REPL environment when seeding the context. It appears that we need to
            // explicitly list the dependencies as they may not exist in the output directory (as is the
            // for library projects) or they may not exist anywhere on the path (e.g. they may only exist
            // in the nuget package that was downloaded for the compilation) or they may be specific to a
            // specific target framework.

            var runtimeDependencies = new HashSet<string>();

            var projectExporter = projectContext.CreateExporter(buildConfiguration);
            var projectDependencies = projectExporter.GetDependencies();

            foreach (var projectDependency in projectDependencies)
            {
                var runtimeAssemblies = projectDependency.RuntimeAssemblies;

                foreach (var runtimeAssembly in runtimeAssemblies)
                {
                    var runtimeAssemblyPath = runtimeAssembly.ResolvedPath;
                    runtimeDependencies.Add(runtimeAssemblyPath);
                }
            }

            return runtimeDependencies;
        }
开发者ID:alexanderkyte,项目名称:cli,代码行数:27,代码来源:Program.cs


示例10: DoRunTests

        internal override int DoRunTests(ProjectContext projectContext, DotnetTestParams dotnetTestParams)
        {
            Console.WriteLine("Listening on port {0}", dotnetTestParams.Port.Value);

            HandleDesignTimeMessages(projectContext, dotnetTestParams);

            return 0;
        }
开发者ID:krytarowski,项目名称:cli,代码行数:8,代码来源:DesignTimeRunner.cs


示例11: ProcessContext

        protected override void ProcessContext(ProjectContext context)
        {
            base.ProcessContext(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.pdb");
            TryAddOutputFile(context, inputFolder, $"{Project.Name}.mdb");
        }
开发者ID:kyulee1,项目名称:cli,代码行数:8,代码来源:SymbolPackageGenerator.cs


示例12: Executable

 public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter)
 {
     _context = context;
     _outputPaths = outputPaths;
     _runtimeOutputPath = outputPaths.RuntimeOutputPath;
     _intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath;
     _exporter = exporter;
 }
开发者ID:cdmihai,项目名称:cli,代码行数:8,代码来源:Executable.cs


示例13: ProcessContext

        protected override void ProcessContext(ProjectContext context)
        {
            base.ProcessContext(context);

            var outputPath = GetOutputPath(context);
            TryAddOutputFile(context, outputPath, $"{Project.Name}.pdb");
            TryAddOutputFile(context, outputPath, $"{Project.Name}.mdb");
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:8,代码来源:SymbolPackageGenerator.cs


示例14: AddProject

        private ProjectId AddProject(ProjectContext project)
        {
            // Create the framework specific project and add it to the workspace
            var projectInfo = ProjectInfo.Create(
                                ProjectId.CreateNewId(),
                                VersionStamp.Create(),
                                project.ProjectFile.Name + "+" + project.TargetFramework,
                                project.ProjectFile.Name,
                                LanguageNames.CSharp,
                                project.ProjectFile.ProjectFilePath);

            OnProjectAdded(projectInfo);

            // TODO: ctor argument?
            var configuration = "Debug";

            var compilationOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, configuration);

            var compilationSettings = ToCompilationSettings(compilationOptions, project.TargetFramework, project.ProjectFile.ProjectDirectory);

            OnParseOptionsChanged(projectInfo.Id, new CSharpParseOptions(compilationSettings.LanguageVersion, preprocessorSymbols: compilationSettings.Defines));

            OnCompilationOptionsChanged(projectInfo.Id, compilationSettings.CompilationOptions);

            foreach (var file in project.ProjectFile.Files.SourceFiles)
            {
                AddSourceFile(projectInfo, file);
            }

            var exporter = project.CreateExporter(configuration);

            foreach (var dependency in exporter.GetDependencies())
            {
                var projectDependency = dependency.Library as ProjectDescription;
                if (projectDependency != null)
                {
                    var projectDependencyContext = ProjectContext.Create(projectDependency.Project.ProjectFilePath, projectDependency.Framework);

                    var id = AddProject(projectDependencyContext);

                    OnProjectReferenceAdded(projectInfo.Id, new ProjectReference(id));
                }
                else
                {
                    foreach (var asset in dependency.CompilationAssemblies)
                    {
                        OnMetadataReferenceAdded(projectInfo.Id, GetMetadataReference(asset.ResolvedPath));
                    }
                }

                foreach (var file in dependency.SourceReferences)
                {
                    AddSourceFile(projectInfo, file);
                }
            }

            return projectInfo.Id;
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:58,代码来源:ProjectJsonWorkspace.cs


示例15: Compile

        public bool Compile(ProjectContext context, string config, string probingFolderPath)
        {
            var compilationlock = _compilationlocks.GetOrAdd(context.ProjectName(), id => new object());

            lock (compilationlock)
            {
                return CompileInternal(context, config, probingFolderPath);
            }
        }
开发者ID:jchenga,项目名称:Orchard2,代码行数:9,代码来源:CSharpExtensionCompiler.cs


示例16: Create

 public static DependencyInfo Create(ProjectContext context, LibraryDescription library)
 {
     return new DependencyInfo
     {
         ProjectPath = context.ProjectFile.ProjectFilePath,
         Version = library.Identity.Version.ToString(),
         Name = library.Identity.Name
     };
 }
开发者ID:yonglehou,项目名称:cli-1,代码行数:9,代码来源:DependencyInfo.cs


示例17: BuildTestProject

        private int BuildTestProject(ProjectContext projectContext, DotnetTestParams dotnetTestParams, BuildWorkspace workspace)
        {
            if (dotnetTestParams.NoBuild)
            {
                return 0;
            }

            return DoBuildTestProject(projectContext, dotnetTestParams, workspace);
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:9,代码来源:BaseDotnetTestRunner.cs


示例18: Executable

 public Executable(ProjectContext context, OutputPaths outputPaths, LibraryExporter exporter, string configuration)
 {
     _context = context;
     _outputPaths = outputPaths;
     _runtimeOutputPath = outputPaths.RuntimeOutputPath;
     _intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath;
     _exporter = exporter;
     _compilerOptions = _context.ProjectFile.GetCompilerOptions(_context.TargetFramework, configuration);
 }
开发者ID:krytarowski,项目名称:cli,代码行数:9,代码来源:Executable.cs


示例19: ResolveLanguageId

        public static string ResolveLanguageId(ProjectContext context)
        {
            var languageId = context.ProjectFile.AnalyzerOptions?.LanguageId;
            if (languageId == null)
            {
                languageId = context.ProjectFile.GetSourceCodeLanguage();
            }

            return languageId;
        }
开发者ID:cdmihai,项目名称:cli,代码行数:10,代码来源:CompilerUtil.cs


示例20: ProcessContext

        protected override void ProcessContext(ProjectContext context)
        {
            base.ProcessContext(context);

            var inputFolder = ArtifactPathsCalculator.InputPathForContext(context);
            var ouptutName =  Project.GetCompilerOptions(context.TargetFramework, Configuration).OutputName;

            TryAddOutputFile(context, inputFolder, $"{ouptutName}.pdb");
            TryAddOutputFile(context, inputFolder, $"{ouptutName}.mdb");
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:10,代码来源:SymbolPackageGenerator.cs



注:本文中的Microsoft.DotNet.ProjectModel.ProjectContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Native.NativeCompileSettings类代码示例发布时间:2022-05-26
下一篇:
C# ProjectModel.Project类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap