Skip to content
Permalink
Browse files

[GameStudio] Fixed template samples generator to work with updated pr…

…oject format
  • Loading branch information
xen2 committed Dec 13, 2018
1 parent bea53b9 commit aaf3ce5635dd9e393d9458ef08f886ba4bed3a3a
Showing with 10 additions and 31 deletions.
  1. +10 −31 sources/editor/Xenko.Assets.Presentation/Templates/TemplateSampleGenerator.cs
@@ -80,27 +80,6 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
// Setting this to true will enforce all package dependencies to be moved to a folder local to the project
bool doMoveParentDependencies = true;

var packageFile = Path.ChangeExtension(description.FullPath.ToWindowsPath(), Package.PackageFileExtension);

if (!File.Exists(packageFile))
{
log.Error($"Unable to find package [{packageFile}]");
return false;
}

var packageLoadResult = new LoggerResult();
var package = Package.Load(packageLoadResult, packageFile, new PackageLoadParameters
{
AutoLoadTemporaryAssets = false,
AutoCompileProjects = false,
LoadAssemblyReferences = false,
});
packageLoadResult.CopyTo(log);
if (packageLoadResult.HasErrors)
{
return false;
}

var regexes = new List<Tuple<Regex, MatchEvaluator>>();
var patternName = description.PatternName ?? description.DefaultOutputName;

@@ -129,8 +108,8 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
//write gitignore
WriteGitIgnore(parameters);

UFile packageOutputFile = null;
UFile packageInputFile = null;
UFile projectOutputFile = null;
UFile projectInputFile = null;

// Process files
foreach (var directory in FileUtility.EnumerateDirectories(description.TemplateDirectory, SearchDirection.Down))
@@ -156,13 +135,13 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
var outputFile = UPath.Combine(outputDirectory, relativeFile);
var outputFileDirectory = outputFile.GetParent();

// Grab the name of the output package file
var isPackageFile = (packageOutputFile == null && file.FullName.EndsWith(Package.PackageFileExtension));
// Determine if we are processing the main game project
var isPackageFile = (projectOutputFile == null && Path.GetExtension(file.FullName).ToLowerInvariant() == ".csproj" && !Path.GetFileNameWithoutExtension(file.FullName).EndsWith(".Windows"));

if (isPackageFile)
{
packageInputFile = file.FullName;
packageOutputFile = outputFile;
projectInputFile = file.FullName;
projectOutputFile = outputFile;
}

if (!Directory.Exists(outputFileDirectory))
@@ -181,10 +160,10 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
}
}

if (packageOutputFile != null)
if (projectOutputFile != null)
{
var inputProject = (SolutionProject)Package.LoadProject(log, packageInputFile);
var outputProject = (SolutionProject)Package.LoadProject(log, packageOutputFile);
var inputProject = (SolutionProject)Package.LoadProject(log, projectInputFile);
var outputProject = (SolutionProject)Package.LoadProject(log, projectOutputFile);
var msbuildProject = VSProjectHelper.LoadProject(outputProject.FullPath, platform: "NoPlatform");

// If requested, add reference to Xenko.Games.Testing
@@ -264,7 +243,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
loadParams.LoadMissingDependencies = false;
var session = parameters.Session;
// We should switch to loading .csproj once all samples are upgraded
var loadedProject = session.AddExistingProject(packageOutputFile, log, loadParams);
var loadedProject = session.AddExistingProject(projectOutputFile, log, loadParams);

RemoveUnusedAssets(loadedProject.Package, session);

0 comments on commit aaf3ce5

Please sign in to comment.
You can’t perform that action at this time.