setlocal

set IDE_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE
set BUILD_PATH=C:\Windows\Microsoft.NET\Framework64\v4.0.30319
set BUILD_TYPE=%1
set CPU_TYPE=Any CPU

if "%1"=="" set BUILD_TYPE=Release

"%IDE_PATH%\devenv" /build "%BUILD_TYPE%" ..\Windows\FooEditEngine.sln
if errorlevel 1 goto end
"%IDE_PATH%\devenv" /build "%BUILD_TYPE%" ..\WPF\FooEditEngine.sln
if errorlevel 1 goto end
"%IDE_PATH%\devenv" /build "%BUILD_TYPE%|%CPU_TYPE%" ..\Metro\Test.sln
if errorlevel 1 goto end
"%IDE_PATH%\devenv" /build "%BUILD_TYPE%|%CPU_TYPE%" ..\UWP\FooEditEngine.UWP.sln
if errorlevel 1 goto end
"%BUILD_PATH%\MSBuild.exe" /p:Configuration=Release ..\Help\fooeditengine_api.shfbproj
if errorlevel 1 echo "building help file is failed"

:copy_dist
md dist
copy ..\Help\Help\Documentation.chm dist
md dist\winform
copy ..\Windows\FooEditEngine\bin\%BUILD_TYPE%\*.dll dist\winform
copy ..\Windows\FooEditEngine\bin\%BUILD_TYPE%\*.pdb dist\winform
md dist\wpf
copy ..\WPF\FooEditEngine\bin\%BUILD_TYPE%\*.dll dist\wpf
copy ..\WPF\FooEditEngine\bin\%BUILD_TYPE%\*.pdb dist\wpf
md dist\uwp
copy ..\UWP\FooEditEngine.UWP\bin\%BUILD_TYPE%\*.dll dist\uwp
copy ..\UWP\FooEditEngine.UWP\bin\%BUILD_TYPE%\*.pdb dist\uwp
copy ..\UWP\FooEditEngine.UWP\bin\%BUILD_TYPE%\*.pri dist\uwp
md dist\uwp\FooEditEngine.UWP\Themes
copy ..\UWP\FooEditEngine.UWP\bin\%BUILD_TYPE%\*.xr.xml dist\uwp\FooEditEngine.UWP
copy ..\UWP\FooEditEngine.UWP\bin\%BUILD_TYPE%\Themes\*.* dist\uwp\FooEditEngine.UWP\Themes

:end
endlocal
pause
