本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}