diff --git a/src/oryx/install.sh b/src/oryx/install.sh index cf67db6b1..06070027f 100755 --- a/src/oryx/install.sh +++ b/src/oryx/install.sh @@ -179,6 +179,39 @@ mkdir -p ${ORYX} git clone --depth=1 https://github.com/microsoft/Oryx $GIT_ORYX +# Patch MemorySourceRepo to implement ISourceRepo.GetFileSize method +# This fixes a breaking interface change introduced in upstream Oryx +# See: https://github.com/microsoft/Oryx/commit/21c559437d69cb43fd9b34f01f68c43ea4bce318 +MEMORY_SOURCE_REPO_FILE="$GIT_ORYX/tests/Detector.Tests/MemorySourceRepo.cs" +if [ -f "$MEMORY_SOURCE_REPO_FILE" ]; then + # Check if GetFileSize is already implemented + if ! grep -q "GetFileSize" "$MEMORY_SOURCE_REPO_FILE"; then + echo "Patching MemorySourceRepo to add GetFileSize implementation..." + # Add GetFileSize implementation before the GetGitCommitId method + sed -i '/public string GetGitCommitId()/i\ + public long? GetFileSize(params string[] paths)\ + {\ + var path = Path.Combine(paths);\ + if (!pathsToFiles.ContainsKey(path))\ + {\ + return null;\ + }\ + var content = pathsToFiles[path];\ + return content?.Length;\ + }\ +' "$MEMORY_SOURCE_REPO_FILE" + + # Verify the patch was applied + if grep -q "GetFileSize" "$MEMORY_SOURCE_REPO_FILE"; then + echo "Successfully patched MemorySourceRepo" + else + echo "Warning: Failed to patch MemorySourceRepo - build may fail" + fi + else + echo "MemorySourceRepo already has GetFileSize implementation, skipping patch" + fi +fi + if [[ "${PINNED_SDK_VERSION}" != "" ]]; then cd $GIT_ORYX dotnet new globaljson --sdk-version ${PINNED_SDK_VERSION}