当前位置: 首页>>代码示例>>C#>>正文


C# ProjectContext.ProjectName方法代码示例

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


在下文中一共展示了ProjectContext.ProjectName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: CollectCheckPathProbingPreconditions

        private void CollectCheckPathProbingPreconditions(ProjectContext project, IncrementalPreconditions preconditions)
        {
            var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project)
                .Select(commandName => Command.CreateDotNet(commandName, Enumerable.Empty<string>(), project.TargetFramework))
                .Where(c => c.ResolutionStrategy.Equals(CommandResolutionStrategy.Path));

            foreach (var pathCommand in pathCommands)
            {
                preconditions.AddPathProbingPrecondition(project.ProjectName(), pathCommand.CommandName);
            }
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:11,代码来源:IncrementalPreconditionManager.cs

示例3: CollectCompilerNamePreconditions

        private void CollectCompilerNamePreconditions(ProjectContext project, IncrementalPreconditions preconditions)
        {
            if (project.ProjectFile != null)
            {
                var compilerOptions = project.ProjectFile.GetCompilerOptions(project.TargetFramework, null);
                var projectCompiler = compilerOptions.CompilerName;

                if (!KnownCompilers.Any(knownCompiler => knownCompiler.Equals(projectCompiler, StringComparison.Ordinal)))
                {
                    preconditions.AddUnknownCompilerPrecondition(project.ProjectName(), projectCompiler);
                }
            }
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:13,代码来源:IncrementalPreconditionManager.cs

示例4: CollectScriptPreconditions

        private void CollectScriptPreconditions(ProjectContext project, IncrementalPreconditions preconditions)
        {
            var preCompileScripts = project.ProjectFile.Scripts.GetOrEmpty(ScriptNames.PreCompile);
            var postCompileScripts = project.ProjectFile.Scripts.GetOrEmpty(ScriptNames.PostCompile);

            if (preCompileScripts.Any())
            {
                preconditions.AddPrePostScriptPrecondition(project.ProjectName(), ScriptNames.PreCompile);
            }

            if (postCompileScripts.Any())
            {
                preconditions.AddPrePostScriptPrecondition(project.ProjectName(), ScriptNames.PostCompile);
            }
        }
开发者ID:piotrpMSFT,项目名称:cli,代码行数:15,代码来源:CompileContext.cs

示例5: CollectCompilerNamePreconditions

        private void CollectCompilerNamePreconditions(ProjectContext project, IncrementalPreconditions preconditions)
        {
            var projectCompiler = CompilerUtil.ResolveCompilerName(project);

            if (!KnownCompilers.Any(knownCompiler => knownCompiler.Equals(projectCompiler, StringComparison.Ordinal)))
            {
                preconditions.AddUnknownCompilerPrecondition(project.ProjectName(), projectCompiler);
            }
        }
开发者ID:piotrpMSFT,项目名称:cli,代码行数:9,代码来源:CompileContext.cs

示例6: AddLockFile

        private static void AddLockFile(ProjectContext project, CompilerIO compilerIO)
        {
            if (project.LockFile == null)
            {
                var errorMessage = $"Project {project.ProjectName()} does not have a lock file.";
                Reporter.Error.WriteLine(errorMessage);
                throw new InvalidOperationException(errorMessage);
            }

            compilerIO.Inputs.Add(project.LockFile.LockFilePath);
        }
开发者ID:piotrpMSFT,项目名称:cli,代码行数:11,代码来源:CompileContext.cs

示例7: CompileProject

        internal void CompileProject(ProjectContext context)
        {
            var compiler = new CSharpExtensionCompiler();
            var success = compiler.Compile(context, Configuration, _probingFolderPath);
            var diagnostics = compiler.Diagnostics;

            if (success)
            {
                if (_logger.IsEnabled(LogLevel.Information) && !diagnostics.Any())
                {
                     _logger.LogInformation($"{0} was successfully compiled", context.ProjectName());
                }
                else if (_logger.IsEnabled(LogLevel.Warning))
                {
                     _logger.LogWarning($"{0} was compiled but has warnings", context.ProjectName());

                     foreach (var diagnostic in diagnostics)
                     {
                         _logger.LogWarning(diagnostic);
                     }
                }
            }
            else
            {
                if (_logger.IsEnabled(LogLevel.Error))
                {
                     _logger.LogError($"{0} compilation failed", context.ProjectName());

                     foreach (var diagnostic in diagnostics)
                     {
                         _logger.LogError(diagnostic);
                     }
                }
            }
        }
开发者ID:yanghl22,项目名称:Orchard2,代码行数:35,代码来源:ExtensionLibraryService.cs

示例8: CompileInternal

        internal bool CompileInternal(ProjectContext context, string config, string probingFolderPath)
        {
            // Check if ambient library
            if (AmbientLibraries.Contains(context.ProjectName()))
            {
                return true;
            }

            bool compilationResult;

            // Check if already compiled
            if (_compiledLibraries.TryGetValue(context.ProjectName(), out compilationResult))
            {
                return compilationResult;
            }

            // Get compilation options and source files
            var compilationOptions = context.ResolveCompilationOptions(config);
            var projectSourceFiles = CompilerUtility.GetCompilationSources(context, compilationOptions);

            // Check if precompiled
            if (!projectSourceFiles.Any())
            {
                return _compiledLibraries[context.ProjectName()] = true;
            }

           // Set up Output Paths
            var outputPaths = context.GetOutputPaths(config);
            var outputPath = outputPaths.CompilationOutputPath;
            var intermediateOutputPath = outputPaths.IntermediateOutputDirectoryPath;

            Directory.CreateDirectory(outputPath);
            Directory.CreateDirectory(intermediateOutputPath);

            // Create the library exporter
            var exporter = context.CreateExporter(config);

            // Gather exports for the project
            var dependencies = exporter.GetDependencies().ToList();

            // Get compilation options
            var outputName = outputPaths.CompilationFiles.Assembly;

            // Set default platform if it isn't already set and we're on desktop
            if (compilationOptions.EmitEntryPoint == true && String.IsNullOrEmpty(compilationOptions.Platform) && context.TargetFramework.IsDesktop())
            {
                // See https://github.com/dotnet/cli/issues/2428 for more details.
                compilationOptions.Platform = RuntimeInformation.ProcessArchitecture == Architecture.X64 ?
                    "x64" : "anycpu32bitpreferred";
            }

            var references = new List<string>();
            var sourceFiles = new List<string>();
            var resources = new List<string>();

            // Get the runtime directory
            var runtimeDirectory = Path.GetDirectoryName(EntryAssembly.Location);

            foreach (var dependency in dependencies)
            {
                sourceFiles.AddRange(dependency.SourceReferences.Select(s => s.GetTransformedFile(intermediateOutputPath)));

                foreach (var resourceFile in dependency.EmbeddedResources)
                {
                    var transformedResource = resourceFile.GetTransformedFile(intermediateOutputPath);
                    var resourceName = ResourceManifestName.CreateManifestName(
                        Path.GetFileName(resourceFile.ResolvedPath), compilationOptions.OutputName);
                    resources.Add($"\"{transformedResource}\",{resourceName}");
                }

                var library = dependency.Library as ProjectDescription;
                var package = dependency.Library as PackageDescription;

                // Compile other referenced libraries
                if (library != null && !AmbientLibraries.Contains(library.Identity.Name) && dependency.CompilationAssemblies.Any())
                {
                    if (!_compiledLibraries.ContainsKey(library.Identity.Name))
                    {
                        var projectContext = GetProjectContextFromPath(library.Project.ProjectDirectory);

                        if (projectContext != null)
                        {
                           // Right now, if !success we try to use the last build
                           var success = Compile(projectContext, config, probingFolderPath);
                        }
                    }
                }

                // Check for an unresolved library
                if (library != null && !library.Resolved)
                {
                    var fileName = GetAssemblyFileName(library.Identity.Name);

                    // Search in the runtime directory
                    var path = Path.Combine(runtimeDirectory, fileName);

                    if (!File.Exists(path))
                    {
                        // Fallback to the project output path or probing folder
                        path = ResolveAssetPath(outputPath, probingFolderPath, fileName);
//.........这里部分代码省略.........
开发者ID:jchenga,项目名称:Orchard2,代码行数:101,代码来源:CSharpExtensionCompiler.cs

示例9: AddLockFile

        private static void AddLockFile(ProjectContext project, List<string> inputs)
        {
            if (project.LockFile == null)
            {
                var errorMessage = $"Project {project.ProjectName()} does not have a lock file. Please run \"dotnet restore\" to generate a new lock file.";
                Reporter.Error.WriteLine(errorMessage);
                throw new InvalidOperationException(errorMessage);
            }

            inputs.Add(project.LockFile.LockFilePath);

            if (project.LockFile.ExportFile != null)
            {
                inputs.Add(project.LockFile.ExportFile.ExportFilePath);
            }
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:16,代码来源:CompilerIOManager.cs

示例10: NeedsRebuilding

        private bool NeedsRebuilding(ProjectContext project, ProjectDependenciesFacade dependencies)
        {
            var compilerIO = GetCompileIO(project, _args.ConfigValue, _args.OutputValue, _args.IntermediateValue, dependencies);

            // rebuild if empty inputs / outputs
            if (!(compilerIO.Outputs.Any() && compilerIO.Inputs.Any()))
            {
                Reporter.Output.WriteLine($"\nProject {project.ProjectName()} will be compiled because it either has empty inputs or outputs");
                return true;
            }

            //rebuild if missing inputs / outputs
            if (AnyMissingIO(project, compilerIO.Outputs, "outputs") || AnyMissingIO(project, compilerIO.Inputs, "inputs"))
            {
                return true;
            }

            // find the output with the earliest write time
            var minOutputPath = compilerIO.Outputs.First();
            var minDate = File.GetLastWriteTime(minOutputPath);

            foreach (var outputPath in compilerIO.Outputs)
            {
                if (File.GetLastWriteTime(outputPath) >= minDate)
                {
                    continue;
                }

                minDate = File.GetLastWriteTime(outputPath);
                minOutputPath = outputPath;
            }

            // find inputs that are older than the earliest output
            var newInputs = compilerIO.Inputs.FindAll(p => File.GetLastWriteTime(p) > minDate);

            if (!newInputs.Any())
            {
                Reporter.Output.WriteLine($"\nProject {project.ProjectName()} was previoulsy compiled. Skipping compilation.");
                return false;
            }

            Reporter.Output.WriteLine($"\nProject {project.ProjectName()} will be compiled because some of its inputs were newer than its oldest output.");
            Reporter.Verbose.WriteLine($"Oldest output item was written at {minDate} : {minOutputPath}");
            Reporter.Verbose.WriteLine($"Inputs newer than the oldest output item:");

            foreach (var newInput in newInputs)
            {
                Reporter.Verbose.WriteLine($"\t{File.GetLastWriteTime(newInput)}\t:\t{newInput}");
            }

            return true;
        }
开发者ID:xier2012,项目名称:cli,代码行数:52,代码来源:CompileContext.cs

示例11: AnyMissingIO

        private static bool AnyMissingIO(ProjectContext project, IEnumerable<string> items, string itemsType)
        {
            var missingItems = items.Where(i => !File.Exists(i)).ToList();

            if (!missingItems.Any())
            {
                return false;
            }

            Reporter.Output.WriteLine($"\nProject {project.ProjectName()} will be compiled because expected {itemsType} are missing. ");

            foreach (var missing in missingItems)
            {
                Reporter.Verbose.WriteLine($"\t {missing}");
            }

            Reporter.Output.WriteLine();

            return true;
        }
开发者ID:xier2012,项目名称:cli,代码行数:20,代码来源:CompileContext.cs

示例12: CheckPathProbing

        private void CheckPathProbing(ProjectContext project, IncrementalPreconditions preconditions)
        {
            var pathCommands = CompilerUtil.GetCommandsInvokedByCompile(project)
                .Select(commandName => Command.Create(commandName, "", project.TargetFramework))
                .Where(c => Command.CommandResolutionStrategy.Path.Equals(c.ResolutionStrategy));

            foreach (var pathCommand in pathCommands)
            {
                preconditions.AddPathProbingPrecondition(project.ProjectName(), pathCommand.CommandName);
            }
        }
开发者ID:yonglehou,项目名称:cli-1,代码行数:11,代码来源:CompileContext.cs


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