本文整理汇总了C#中Microsoft.CodeAnalysis.CommandLine.BuildPaths类的典型用法代码示例。如果您正苦于以下问题:C# BuildPaths类的具体用法?C# BuildPaths怎么用?C# BuildPaths使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BuildPaths类属于Microsoft.CodeAnalysis.CommandLine命名空间,在下文中一共展示了BuildPaths类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunServerCompilation
public static Task<BuildResponse> RunServerCompilation(
RequestLanguage language,
List<string> arguments,
BuildPaths buildPaths,
string keepAlive,
string libEnvVariable,
CancellationToken cancellationToken) => Task.FromResult<BuildResponse>(null);
示例2: TryCreateCompiler
public bool TryCreateCompiler(RunRequest request, out CommonCompiler compiler)
{
var buildPaths = new BuildPaths(ClientDirectory, request.CurrentDirectory, SdkDirectory, request.TempDirectory);
switch (request.Language)
{
case LanguageNames.CSharp:
compiler = new CSharpCompilerServer(
AssemblyReferenceProvider,
args: request.Arguments,
buildPaths: buildPaths,
libDirectory: request.LibDirectory,
analyzerLoader: AnalyzerAssemblyLoader);
return true;
case LanguageNames.VisualBasic:
compiler = new VisualBasicCompilerServer(
AssemblyReferenceProvider,
args: request.Arguments,
buildPaths: buildPaths,
libDirectory: request.LibDirectory,
analyzerLoader: AnalyzerAssemblyLoader);
return true;
default:
compiler = null;
return false;
}
}
示例3: Run
internal static int Run(string[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
{
FatalError.Handler = FailFast.OnFatalException;
var responseFile = Path.Combine(buildPaths.ClientDirectory, CSharpCompiler.ResponseFileName);
var compiler = new Csc(responseFile, buildPaths, args, analyzerLoader);
return ConsoleUtil.RunWithUtf8Output(compiler.Arguments.Utf8Output, textWriter, tw => compiler.Run(tw));
}
示例4: RunServerCompilation
protected override Task<BuildResponse> RunServerCompilation(List<string> arguments, BuildPaths buildPaths, string sessionKey, string keepAlive, string libDirectory, CancellationToken cancellationToken)
{
if (_runServerCompilationFunc != null)
{
return _runServerCompilationFunc();
}
return base.RunServerCompilation(arguments, buildPaths, sessionKey, keepAlive, libDirectory, cancellationToken);
}
示例5: RunServerCompilation
protected override async Task<BuildResponse> RunServerCompilation(List<string> arguments, BuildPaths buildPaths, string keepAlive, string libDirectory, CancellationToken cancellationToken)
{
var client = new TcpClient();
await client.ConnectAsync("127.0.0.1", port: 12000).ConfigureAwait(true);
var request = BuildRequest.Create(_language, buildPaths.WorkingDirectory, arguments, keepAlive, libDirectory);
await request.WriteAsync(client.GetStream(), cancellationToken).ConfigureAwait(true);
return await BuildResponse.ReadAsync(client.GetStream(), cancellationToken).ConfigureAwait(true);
}
示例6: RunServerCompilation
protected override Task<BuildResponse> RunServerCompilation(
List<string> arguments,
BuildPaths buildPaths,
string sessionKey,
string keepAlive,
string libDirectory,
CancellationToken cancellationToken)
{
return RunServerCompilationCore(_language, arguments, buildPaths, sessionKey, keepAlive, libDirectory, TimeoutOverride, TryCreateServer, cancellationToken);
}
示例7: RunServerCompilation
protected override Task<BuildResponse> RunServerCompilation(
List<string> arguments,
BuildPaths buildPaths,
string keepAlive,
string libDirectory,
CancellationToken cancellationToken)
{
var pipeName = GetPipeName(buildPaths.ClientDirectory);
return RunServerCompilationCore(_language, arguments, buildPaths, pipeName, keepAlive, libDirectory, TryCreateServer, cancellationToken);
}
示例8: RunServerCompilation
public static Task<BuildResponse> RunServerCompilation(
RequestLanguage language,
List<string> arguments,
BuildPaths buildPaths,
string keepAlive,
string libEnvVariable,
CancellationToken cancellationToken)
{
throw new NotSupportedException();
}
示例9: Run
internal static int Run(IEnumerable<string> arguments, IEnumerable<string> extraArguments, RequestLanguage language, CompileFunc compileFunc, IAnalyzerAssemblyLoader analyzerAssemblyLoader)
{
var client = new DesktopBuildClient(language, compileFunc, analyzerAssemblyLoader);
var clientDir = AppDomain.CurrentDomain.BaseDirectory;
var sdkDir = RuntimeEnvironment.GetRuntimeDirectory();
var workingDir = Directory.GetCurrentDirectory();
var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: sdkDir);
var originalArguments = BuildClient.GetCommandLineArgs(arguments).Concat(extraArguments).ToArray();
return client.RunCompilation(originalArguments, buildPaths).ExitCode;
}
示例10: Run
internal static int Run(IEnumerable<string> arguments, RequestLanguage language, CompileFunc compileFunc)
{
// BTODO: Should be using BuildClient.GetCommandLineArgs(arguments) here. But the native invoke
// ends up giving us both CoreRun and the exe file. Need to find a good way to remove the host
// as well as the EXE argument.
var client = new CoreClrBuildClient(language, compileFunc);
var clientDir = AppContext.BaseDirectory;
var workingDir = Directory.GetCurrentDirectory();
var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: null);
return client.RunCompilation(arguments, buildPaths);
}
示例11: RunCompilation
/// <summary>
/// Run a compilation through the compiler server and print the output
/// to the console. If the compiler server fails, run the fallback
/// compiler.
/// </summary>
internal RunCompilationResult RunCompilation(IEnumerable<string> originalArguments, BuildPaths buildPaths, TextWriter textWriter = null)
{
textWriter = textWriter ?? Console.Out;
var args = originalArguments.Select(arg => arg.Trim()).ToArray();
bool hasShared;
string keepAlive;
string errorMessage;
string sessionKey;
List<string> parsedArgs;
if (!CommandLineParser.TryParseClientArgs(
args,
out parsedArgs,
out hasShared,
out keepAlive,
out sessionKey,
out errorMessage))
{
Console.Out.WriteLine(errorMessage);
return RunCompilationResult.Failed;
}
if (hasShared)
{
var libDirectory = Environment.GetEnvironmentVariable("LIB");
try
{
sessionKey = sessionKey ?? GetSessionKey(buildPaths);
var buildResponseTask = RunServerCompilation(
parsedArgs,
buildPaths,
sessionKey,
keepAlive,
libDirectory,
CancellationToken.None);
var buildResponse = buildResponseTask.Result;
if (buildResponse != null)
{
return HandleResponse(buildResponse, parsedArgs.ToArray(), buildPaths, textWriter);
}
}
catch (OperationCanceledException)
{
// #7866 tracks cleaning up this code.
return RunCompilationResult.Succeeded;
}
}
// It's okay, and expected, for the server compilation to fail. In that case just fall
// back to normal compilation.
var exitCode = RunLocalCompilation(parsedArgs.ToArray(), buildPaths, textWriter);
return new RunCompilationResult(exitCode);
}
示例12: Run
internal static int Run(IEnumerable<string> arguments, RequestLanguage language, CompileFunc compileFunc)
{
// Should be using BuildClient.GetCommandLineArgs(arguments) here. But the native invoke
// ends up giving us both CoreRun and the exe file. Need to find a good way to remove the host
// as well as the EXE argument.
// https://github.com/dotnet/roslyn/issues/6677
var client = new CoreClrBuildClient(language, compileFunc);
var clientDir = AppContext.BaseDirectory;
var workingDir = Directory.GetCurrentDirectory();
var tempDir = Path.GetTempPath();
var buildPaths = new BuildPaths(clientDir: clientDir, workingDir: workingDir, sdkDir: null, tempDir: tempDir);
return client.RunCompilation(arguments, buildPaths).ExitCode;
}
示例13: RunServerCompilation
public static Task<BuildResponse> RunServerCompilation(
RequestLanguage language,
List<string> arguments,
BuildPaths buildPaths,
string keepAlive,
string libEnvVariable,
CancellationToken cancellationToken)
=> DesktopBuildClient.RunServerCompilation(
language,
arguments,
buildPaths,
keepAlive,
libEnvVariable,
cancellationToken);
示例14: RunCompilation
/// <summary>
/// Run a compilation through the compiler server and print the output
/// to the console. If the compiler server fails, run the fallback
/// compiler.
/// </summary>
internal int RunCompilation(IEnumerable<string> originalArguments, BuildPaths buildPaths)
{
var args = originalArguments.Select(arg => arg.Trim()).ToArray();
bool hasShared;
string keepAlive;
string errorMessage;
string sessionKey;
List<string> parsedArgs;
if (!CommandLineParser.TryParseClientArgs(
args,
out parsedArgs,
out hasShared,
out keepAlive,
out sessionKey,
out errorMessage))
{
Console.Out.WriteLine(errorMessage);
return CommonCompiler.Failed;
}
if (hasShared)
{
var libDirectory = Environment.GetEnvironmentVariable("LIB");
try
{
sessionKey = sessionKey ?? GetSessionKey(buildPaths);
var buildResponseTask = RunServerCompilation(
parsedArgs,
buildPaths,
sessionKey,
keepAlive,
libDirectory,
CancellationToken.None);
var buildResponse = buildResponseTask.Result;
if (buildResponse != null)
{
return HandleResponse(buildResponse, parsedArgs, buildPaths);
}
}
catch
{
// It's okay, and expected, for the server compilation to fail. In that case just fall
// back to normal compilation.
}
}
return RunLocalCompilation(parsedArgs, buildPaths.ClientDirectory, buildPaths.SdkDirectory);
}
示例15: RunServerCompilation
public static Task<BuildResponse> RunServerCompilation(
RequestLanguage language,
List<string> arguments,
BuildPaths buildPaths,
string keepAlive,
string libEnvVariable,
CancellationToken cancellationToken)
{
return RunServerCompilationCore(
language,
arguments,
buildPaths,
GetPipeNameFromFileInfo(buildPaths.ClientDirectory),
keepAlive,
libEnvVariable,
TryCreateServerCore,
cancellationToken);
}