@echo off
setlocal

rem --- resolve absolute path of DLL ---
set "dll=..\bin\Debug\net8.0-windows\VisionBuilder.UI.Windows.Duo.dll"
for %%I in ("%dll%") do set "dll=%%~fI"

rem --- get version from DLL ---
for /f "tokens=2 delims==" %%v in ('wmic datafile where "name='%dll:\=\\%'" get Version /value ^| find "="') do set "ver=%%v"

rem --- cut off last part (keep only major.minor.build) ---
for /f "tokens=1-3 delims=." %%a in ("%ver%") do set "ver=%%a.%%b.%%c"

echo Found version: %ver%

rem --- make sure output dir exists ---
if not exist Output mkdir Output

rem --- build 7z-SFX ---
set "src=..\bin\Debug\net8.0-windows"
set "out=Output\UNO%ver%.exe"

7z a -sfx "%out%" "%src%\*"

echo Done: %out%
endlocal