本文整理汇总了C#中Microsoft.CodeAnalysis.Project.AddMetadataReference方法的典型用法代码示例。如果您正苦于以下问题:C# Project.AddMetadataReference方法的具体用法?C# Project.AddMetadataReference怎么用?C# Project.AddMetadataReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Project
的用法示例。
在下文中一共展示了Project.AddMetadataReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtendProject
protected override Project ExtendProject(Project project)
{
var newFileName = DefaultFilePathPrefix + project.Documents.Count() + "." + CSharpDefaultFileExt;
return project.AddMetadataReference(IListSourceReference)
.AddMetadataReference(EntityFrameworkReference)
.AddDocument(newFileName, SourceText.From(Properties.Resources.Model)).Project;
}
示例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);
}
}