diff --git a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileSceneKitAssetsTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileSceneKitAssetsTaskBase.cs index f51ffce23559..8f825913bf42 100644 --- a/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileSceneKitAssetsTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks.Core/Tasks/CompileSceneKitAssetsTaskBase.cs @@ -195,6 +195,17 @@ public override bool Execute () // .. and remove the @OriginalItemSpec which is for @asset scnassetsItem.RemoveMetadata ("OriginalItemSpec"); + // The Link metadata is for the asset, but 'scnassetsItem' is the containing *.scnasset directory, + // so we need to update the Link metadata accordingly (if it exists). + var link = scnassetsItem.GetMetadata ("Link"); + if (!string.IsNullOrEmpty (link)) { + var newLinkLength = link.Length - (asset.ItemSpec.Length - scnassets.Length); + if (newLinkLength > 0 && newLinkLength < link.Length) { + link = link.Substring (0, newLinkLength); + scnassetsItem.SetMetadata ("Link", link); + } + } + var assetMetadata = asset.GetMetadata ("DefiningProjectFullPath"); if (assetMetadata != scnassetsItem.GetMetadata ("DefiningProjectFullPath")) { // xbuild doesn't set this, so we'll do it diff --git a/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/scene.scn b/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/scene.scn new file mode 100644 index 000000000000..5b0d1c58aa14 Binary files /dev/null and b/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/scene.scn differ diff --git a/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/texture.png b/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/texture.png new file mode 100644 index 000000000000..ba392589b700 Binary files /dev/null and b/tests/dotnet/AppWithResources/DirWithResources/linkedArt.scnassets/texture.png differ diff --git a/tests/dotnet/AppWithResources/shared.csproj b/tests/dotnet/AppWithResources/shared.csproj index 4603f2c62982..9216585234d3 100644 --- a/tests/dotnet/AppWithResources/shared.csproj +++ b/tests/dotnet/AppWithResources/shared.csproj @@ -19,6 +19,8 @@ + +