本文整理汇总了C#中Tests.Options.GetCompilerAbsolutePath方法的典型用法代码示例。如果您正苦于以下问题:C# Options.GetCompilerAbsolutePath方法的具体用法?C# Options.GetCompilerAbsolutePath怎么用?C# Options.GetCompilerAbsolutePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tests.Options
的用法示例。
在下文中一共展示了Options.GetCompilerAbsolutePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
internal static string Build(Options options, out string absoluteSourceDir)
{
var sourceFile = options.MakeAbsolute(options.SourceFile);
var compilerPath = options.GetCompilerAbsolutePath(ToolsRoot);
Assert.IsTrue(File.Exists(compilerPath), string.Format("Can't find compiler at '{0}'", compilerPath));
var contractreferencedir = options.MakeAbsolute(Path.Combine(ContractReferenceDirRoot, options.ReferencesFramework));
var sourcedir = absoluteSourceDir = Path.GetDirectoryName(sourceFile);
var outputdir = Path.Combine(Path.Combine(sourcedir, "bin"), options.CompilerPath);
var extension = options.UseExe ? ".exe" : ".dll";
var targetKind = options.UseExe ? "exe" : "library";
var targetfile = Path.Combine(outputdir, options.TestName + extension);
// add Microsoft.Contracts reference if needed
if (options.IsV35)
{
options.References.Add("Microsoft.Contracts.dll");
}
var oldCwd = Environment.CurrentDirectory;
try
{
Environment.CurrentDirectory = sourcedir;
var resolvedReferences = ResolveReferences(options);
var referenceString = ReferenceOptions(resolvedReferences);
if (!Directory.Exists(outputdir))
{
Directory.CreateDirectory(outputdir);
}
string arguments = String.Format("/t:{4} /out:{0} {3} {2} {1}", targetfile, sourceFile, referenceString, options.FinalCompilerOptions, targetKind);
if (!options.ReleaseMode)
{
arguments = "/debug " + arguments;
}
var exitCode = RunProcess(sourcedir, compilerPath, arguments, true);
if (exitCode != 0)
{
return null;
}
// add reference to Microsoft.Contracts.dll if not already done because of transitive closure issues
if (!options.References.Contains("Microsoft.Contracts.dll"))
{
options.References.Add("Microsoft.Contracts.dll");
// recompute resolvedReferences
resolvedReferences = ResolveReferences(options);
}
CopyReferenceAssemblies(resolvedReferences, outputdir);
return targetfile;
}
finally
{
Environment.CurrentDirectory = oldCwd;
}
}