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


C# Project.RemoveMetadataReference方法代码示例

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


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

示例1: RemoveNonExistingReferences

        private static Solution RemoveNonExistingReferences(Project project)
        {
            foreach (var metadataReference in project.MetadataReferences.ToArray())
            {
                if (!File.Exists(metadataReference.Display))
                {
                    Log.Message("Reference assembly doesn't exist on disk: " + metadataReference.Display);
                    project = project.RemoveMetadataReference(metadataReference);
                }
            }

            return project.Solution;
        }
开发者ID:akrisiun,项目名称:SourceBrowser,代码行数:13,代码来源:SolutionGenerator.cs

示例2: CompileProject

        /// <summary>
        /// Compiles the given P# project.
        /// </summary>
        /// <param name="project">Project</param>
        private static void CompileProject(Project project)
        {
            var runtimeDllPath = typeof(Dispatcher).Assembly.Location;
            var bugFindingRuntimeDllPath = typeof(BugFindingDispatcher).Assembly.Location;

            var runtimeDll = project.MetadataReferences.FirstOrDefault(val => val.Display.EndsWith(
                Path.DirectorySeparatorChar + "Microsoft.PSharp.Runtime.dll"));

            if (runtimeDll != null && (Configuration.RunStaticAnalysis ||
                Configuration.RunDynamicAnalysis))
            {
                project = project.RemoveMetadataReference(runtimeDll);
            }

            if ((Configuration.RunStaticAnalysis || Configuration.RunDynamicAnalysis) &&
                !project.MetadataReferences.Any(val => val.Display.EndsWith(
                Path.DirectorySeparatorChar + "Microsoft.PSharp.BugFindingRuntime.dll")))
            {
                project = project.AddMetadataReference(MetadataReference.CreateFromFile(
                    bugFindingRuntimeDllPath));
            }

            var compilation = project.GetCompilationAsync().Result;

            try
            {
                if (Configuration.RunDynamicAnalysis)
                {
                    var dll = CompilationEngine.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary,
                        project.OutputFilePath);

                    if (Configuration.ProjectName.Equals(project.Name))
                    {
                        Configuration.AssembliesToBeAnalyzed.Add(dll);
                    }
                }
                else if (Configuration.CompileForDistribution)
                {
                    CompilationEngine.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary,
                        project.OutputFilePath);
                }
                else
                {
                    CompilationEngine.ToFile(compilation, project.CompilationOptions.OutputKind,
                        project.OutputFilePath);
                }
            }
            catch (ApplicationException ex)
            {
                ErrorReporter.ReportAndExit(ex.Message);
            }
        }
开发者ID:jerickmsft,项目名称:PSharp,代码行数:56,代码来源:CompilationEngine.cs

示例3: CompileProject

        /// <summary>
        /// Compiles the given P# project.
        /// </summary>
        /// <param name="project">Project</param>
        private void CompileProject(Project project)
        {
            var runtimeDllPath = typeof(Dispatcher).Assembly.Location;
            var bugFindingRuntimeDllPath = typeof(BugFindingDispatcher).Assembly.Location;

            var runtimeDll = project.MetadataReferences.FirstOrDefault(val => val.Display.EndsWith(
                Path.DirectorySeparatorChar + "Microsoft.PSharp.Runtime.dll"));

            if (runtimeDll != null && this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing)
            {
                project = project.RemoveMetadataReference(runtimeDll);
            }

            if (this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing &&
                !project.MetadataReferences.Any(val => val.Display.EndsWith(
                Path.DirectorySeparatorChar + "Microsoft.PSharp.BugFindingRuntime.dll")))
            {
                project = project.AddMetadataReference(MetadataReference.CreateFromFile(
                    bugFindingRuntimeDllPath));
            }

            var compilation = project.GetCompilationAsync().Result;

            try
            {
                if (this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Testing ||
                    this.CompilationContext.ActiveCompilationTarget == CompilationTarget.Distribution)
                {
                    this.ToFile(compilation, OutputKind.DynamicallyLinkedLibrary,
                        project.OutputFilePath);
                }
                else
                {
                    this.ToFile(compilation, project.CompilationOptions.OutputKind,
                        project.OutputFilePath);
                }
            }
            catch (ApplicationException ex)
            {
                ErrorReporter.ReportAndExit(ex.Message);
            }
        }
开发者ID:ashwini-mnnit,项目名称:PSharp,代码行数:46,代码来源:CompilationEngine.cs


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