Add ´build_beta.bat´ + try to clean up packages

This commit is contained in:
Nikolaj Olsson 2020-12-01 22:04:27 +01:00
parent 5fd9818c81
commit f5f226bfcb
15 changed files with 214 additions and 33 deletions

1
.gitignore vendored
View File

@ -43,6 +43,5 @@ SubtitleEditBeta
/src/ui/packages
/src/ui/ILRepack*
/src/ui/NHunspell*
/build_beta.bat
/TestResults
/packages

View File

@ -99,14 +99,11 @@ IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
IF /I "%BUILDTYPE%" == "Clean" GOTO EndSuccessful
dir
PUSHD "src/ui"
dir
ECHO.
ECHO Merging assemblies with ILRepack...
FOR /D %%A IN (packages\ILRepack.*) DO (SET "ILREPACKDIR=%%A")
FOR /D %%A IN (..\..\packages\ILRepack.*) DO (SET "ILREPACKDIR=%%A")
ECHO.
dir
echo ILREPACKDIR
echo %ILREPACKDIR%
echo ILREPACKDIR done

204
build_beta.bat Normal file
View File

@ -0,0 +1,204 @@
@ECHO OFF
SETLOCAL
CD /D %~dp0
REM Check for the help switches
IF /I "%~1" == "help" GOTO ShowHelp
IF /I "%~1" == "/help" GOTO ShowHelp
IF /I "%~1" == "-help" GOTO ShowHelp
IF /I "%~1" == "--help" GOTO ShowHelp
IF /I "%~1" == "/?" GOTO ShowHelp
IF /I "%~1" == "-?" GOTO ShowHelp
ECHO Getting latest changes...
git pull
ECHO.
ECHO Starting compilation...
MD SubtitleEditBeta
DEL SubtitleEditBeta\SubtitleEditBeta.zip
REM Set environment variables for Visual Studio command line if necessary
:SetVsCmdLineEnv
IF DEFINED VSINSTALLDIR IF EXIST "%VSINSTALLDIR%" (
IF DEFINED VisualStudioVersion IF "%VisualStudioVersion%" GEQ "15.0" GOTO SetBuildType
ECHO.
ECHO Developer Command Prompt for Visual Studio 2017 or later required!
GOTO EndWithError
)
FOR /F "usebackq delims=" %%A IN (`vswhere -latest -requires Microsoft.Component.MSBuild -property installationPath`) DO (
SET "VSINSTALLDIR=%%A\"
)
IF DEFINED VSINSTALLDIR IF EXIST "%VSINSTALLDIR%" (
ECHO Visual Studio installation path: "%VSINSTALLDIR%"
) ELSE (
ECHO.
ECHO Cannot find Visual Studio.
GOTO EndWithError
)
SET "VsDevCmd_bat=%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat"
IF NOT EXIST "%VsDevCmd_bat%" (
FOR /F "usebackq delims=" %%A IN (`DIR /B /S "%VSINSTALLDIR%\VsDevCmd.bat"`) DO (
SET "VsDevCmd_bat=%%A"
)
)
IF EXIST "%VsDevCmd_bat%" (
ECHO Visual Studio VsDevCmd.bat path: "%VsDevCmd_bat%"
) ELSE (
ECHO.
ECHO Cannot find Visual Studio VsDevCmd batch file.
GOTO EndWithError
)
ECHO.
CALL "%VsDevCmd_bat%" -startdir=none
GOTO SetVsCmdLineEnv
:SetBuildType
IF "%~1" == "" (
SET "BUILDTYPE=Build"
) ELSE (
IF /I "%~1" == "Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "/Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "-Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "--Build" SET "BUILDTYPE=Build" & GOTO START
IF /I "%~1" == "Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "/Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "-Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "--Clean" SET "BUILDTYPE=Clean" & GOTO START
IF /I "%~1" == "Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "/Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "-Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
IF /I "%~1" == "--Rebuild" SET "BUILDTYPE=Rebuild" & GOTO START
ECHO.
ECHO Unsupported commandline switch!
GOTO EndWithError
)
:START
TITLE %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU...
ECHO.
ECHO %BUILDTYPE%ing Subtitle Edit - Release^|Any CPU...
DEL /F /Q SubtitleEdit-*-Setup.exe SubtitleEdit-*.zip 2>NUL
ECHO.
ECHO Visual Studio installation path: "%VSINSTALLDIR%"
IF EXIST "%VSINSTALLDIR%MSBuild\15.0\Bin\MSBuild.exe" (
SET "MSBUILD=%VSINSTALLDIR%MSBuild\15.0\Bin\MSBuild.exe"
) ELSE (
IF EXIST "%VSINSTALLDIR%MSBuild\Current\Bin\MSBuild.exe" (
SET "MSBUILD=%VSINSTALLDIR%MSBuild\Current\Bin\MSBuild.exe"
) ELSE (
ECHO Cannot find Visual Studio 2019.
GOTO EndWithError
))
"%MSBUILD%" SubtitleEdit.sln /r /t:%BUILDTYPE% /p:Configuration=Release /p:Platform="Any CPU"^
/maxcpucount /consoleloggerparameters:DisableMPLogging;Summary;Verbosity=minimal
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
IF /I "%BUILDTYPE%" == "Clean" GOTO EndSuccessful
PUSHD "src/ui"
ECHO.
ECHO Merging assemblies with ILRepack...
FOR /D %%A IN (..\..\packages\ILRepack.*) DO (SET "ILREPACKDIR=%%A")
ECHO.
echo ILREPACKDIR
echo %ILREPACKDIR%
echo ILREPACKDIR done
"%ILREPACKDIR%\tools\ILRepack.exe" /parallel /internalize /targetplatform:v4 /out:"bin\Release\SubtitleEdit.exe" "bin\Release\SubtitleEdit.exe"^
"bin\Release\libse.dll" "bin\Release\zlib.net.dll" "bin\Release\NHunspell.dll" "bin\Release\UtfUnknown.dll" "DLLs\Interop.QuartzTypeLib.dll"^
"bin\Release\Newtonsoft.Json.dll" "bin\Release\System.Net.Http.Extensions.dll" "bin\Release\System.Net.Http.Primitives.dll"
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
POPD
CALL :SubDetectSevenzipPath
IF DEFINED SEVENZIP IF EXIST "%SEVENZIP%" (
CALL :SubZipFile
)
:EndSuccessful
TITLE %BUILDTYPE%ing Subtitle Edit finished!
GOTO END
:EndWithError
TITLE Compiling Subtitle Edit [ERROR]
ECHO.
ECHO.
ECHO ** ERROR: Build failed and aborted! **
GOTO END
:ShowHelp
TITLE %~nx0 %1
ECHO.
ECHO.
ECHO Usage: %~nx0 [Clean^|Build^|Rebuild]
ECHO.
ECHO Notes: You can also prefix the commands with "-", "--" or "/".
ECHO The arguments are not case sensitive.
ECHO.
ECHO Executing %~nx0 without any arguments is equivalent to "%~nx0 build".
:END
ECHO.
ECHO.
ENDLOCAL
PAUSE
EXIT /B
:SubZipFile
TITLE Creating ZIP archive with 7-Zip...
ECHO.
ECHO Creating ZIP archive with 7-Zip...
PUSHD "src\ui\bin\Release"
IF EXIST "temp_zip" RD /S /Q "temp_zip"
IF NOT EXIST "temp_zip" MD "temp_zip"
IF NOT EXIST "temp_zip\Languages" MD "temp_zip\Languages"
IF NOT EXIST "temp_zip\Dictionaries" MD "temp_zip\Dictionaries"
IF NOT EXIST "temp_zip\Ocr" MD "temp_zip\Ocr"
IF NOT EXIST "temp_zip\Tesseract302" MD "temp_zip\Tesseract302"
ECHO.
COPY /Y /V "..\..\..\..\LICENSE.txt" "temp_zip\"
COPY /Y /V "..\..\..\..\Changelog.txt" "temp_zip\"
COPY /Y /V "Hunspellx86.dll" "temp_zip\"
COPY /Y /V "Hunspellx64.dll" "temp_zip\"
COPY /Y /V "SubtitleEdit.exe" "temp_zip\"
COPY /Y /V "Languages\*.xml" "temp_zip\Languages\"
COPY /Y /V "..\..\..\..\Dictionaries\*.*" "temp_zip\Dictionaries\"
COPY /Y /V "..\..\..\..\Ocr\*.*" "temp_zip\Ocr\"
XCOPY /Y /V "..\..\..\..\Tesseract302\*.*" "temp_zip\Tesseract302\" /S
PUSHD "temp_zip"
START "" /B /WAIT "%SEVENZIP%" a -tzip -mx=9 "SubtitleEditBeta.zip" * >NUL
IF %ERRORLEVEL% NEQ 0 GOTO EndWithError
ECHO.
ECHO ZIP archive created successfully!
MOVE /Y "SubtitleEditBeta.zip" "..\..\..\..\..\SubtitleEditBeta" >NUL
POPD
IF EXIST "temp_zip" RD /S /Q "temp_zip"
POPD
EXIT /B
:SubDetectSevenzipPath
FOR %%G IN (7z.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
FOR %%G IN (7za.exe) DO (SET "SEVENZIP_PATH=%%~$PATH:G")
IF EXIST "%SEVENZIP_PATH%" (SET "SEVENZIP=%SEVENZIP_PATH%" & EXIT /B)
FOR /F "tokens=2*" %%A IN (
'REG QUERY "HKLM\SOFTWARE\7-Zip" /v "Path" 2^>NUL ^|^|
REG QUERY "HKLM\SOFTWARE\Wow6432Node\7-Zip" /v "Path" 2^>NUL') DO IF "%%A" == "REG_SZ" SET "SEVENZIP=%%B\7z.exe"
EXIT /B

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('packages\ILRepack.2.0.18\build\ILRepack.props')" />
<Import Project="..\..\packages\ILRepack.2.0.18\build\ILRepack.props" Condition="Exists('..\..packages\ILRepack.2.0.18\build\ILRepack.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<AppDesignerFolder>Properties</AppDesignerFolder>
@ -58,11 +58,11 @@
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>$(SolutionDir)\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NHunspell, Version=1.2.5554.16953, Culture=neutral, PublicKeyToken=1ac793ea843b4366, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>packages\NHunspell.1.2.5554.16953\lib\net\NHunspell.dll</HintPath>
<HintPath>$(SolutionDir)\NHunspell.1.2.5554.16953\lib\net\NHunspell.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -70,10 +70,10 @@
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
<HintPath>$(SolutionDir)\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<HintPath>$(SolutionDir)\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web.Services" />
@ -1918,7 +1918,7 @@
<Output TaskParameter="Result" PropertyName="HunspellVersion" />
</XmlPeek>
<PropertyGroup>
<HunspellDir>$(SolutionDir)\src\ui\packages\NHunspell.$(HunspellVersion)\content\</HunspellDir>
<HunspellDir>$(SolutionDir)\packages\NHunspell.$(HunspellVersion)\content\</HunspellDir>
</PropertyGroup>
<Copy SourceFiles="@(HunspellAssemblies -> '$(HunspellDir)%(Identity)')" DestinationFolder="$(OutputPath)" SkipUnchangedFiles="True" />
<Exec Command="%22$(SolutionDir)\build_helpers.bat%22 rev %22$(ConfigurationName)%22" />
@ -1926,10 +1926,10 @@
<Target Name="BeforeClean">
<Delete Files="@(HunspellAssemblies -> '$(OutputPath)%(Identity)')" />
</Target>
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Import Project="$(SolutionDir)\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
<Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('$(SolutionDir)\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Binary file not shown.

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ILRepack>$(MSBuildThisFileDirectory)..\tools\ILRepack.exe</ILRepack>
</PropertyGroup>
</Project>

View File

@ -1,13 +0,0 @@
param($installPath, $toolsPath, $package, $project)
# Hunspellx86.dll (32 Bit Windows)
$hunspellx86Dll = $project.ProjectItems.Item("Hunspellx86.dll")
$hunspellx86Dll.Properties.Item("BuildAction").Value = 0 # BuildAction = None
$hunspellx86Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # CopyToOutputDirectory = Copy if newer
# Hunspellx64.dll (64 Bit Windows)
$hunspellx64Dll = $project.ProjectItems.Item("Hunspellx64.dll")
$hunspellx64Dll.Properties.Item("BuildAction").Value = 0 # BuildAction = None
$hunspellx64Dll.Properties.Item("CopyToOutputDirectory").Value = 2 # CopyToOutputDirectory = Copy if newer