#!/usr/bin/env bash

set -eo pipefail
source debian/tests/.tests.rc.d/init.sh

ChangeToAutopkgtestTmpFolder

LogInfo "Setup project file structure"
dotnet new sln --name Project

dotnet new console --language C# --name HelloCsharp
dotnet new classlib --language C# --name CsharpLibrary
dotnet add HelloCsharp/HelloCsharp.csproj reference CsharpLibrary/CsharpLibrary.csproj
dotnet sln Project.sln add HelloCsharp/HelloCsharp.csproj

dotnet new console --language F# --name HelloFsharp
dotnet sln add HelloFsharp/HelloFsharp.fsproj

dotnet new console --language VB --name HelloVisualBasic
dotnet sln add HelloVisualBasic/HelloVisualBasic.vbproj

LogInfo "Showing File structure"
echo "$ ls -lR"
ls -lR

LogInfo "Build Solution"
dotnet build Project.sln

LogInfo "Checking if build binaries exist"

test -e "CsharpLibrary/bin/Debug/$DOTNET_VERSION_NAME/CsharpLibrary.dll"
test -e "HelloVisualBasic/bin/Debug/$DOTNET_VERSION_NAME/HelloVisualBasic.dll"
test -e "HelloCsharp/bin/Debug/$DOTNET_VERSION_NAME/HelloCsharp.dll"
test -e "HelloFsharp/bin/Debug/$DOTNET_VERSION_NAME/HelloFsharp.dll"

LogInfo "Showing File structure again (after build)"
echo "$ ls -lR"
ls -lR

LogInfo "Test Ok!"
