Skip to content
Permalink
Browse files

[Templates] Sample Templates now works (asset packs are now ProjectRe…

…ference and their assets are properly copied during template generation)
  • Loading branch information
xen2 committed Sep 12, 2018
1 parent 42306db commit 24bb053badc62769af951f55246354c1c9768aab
@@ -9,5 +9,9 @@
<PackageReference Include="Xenko" Version="3.0.0.1-dev">
<PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\..\Packs\VFXPackage\VFXPackage.csproj"/>
<ProjectReference Include="..\..\..\Packs\PrototypingBlocks\PrototypingBlocks.csproj"/>
<ProjectReference Include="..\..\..\Packs\mannequinModel\mannequinModel.csproj"/>
<ProjectReference Include="..\..\..\Packs\SamplesAssetPackage\SamplesAssetPackage.csproj"/>
</ItemGroup>
</Project>
@@ -11,11 +11,6 @@ Meta:
- Name: Xenko
Version: 3.0.0.1-dev
RootAssets: []
LocalDependencies:
- 575b8dc7-3fad-497d-acf7-fbdfabcece80:../../Packs/VFXPackage/VFXPackage.xkpkg
- c9b4f26a-e7ba-4201-a6e0-0c0eedfe9de2:../../Packs/PrototypingBlocks/PrototypingBlocks.xkpkg
- ec64fd24-824f-4da4-b077-3661cf988027:../../Packs/mannequinModel/mannequinModel.xkpkg
- bdd7a38f-3ff5-4279-b7b7-27a4c677f4d7:../../Packs/SamplesAssetPackage/SamplesAssetPackage.xkpkg
Profiles:
- Name: Shared
Platform: Shared
@@ -9,5 +9,7 @@
<PackageReference Include="Xenko" Version="3.0.0.1-dev">
<PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\..\Packs\PrototypingBlocks\PrototypingBlocks.csproj"/>
<ProjectReference Include="..\..\..\Packs\mannequinModel\mannequinModel.csproj"/>
</ItemGroup>
</Project>
@@ -11,9 +11,6 @@ Meta:
- Name: Xenko
Version: 3.0.0.1-dev
RootAssets: []
LocalDependencies:
- ec64fd24-824f-4da4-b077-3661cf988027:../../Packs/mannequinModel/mannequinModel.xkpkg
- c9b4f26a-e7ba-4201-a6e0-0c0eedfe9de2:../../Packs/PrototypingBlocks/PrototypingBlocks.xkpkg
Profiles:
- Name: Shared
Platform: Shared
@@ -9,5 +9,9 @@
<PackageReference Include="Xenko" Version="3.0.0.1-dev">
<PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\..\Packs\VFXPackage\VFXPackage.csproj"/>
<ProjectReference Include="..\..\..\Packs\PrototypingBlocks\PrototypingBlocks.csproj"/>
<ProjectReference Include="..\..\..\Packs\mannequinModel\mannequinModel.csproj"/>
<ProjectReference Include="..\..\..\Packs\SamplesAssetPackage\SamplesAssetPackage.csproj"/>
</ItemGroup>
</Project>
@@ -11,11 +11,6 @@ Meta:
- Name: Xenko
Version: 3.0.0.1-dev
RootAssets: []
LocalDependencies:
- ec64fd24-824f-4da4-b077-3661cf988027:../../Packs/mannequinModel/mannequinModel.xkpkg
- c9b4f26a-e7ba-4201-a6e0-0c0eedfe9de2:../../Packs/PrototypingBlocks/PrototypingBlocks.xkpkg
- bdd7a38f-3ff5-4279-b7b7-27a4c677f4d7:../../Packs/SamplesAssetPackage/SamplesAssetPackage.xkpkg
- 575b8dc7-3fad-497d-acf7-fbdfabcece80:../../Packs/VFXPackage/VFXPackage.xkpkg
Profiles:
- Name: Shared
Platform: Shared
@@ -9,5 +9,7 @@
<PackageReference Include="Xenko" Version="3.0.0.1-dev">
<PrivateAssets>contentfiles;analyzers</PrivateAssets>
</PackageReference>
<ProjectReference Include="..\..\..\Packs\mannequinModel\mannequinModel.csproj"/>
<ProjectReference Include="..\..\..\Packs\SamplesAssetPackage\SamplesAssetPackage.csproj"/>
</ItemGroup>
</Project>
@@ -11,9 +11,6 @@ Meta:
- Name: Xenko
Version: 3.0.0.1-dev
RootAssets: []
LocalDependencies:
- ec64fd24-824f-4da4-b077-3661cf988027:../../Packs/mannequinModel/mannequinModel.xkpkg
- bdd7a38f-3ff5-4279-b7b7-27a4c677f4d7:../../Packs/SamplesAssetPackage/SamplesAssetPackage.xkpkg
Profiles:
- Name: Shared
Platform: Shared
@@ -139,6 +139,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
WriteGitIgnore(parameters);

UFile packageOutputFile = null;
UFile packageInputFile = null;

// Process files
foreach (var directory in FileUtility.EnumerateDirectories(description.TemplateDirectory, SearchDirection.Down))
@@ -169,6 +170,7 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)

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

@@ -188,64 +190,72 @@ protected override bool Generate(SessionTemplateGeneratorParameters parameters)
}
}

// TODO CSPROJ=XKPKG
/*
// Copy dependency files locally
// We only want to copy the asset files. The raw files are in Resources and the game assets are in Assets.
// If we copy each file locally they will be included in the package and we can then delete the dependency packages.
foreach (var packageReference in package.LocalDependencies)
if (packageOutputFile != null)
{
var packageDirectory = packageReference.Location.GetFullDirectory();
foreach (var directory in FileUtility.EnumerateDirectories(packageDirectory, SearchDirection.Down))
var inputProject = (SolutionProject)Package.LoadProject(log, packageInputFile);
var outputProject = (SolutionProject)Package.LoadProject(log, packageOutputFile);
var msbuildProject = VSProjectHelper.LoadProject(outputProject.FullPath, platform: "NoPlatform");

// Copy dependency files locally
// We only want to copy the asset files. The raw files are in Resources and the game assets are in Assets.
// If we copy each file locally they will be included in the package and we can then delete the dependency packages.
foreach (var projectReference in msbuildProject.GetItems("ProjectReference").ToList())
{
foreach (var file in directory.GetFiles())
var packageDirectory = UPath.Combine(inputProject.FullPath.GetFullDirectory(), (UFile)projectReference.EvaluatedInclude).GetFullDirectory();
foreach (var directory in FileUtility.EnumerateDirectories(packageDirectory, SearchDirection.Down))
{
// If the file is ending with the Template extension or a directory with the sample extension, don`t copy it
if (file.FullName.EndsWith(TemplateDescription.FileExtension) ||
string.Compare(directory.Name, TemplateDescription.FileExtension, StringComparison.OrdinalIgnoreCase) == 0)
foreach (var file in directory.GetFiles())
{
continue;
}
// If the file is ending with the Template extension or a directory with the sample extension, don`t copy it
if (file.FullName.EndsWith(TemplateDescription.FileExtension) ||
string.Compare(directory.Name, TemplateDescription.FileExtension, StringComparison.OrdinalIgnoreCase) == 0)
{
continue;
}

var relativeFile = new UFile(file.FullName).MakeRelative(packageDirectory);
var relativeFilename = relativeFile.ToString();
var relativeFile = new UFile(file.FullName).MakeRelative(packageDirectory);
var relativeFilename = relativeFile.ToString();

bool isAsset = relativeFilename.Contains("Assets");
bool isResource = relativeFilename.Contains("Resources");
bool isAsset = relativeFilename.Contains("Assets");
bool isResource = relativeFilename.Contains("Resources");

if (!isAsset && !isResource)
continue;
if (!isAsset && !isResource)
continue;

// Replace the name in the files if necessary
foreach (var nameRegex in regexes)
{
relativeFile = nameRegex.Item1.Replace(relativeFile, nameRegex.Item2);
}
var outputFile = UPath.Combine(outputDirectory, relativeFile);
{ // Create the output directory if needed
var outputFileDirectory = outputFile.GetParent();
if (!Directory.Exists(outputFileDirectory))
// Replace the name in the files if necessary
foreach (var nameRegex in regexes)
{
Directory.CreateDirectory(outputFileDirectory);
relativeFile = nameRegex.Item1.Replace(relativeFile, nameRegex.Item2);
}
}

if (IsBinaryFile(file.FullName))
{
File.Copy(file.FullName, outputFile, true);
}
else
{
ProcessTextFile(file.FullName, outputFile, regexes);
var outputFile = UPath.Combine(outputDirectory, relativeFile);
{ // Create the output directory if needed
var outputFileDirectory = outputFile.GetParent();
if (!Directory.Exists(outputFileDirectory))
{
Directory.CreateDirectory(outputFileDirectory);
}
}

if (IsBinaryFile(file.FullName))
{
File.Copy(file.FullName, outputFile, true);
}
else
{
ProcessTextFile(file.FullName, outputFile, regexes);
}
}
}

msbuildProject.RemoveItem(projectReference);
}
}
*/

if (packageOutputFile != null)
{
// Save csproj without ProjectReferences
msbuildProject.Save();
msbuildProject.ProjectCollection.UnloadAllProjects();
msbuildProject.ProjectCollection.Dispose();

// Add package to session
var loadParams = PackageLoadParameters.Default();
loadParams.ForceNugetRestore = true;

0 comments on commit 24bb053

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