Skip to content

Commit

Permalink
[msbuild] Refactor out function in CompileSceneKitAssets to make code…
Browse files Browse the repository at this point in the history
… reuse possible
  • Loading branch information
rolfbjarne committed Jul 5, 2024
1 parent b6ab749 commit 71d6803
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileSceneKitAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ Task CopySceneKitAssets (string scnassets, string output, string intermediate)
return ExecuteAsync (GetFullPathToTool (), args, sdkDevPath: SdkDevPath, environment: environment, showErrorIfFailure: true);
}

static bool TryGetScnAssetsPath (string file, out string scnassets)
{
scnassets = file;
while (scnassets.Length > 0 && Path.GetExtension (scnassets).ToLowerInvariant () != ".scnassets")
scnassets = Path.GetDirectoryName (scnassets);
return scnassets.Length > 0;
}

public override bool Execute ()
{
if (ShouldExecuteRemotely ()) {
Expand All @@ -141,11 +149,7 @@ public override bool Execute ()
continue;

// get the .scnassets directory path
var scnassets = Path.GetDirectoryName (asset.ItemSpec);
while (scnassets.Length > 0 && Path.GetExtension (scnassets).ToLowerInvariant () != ".scnassets")
scnassets = Path.GetDirectoryName (scnassets);

if (scnassets.Length == 0)
if (!TryGetScnAssetsPath (asset.ItemSpec, out var scnassets))
continue;

asset.RemoveMetadata ("LogicalName");
Expand Down

0 comments on commit 71d6803

Please sign in to comment.