本文整理汇总了C#中LoggerResult.ToText方法的典型用法代码示例。如果您正苦于以下问题:C# LoggerResult.ToText方法的具体用法?C# LoggerResult.ToText怎么用?C# LoggerResult.ToText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoggerResult
的用法示例。
在下文中一共展示了LoggerResult.ToText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PackageStore
/// <summary>
/// Initializes a new instance of the <see cref="PackageStore"/> class.
/// </summary>
/// <exception cref="System.InvalidOperationException">Unable to find a valid Xenko installation path</exception>
private PackageStore(string installationPath = null, string defaultPackageName = "Xenko", string defaultPackageVersion = XenkoVersion.CurrentAsText)
{
// TODO: these are currently hardcoded to Xenko
DefaultPackageName = defaultPackageName;
DefaultPackageVersion = new PackageVersion(defaultPackageVersion);
defaultPackageDirectory = DirectoryHelper.GetPackageDirectory(defaultPackageName);
// 1. Try to use the specified installation path
if (installationPath != null)
{
if (!DirectoryHelper.IsInstallationDirectory(installationPath))
{
throw new ArgumentException("Invalid Xenko installation path [{0}]".ToFormat(installationPath), "installationPath");
}
globalInstallationPath = installationPath;
}
// 2. Try to resolve an installation path from the path of this assembly
// We need to be able to use the package manager from an official Xenko install as well as from a developer folder
if (globalInstallationPath == null)
{
globalInstallationPath = DirectoryHelper.GetInstallationDirectory(DefaultPackageName);
}
// If there is no root, this is an error
if (globalInstallationPath == null)
{
throw new InvalidOperationException("Unable to find a valid Xenko installation or dev path");
}
// Preload default package
var logger = new LoggerResult();
var defaultPackageFile = DirectoryHelper.GetPackageFile(defaultPackageDirectory, DefaultPackageName);
defaultPackage = Package.Load(logger, defaultPackageFile, GetDefaultPackageLoadParameters());
if (defaultPackage == null)
{
throw new InvalidOperationException("Error while loading default package from [{0}]: {1}".ToFormat(defaultPackageFile, logger.ToText()));
}
defaultPackage.IsSystem = true;
// A flag variable just to know if it is a bare bone development directory
isDev = defaultPackageDirectory != null && DirectoryHelper.IsRootDevDirectory(defaultPackageDirectory);
// Check if we are in a root directory with store/packages facilities
if (NugetStore.IsStoreDirectory(globalInstallationPath))
{
packagesDirectory = UPath.Combine(globalInstallationPath, (UDirectory)NugetStore.DefaultGamePackagesDirectory);
store = new NugetStore(globalInstallationPath);
}
else
{
// We should exit from here if NuGet is not configured.
MessageBox.Show($"Unexpected installation. Cannot find a proper NuGet configuration for [{defaultPackageName}] in [{globalInstallationPath}]", "Installation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
示例2: Main
private static int Main(string[] args)
{
Console.WriteLine(@"Bootstrapping: " + args[0]);
var xenkoDir = Environment.GetEnvironmentVariable("SiliconStudioXenkoDir");
var xenkoPkgPath = UPath.Combine(xenkoDir, new UFile("Xenko.xkpkg"));
var session = PackageSession.Load(xenkoPkgPath);
var generator = TemplateSampleGenerator.Default;
var logger = new LoggerResult();
var parameters = new TemplateGeneratorParameters { Session = session.Session };
var outputPath = UPath.Combine(new UDirectory(xenkoDir), new UDirectory("samplesGenerated"));
outputPath = UPath.Combine(outputPath, new UDirectory(args[0]));
var xenkoTemplates = session.Session.Packages.First().Templates;
parameters.Description = xenkoTemplates.First(x => x.Group.StartsWith("Samples") && x.Id == new Guid(args[1]));
parameters.Name = args[0];
parameters.Namespace = args[0];
parameters.OutputDirectory = outputPath;
parameters.Logger = logger;
generator.Generate(parameters);
var updaterTemplate = xenkoTemplates.First(x => x.FullPath.ToString().EndsWith("UpdatePlatforms.xktpl"));
parameters.Description = updaterTemplate;
var updater = UpdatePlatformsTemplateGenerator.Default;
var gameSettingsAsset = session.Session.Packages.Last().GetGameSettingsAsset();
var updateParams = new GameTemplateParameters
{
Common = parameters,
ForcePlatformRegeneration = true,
GraphicsProfile = gameSettingsAsset.DefaultGraphicsProfile,
IsHDR = false,
Orientation = gameSettingsAsset.DisplayOrientation,
Platforms = AssetRegistry.SupportedPlatforms.ToList()
};
updater.Generate(updateParams);
Console.WriteLine(logger.ToText());
return logger.HasErrors ? 1 : 0;
}
示例3: CheckResult
// TODO: THIS IS JUST A WORKAROUND, REMOVE THIS
private static void CheckResult(LoggerResult compilerResult)
{
// Check errors
if (compilerResult.HasErrors)
{
throw new InvalidOperationException("Could not compile shader. See error messages." + compilerResult.ToText());
}
}
示例4: GenerateUnitTestProject
private static void GenerateUnitTestProject(string outputDirectory, string templateFile, string name, string projectNamespace)
{
var projectTemplate = ProjectTemplate.Load(templateFile);
// Force reference to Xenko.Assets (to have acess to SolutionPlatform)
projectTemplate.Assemblies.Add(typeof(GraphicsProfile).Assembly.FullName);
projectTemplate.Assemblies.Add(typeof(XenkoConfig).Assembly.FullName);
var options = new Dictionary<string, object>();
// When generating over an existing set of files, retrieve the existing IDs
// for better incrementality
Guid projectGuid, assetId;
GetExistingGuid(outputDirectory, name + ".Windows.csproj", out projectGuid);
GetExistingAssetId(outputDirectory, name + ".xkpkg", out assetId);
var session = new PackageSession();
var result = new LoggerResult();
var templateGeneratorParameters = new SessionTemplateGeneratorParameters();
templateGeneratorParameters.OutputDirectory = outputDirectory;
templateGeneratorParameters.Session = session;
templateGeneratorParameters.Name = name;
templateGeneratorParameters.Logger = result;
templateGeneratorParameters.Description = new TemplateDescription();
templateGeneratorParameters.Id = assetId;
if (!PackageUnitTestGenerator.Default.PrepareForRun(templateGeneratorParameters).Result)
{
Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.PrepareForRun returned false");
return;
}
if (!PackageUnitTestGenerator.Default.Run(templateGeneratorParameters))
{
Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.Run returned false");
return;
}
if (result.HasErrors)
{
Console.WriteLine($"Error generating package: {result.ToText()}");
return;
}
var package = session.LocalPackages.Single();
var previousCurrent = session.CurrentPackage;
session.CurrentPackage = package;
// Compute Xenko Sdk relative path
// We are supposed to be in standard output binary folder, so Xenko root should be at ..\..
var xenkoPath = UPath.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new UDirectory(@"..\.."));
var xenkoRelativePath = new UDirectory(xenkoPath)
.MakeRelative(outputDirectory)
.ToString()
.Replace('/', '\\');
xenkoRelativePath = xenkoRelativePath.TrimEnd('\\');
options["Namespace"] = projectNamespace ?? name;
options["Package"] = package;
options["Platforms"] = new List<SolutionPlatform>(AssetRegistry.SupportedPlatforms);
options["XenkoSdkRelativeDir"] = xenkoRelativePath;
// Generate project template
result = projectTemplate.Generate(outputDirectory, name, projectGuid, options);
if (result.HasErrors)
{
Console.WriteLine("Error generating solution: {0}", result.ToText());
return;
}
var sharedProfile = package.Profiles.FindSharedProfile();
// Setup the assets folder
Directory.CreateDirectory(UPath.Combine(outputDirectory, (UDirectory)"Assets/Shared"));
// Add Windows test as Shared library
var projectWindowsRef = new ProjectReference
{
Id = projectGuid,
Location = UPath.Combine(outputDirectory, (UFile)(name + ".Windows.csproj")),
Type = SiliconStudio.Assets.ProjectType.Library
};
sharedProfile.ProjectReferences.Add(projectWindowsRef);
// Generate executable projects for each platform
foreach (var platform in AssetRegistry.SupportedPlatforms)
{
var platformProfile = new PackageProfile(platform.Name) { Platform = platform.Type };
platformProfile.AssetFolders.Add(new AssetFolder("Assets/"+ platform.Name));
// Log progress
var projectName = name + "." + platform.Type;
// Create project reference
var projectPlatformRef = new ProjectReference
{
Id = projectGuid,
Location = UPath.Combine(outputDirectory, (UFile)(projectName + ".csproj")),
Type = SiliconStudio.Assets.ProjectType.Executable
};
//.........这里部分代码省略.........
示例5: GenerateUnitTestProject
private static void GenerateUnitTestProject(string outputDirectory, string templateFile, string name)
{
var projectTemplate = ProjectTemplate.Load(templateFile);
// Force reference to Paradox.Assets (to have acess to SolutionPlatform)
projectTemplate.Assemblies.Add(typeof(GraphicsProfile).Assembly.FullName);
projectTemplate.Assemblies.Add(typeof(ParadoxConfig).Assembly.FullName);
var options = new Dictionary<string, object>();
var session = new PackageSession();
var result = new LoggerResult();
var templateGeneratorParameters = new TemplateGeneratorParameters();
templateGeneratorParameters.OutputDirectory = outputDirectory;
templateGeneratorParameters.Session = session;
templateGeneratorParameters.Name = name;
templateGeneratorParameters.Logger = result;
templateGeneratorParameters.Description = new TemplateDescription();
PackageUnitTestGenerator.Default.Generate(templateGeneratorParameters);
if (result.HasErrors)
{
Console.WriteLine("Error generating package: {0}", result.ToText());
return;
}
var package = templateGeneratorParameters.Package;
var previousCurrent = session.CurrentPackage;
session.CurrentPackage = package;
// Compute Paradox Sdk relative path
// We are supposed to be in standard output binary folder, so Paradox root should be at ..\..
var paradoxPath = UDirectory.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new UDirectory(@"..\.."));
var paradoxRelativePath = new UDirectory(paradoxPath)
.MakeRelative(outputDirectory)
.ToString()
.Replace('/', '\\');
paradoxRelativePath = paradoxRelativePath.TrimEnd('\\');
options["Namespace"] = name;
options["Package"] = package;
options["Platforms"] = new List<SolutionPlatform>(AssetRegistry.SupportedPlatforms);
options["ParadoxSdkRelativeDir"] = paradoxRelativePath;
// Generate project template
var projectGuid = Guid.NewGuid();
result = projectTemplate.Generate(outputDirectory, name, projectGuid, options);
if (result.HasErrors)
{
Console.WriteLine("Error generating solution: {0}", result.ToText());
return;
}
var sharedProfile = package.Profiles[PlatformType.Shared];
// Setup the assets folder
Directory.CreateDirectory(UPath.Combine(outputDirectory, (UDirectory)"Assets/Shared"));
// Add Windows test as Shared library
var projectWindowsRef = new ProjectReference();
projectWindowsRef.Id = projectGuid;
projectWindowsRef.Location = UPath.Combine(outputDirectory, (UFile)(name + ".Windows.csproj"));
projectWindowsRef.Type = SiliconStudio.Assets.ProjectType.Library;
sharedProfile.ProjectReferences.Add(projectWindowsRef);
// Generate executable projects for each platform
foreach (var platform in AssetRegistry.SupportedPlatforms)
{
var platformProfile = new PackageProfile(platform.Name) { Platform = platform.Type };
platformProfile.AssetFolders.Add(new AssetFolder("Assets/"+ platform.Name));
// Log progress
var projectName = name + "." + platform.Type;
// Create project reference
var projectPlatformRef = new ProjectReference();
projectPlatformRef.Id = projectGuid;
projectPlatformRef.Location = UPath.Combine(outputDirectory, (UFile)(projectName + ".csproj"));
projectPlatformRef.Type = SiliconStudio.Assets.ProjectType.Executable;
platformProfile.ProjectReferences.Add(projectPlatformRef);
// Add build configuration per platform
platform.Properties.CopyTo(platformProfile.Properties, true);
package.Profiles.Add(platformProfile);
}
session.CurrentPackage = previousCurrent;
result = session.Save();
if (result.HasErrors)
{
Console.WriteLine("Error saving package: {0}", result.ToText());
return;
}
}