本文整理汇总了C#中Microsoft.DotNet.ProjectModel.ProjectContext.GetOutputPath方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectContext.GetOutputPath方法的具体用法?C# ProjectContext.GetOutputPath怎么用?C# ProjectContext.GetOutputPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.DotNet.ProjectModel.ProjectContext
的用法示例。
在下文中一共展示了ProjectContext.GetOutputPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileContext
public CompileContext(ProjectContext rootProject, BuilderCommandApp args)
{
_rootProject = rootProject;
_args = args;
// Set up Output Paths. They are unique per each CompileContext
// Todo: clone args and mutate the clone so the rest of this class does not have special treatment for output paths
_outputPath = _rootProject.GetOutputPath(_args.ConfigValue, _args.OutputValue);
_intermediateOutputPath = _rootProject.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue, _args.OutputValue);
// Set up dependencies
_dependencies = GetProjectDependenciesWithSources(_rootProject, _args.ConfigValue);
//gather preconditions
_preconditions = GatherIncrementalPreconditions();
}
示例2: CompileContext
public CompileContext(ProjectContext rootProject, BuilderCommandApp args)
{
_rootProject = rootProject;
// Cleaner to clone the args and mutate the clone than have separate CompileContext fields for mutated args
// and then reasoning which ones to get from args and which ones from fields.
_args = (BuilderCommandApp) args.ShallowCopy();
// Set up Output Paths. They are unique per each CompileContext
_args.OutputValue = _rootProject.GetOutputPath(_args.ConfigValue, _args.OutputValue);
_args.IntermediateValue = _rootProject.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue, _args.OutputValue);
// Set up dependencies
_dependencies = new ProjectDependenciesFacade(_rootProject, _args.ConfigValue);
// gather preconditions
_preconditions = GatherIncrementalPreconditions();
}
示例3: CompileNative
private static bool CompileNative(
ProjectContext context,
CompilerCommandApp args)
{
var outputPath = context.GetOutputPath(args.ConfigValue, args.OutputValue);
var nativeOutputPath = Path.Combine(outputPath, "native");
var intermediateOutputPath =
context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
Directory.CreateDirectory(nativeOutputPath);
Directory.CreateDirectory(intermediateOutputPath);
var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, args.ConfigValue);
var managedOutput =
GetProjectOutput(context.ProjectFile, context.TargetFramework, args.ConfigValue, outputPath);
var nativeArgs = new List<string>();
// Input Assembly
nativeArgs.Add($"{managedOutput}");
// ILC Args
if (!string.IsNullOrWhiteSpace(args.IlcArgsValue))
{
nativeArgs.Add("--ilcargs");
nativeArgs.Add($"{args.IlcArgsValue}");
}
// ILC Path
if (!string.IsNullOrWhiteSpace(args.IlcPathValue))
{
nativeArgs.Add("--ilcpath");
nativeArgs.Add(args.IlcPathValue);
}
// ILC SDK Path
if (!string.IsNullOrWhiteSpace(args.IlcSdkPathValue))
{
nativeArgs.Add("--ilcsdkpath");
nativeArgs.Add(args.IlcSdkPathValue);
}
// AppDep SDK Path
if (!string.IsNullOrWhiteSpace(args.AppDepSdkPathValue))
{
nativeArgs.Add("--appdepsdk");
nativeArgs.Add(args.AppDepSdkPathValue);
}
// CodeGen Mode
if(args.IsCppModeValue)
{
nativeArgs.Add("--mode");
nativeArgs.Add("cpp");
}
if (!string.IsNullOrWhiteSpace(args.CppCompilerFlagsValue))
{
nativeArgs.Add("--cppcompilerflags");
nativeArgs.Add(args.CppCompilerFlagsValue);
}
// Configuration
if (args.ConfigValue != null)
{
nativeArgs.Add("--configuration");
nativeArgs.Add(args.ConfigValue);
}
// Architecture
if (args.ArchValue != null)
{
nativeArgs.Add("--arch");
nativeArgs.Add(args.ArchValue);
}
// Intermediate Path
nativeArgs.Add("--temp-output");
nativeArgs.Add($"{intermediateOutputPath}");
// Output Path
nativeArgs.Add("--output");
nativeArgs.Add($"{nativeOutputPath}");
// Write Response File
var rsp = Path.Combine(intermediateOutputPath, $"dotnet-compile-native.{context.ProjectFile.Name}.rsp");
File.WriteAllLines(rsp, nativeArgs);
// TODO Add -r assembly.dll for all Nuget References
// Need CoreRT Framework published to nuget
// Do Native Compilation
var result = Command.Create("dotnet-compile-native", $"--rsp \"{rsp}\"")
.ForwardStdErr()
.ForwardStdOut()
.Execute();
return result.ExitCode == 0;
}
示例4: CompileProject
private static bool CompileProject(ProjectContext context, CompilerCommandApp args)
{
// Set up Output Paths
string outputPath = context.GetOutputPath(args.ConfigValue, args.OutputValue);
string intermediateOutputPath = context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
Directory.CreateDirectory(outputPath);
Directory.CreateDirectory(intermediateOutputPath);
// Create the library exporter
var exporter = context.CreateExporter(args.ConfigValue);
// Gather exports for the project
var dependencies = exporter.GetDependencies().ToList();
Reporter.Output.WriteLine($"Compiling {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}");
var sw = Stopwatch.StartNew();
var diagnostics = new List<DiagnosticMessage>();
var missingFrameworkDiagnostics = new List<DiagnosticMessage>();
// Collect dependency diagnostics
foreach (var diag in context.LibraryManager.GetAllDiagnostics())
{
if (diag.ErrorCode == ErrorCodes.DOTNET1011 ||
diag.ErrorCode == ErrorCodes.DOTNET1012)
{
missingFrameworkDiagnostics.Add(diag);
}
diagnostics.Add(diag);
}
if (missingFrameworkDiagnostics.Count > 0)
{
// The framework isn't installed so we should short circuit the rest of the compilation
// so we don't get flooded with errors
PrintSummary(missingFrameworkDiagnostics, sw);
return false;
}
// Get compilation options
var outputName = GetProjectOutput(context.ProjectFile, context.TargetFramework, args.ConfigValue, outputPath);
// Assemble args
var compilerArgs = new List<string>()
{
$"--temp-output:{intermediateOutputPath}",
$"--out:{outputName}"
};
var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, args.ConfigValue);
// Path to strong naming key in environment variable overrides path in project.json
var environmentKeyFile = Environment.GetEnvironmentVariable(EnvironmentNames.StrongNameKeyFile);
if (!string.IsNullOrWhiteSpace(environmentKeyFile))
{
compilationOptions.KeyFile = environmentKeyFile;
}
else if (!string.IsNullOrWhiteSpace(compilationOptions.KeyFile))
{
// Resolve full path to key file
compilationOptions.KeyFile = Path.GetFullPath(Path.Combine(context.ProjectFile.ProjectDirectory, compilationOptions.KeyFile));
}
var references = new List<string>();
// Add compilation options to the args
compilerArgs.AddRange(compilationOptions.SerializeToArgs());
// Add metadata options
compilerArgs.AddRange(AssemblyInfoOptions.SerializeToArgs(AssemblyInfoOptions.CreateForProject(context)));
foreach (var dependency in dependencies)
{
var projectDependency = dependency.Library as ProjectDescription;
if (projectDependency != null)
{
if (projectDependency.Project.Files.SourceFiles.Any())
{
var projectOutputPath = GetProjectOutput(projectDependency.Project, projectDependency.Framework, args.ConfigValue, outputPath);
references.Add(projectOutputPath);
}
}
else
{
references.AddRange(dependency.CompilationAssemblies.Select(r => r.ResolvedPath));
}
compilerArgs.AddRange(dependency.SourceReferences);
}
compilerArgs.AddRange(references.Select(r => $"--reference:{r}"));
if (compilationOptions.PreserveCompilationContext == true)
{
var dependencyContext = DependencyContextBuilder.Build(compilationOptions,
exporter,
//.........这里部分代码省略.........