Skip to content
Permalink
Browse files

[Assets] PackAssets: skip excluded files

  • Loading branch information
xen2 committed Dec 14, 2018
1 parent 772c37b commit 98a908be2ee6134879306972ac05608d2bd11f69
@@ -3,6 +3,8 @@

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.FileSystemGlobbing.Abstractions;
using System;
using System.Collections.Generic;
using System.IO;
@@ -66,13 +68,21 @@ void RegisterItem(UFile targetFilePath)
generatedItems.Add((targetFilePath.ToWindowsPath(), UPath.Combine("xenko", targetFilePath.MakeRelative(outputPath)).ToWindowsPath()));
}

void TryCopyDirectory(UDirectory sourceDirectory, UDirectory targetDirectory)
void TryCopyDirectory(UDirectory sourceDirectory, UDirectory targetDirectory, string exclude = null)
{
var resourceFiles = Directory.EnumerateFiles(sourceDirectory, "*.*", SearchOption.AllDirectories);
foreach (var resourceFile in resourceFiles)
var matcher = new Matcher(StringComparison.OrdinalIgnoreCase);
matcher.AddInclude("**/*.*");
if (exclude != null)
{
var resourceFilePath = (UFile)resourceFile;
var targetFilePath = UPath.Combine(targetDirectory, resourceFilePath.MakeRelative(sourceDirectory));
foreach (var excludeEntry in exclude.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
matcher.AddExclude(excludeEntry);
}

//var resourceFiles = Directory.EnumerateFiles(sourceDirectory, "*.*", SearchOption.AllDirectories);
foreach (var resourceFile in matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(sourceDirectory))).Files)
{
var resourceFilePath = UPath.Combine(sourceDirectory, (UFile)resourceFile.Path);
var targetFilePath = UPath.Combine(targetDirectory, (UFile)resourceFile.Path);

TryCopyResource(resourceFilePath, targetFilePath);
}
@@ -218,7 +228,7 @@ void TryCopyResource(UFile resourceFilePath, UFile targetFilePath)
target = UPath.Combine(target, templateFolder.Group);
}

TryCopyDirectory(templateFolder.Path, target);
TryCopyDirectory(templateFolder.Path, target, templateFolder.Exclude);

// Add template files
foreach (var templateFile in templateFolder.Files)
@@ -3,24 +3,24 @@ SerializedVersion: {Assets: 3.1.0.0}
TemplateFolders:
- Path: !dir ../../../samples
Group: Samples
Exclude: "**/Testing/**;**/.git/**;**/_ReSharper.*/**;**/Bin/**;**/obj/**;**/*.sln;**/*.suo;**/*.GhostDoc.xml;**/samples2/readme.md;**/samples2/.gitignore;**/*.psess;**/*.vspx;**/*.userprefs"
Exclude: "**/Testing/**;**/.git/**;**/_ReSharper.*/**;**/Bin/**;**/obj/**;**/*.sln;**/*.suo;**/.vs/**;**/*.GhostDoc.xml;readme.md;.gitignore;**/*.psess;**/*.vspx;**/*.userprefs"
Files:
- !file ..\..\..\samples\Audio\SimpleAudio\SimpleAudio.xktpl
- !file ..\..\..\samples\Games\JumpyJet\JumpyJet.xktpl
- !file ..\..\..\samples\Games\SpaceEscape\SpaceEscape.xktpl
- !file ..\..\..\samples\Graphics\AnimatedModel\AnimatedModel.xktpl
- !file ..\..\..\samples\Graphics\CustomEffect\CustomEffect.xktpl
- !file ..\..\..\samples\Graphics\MaterialShader\MaterialShader.xktpl
- !file ..\..\..\samples\Graphics\SpriteFonts\SpriteFonts.xktpl
- !file ..\..\..\samples\Graphics\SpriteStudioDemo\SpriteStudioDemo.xktpl
- !file ..\..\..\samples\Input\TouchInputs\TouchInputs.xktpl
- !file ..\..\..\samples\Input\GravitySensor\GravitySensor.xktpl
- !file ..\..\..\samples\Particles\ParticlesSample\ParticlesSample.xktpl
- !file ..\..\..\samples\Physics\PhysicsSample\PhysicsSample.xktpl
- !file ..\..\..\samples\UI\GameMenu\GameMenu.xktpl
- !file ..\..\..\samples\UI\UIParticles\UIParticles.xktpl
- !file ..\..\..\samples\UI\UIElementLink\UIElementLink.xktpl
- !file ..\..\..\samples\Templates\FirstPersonShooter\FirstPersonShooter\FirstPersonShooter.xktpl
- !file ..\..\..\samples\Templates\ThirdPersonPlatformer\ThirdPersonPlatformer\ThirdPersonPlatformer.xktpl
- !file ..\..\..\samples\Templates\TopDownRPG\TopDownRPG\TopDownRPG.xktpl
- !file ..\..\..\samples\Templates\VRSandbox\VRSandbox\VRSandbox.xktpl
- !file ../../../samples/Audio/SimpleAudio/SimpleAudio.xktpl
- !file ../../../samples/Games/JumpyJet/JumpyJet.xktpl
- !file ../../../samples/Games/SpaceEscape/SpaceEscape.xktpl
- !file ../../../samples/Graphics/AnimatedModel/AnimatedModel.xktpl
- !file ../../../samples/Graphics/CustomEffect/CustomEffect.xktpl
- !file ../../../samples/Graphics/MaterialShader/MaterialShader.xktpl
- !file ../../../samples/Graphics/SpriteFonts/SpriteFonts.xktpl
- !file ../../../samples/Graphics/SpriteStudioDemo/SpriteStudioDemo.xktpl
- !file ../../../samples/Input/TouchInputs/TouchInputs.xktpl
- !file ../../../samples/Input/GravitySensor/GravitySensor.xktpl
- !file ../../../samples/Particles/ParticlesSample/ParticlesSample.xktpl
- !file ../../../samples/Physics/PhysicsSample/PhysicsSample.xktpl
- !file ../../../samples/UI/GameMenu/GameMenu.xktpl
- !file ../../../samples/UI/UIParticles/UIParticles.xktpl
- !file ../../../samples/UI/UIElementLink/UIElementLink.xktpl
- !file ../../../samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.xktpl
- !file ../../../samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.xktpl
- !file ../../../samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.xktpl
- !file ../../../samples/Templates/VRSandbox/VRSandbox/VRSandbox.xktpl

0 comments on commit 98a908b

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