Преглед на файлове

Add QDS scripts - final

Dalibor Votruba преди 7 години
родител
ревизия
37939651db

+ 5 - 0
QConsole/@Scripts/001_settings.ps1

@@ -33,6 +33,7 @@ $projectOutputDir           = $projectDir + "\@Release"
 
 # Tools & system paths
 $pathMsBuild                = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild.exe"
+$path7zip                   = "$projectDir\..\Assets\7z.exe"
 
 # Builds
 $buildCfgDebug              = "Debug"
@@ -42,8 +43,12 @@ $buildTrgClean              = "Clean"
 $buildTrgRebuild            = "Rebuild"
 $buildTrgPublish            = "Publish"
 
+# Zip
+$zipNamePrefix              = "ProjectZip"
+
 # Aliases
 Set-Alias msbuild $pathMsBuild
+Set-Alias 7zip $path7zip
 
 Write-Host "Settings was loaded succesfully." -ForegroundColor DarkGray
 $settingsWasLoaded = $true

+ 43 - 1
QConsole/@Scripts/002_library.ps1

@@ -4,7 +4,7 @@
 #**  Description: PowerShell script library of elementary functions to   **#
 #**                work with QDS                                         **#
 #**  Version: 1.0.                                                       **#
-#**  Updated: 24.7.2019                                                  **# 
+#**  Updated: 29.7.2019                                                  **# 
 #**************************************************************************#
 
 # Rebuilds solution file, may calls CleanSolution
@@ -76,6 +76,48 @@ Function CleanSolution
     #/p:SolutionDir=$location /m
 }
 
+# Publish solution file, may calls CleanSolution
+Function PublishSolution
+{
+    param(
+        # Solution file name with full path
+        [string] $solutionFileName,
+        # Build configuration Debug / Release
+        [string] $configurationName = $buildCfgDebug,
+        # Defines alternative output directory. If not defined, use default output locations depends on configuration
+        [string] $alternativeOutputDirectory,
+        # Defines if Clean will be called before build
+        [bool] $cleanBeforeBuild = $false,
+        # Defines if only show calling commands instead of executes them (just for debugging)
+        [bool] $simulate = $false
+    )
+
+    $fileExists = Test-Path($solutionFileName)
+    if ($fileExists -eq $false){
+        Write-Error("Solution file '{0}' doesn't exists." -f $solutionFileName)
+        Break
+    }
+
+    if (!$alternativeOutputDirectory){
+        $alternativeOutputDirectory = ""
+    }
+    else{
+        $alternativeOutputDirectory = " /p:PublishDestination='{0}'" -f $alternativeOutputDirectory
+    }
+
+    Write-Host("**** BEGIN *** BUILDS SOLUTION/PROJECT : {0} ****" -f $solutionFileName) -ForegroundColor Yellow
+    if ($cleanBeforeBuild -eq $true){
+        CleanSolution $solutionFileName $configurationName $simulate
+    }
+    if ($simulate -eq $true){
+        Write-Host "msbuild $solutionFileName /t:$buildTrgPublish /p:VisualStudioVersion=15.0 /p:Configuration=$configurationName /m /clp:Summary /clp:ShowTimestamp $alternativeOutputDirectory"  -ForegroundColor Cyan
+    } else{
+        msbuild $solutionFileName /t:$buildTrgPublish /p:VisualStudioVersion=15.0 /p:Configuration=$configurationName /m /clp:Summary /clp:ShowTimestamp $alternativeOutputDirectory
+    }    
+    Write-Host("**** END *** BUILDS SOLUTION/PROJECT : {0} ****" -f $solutionFileName) -ForegroundColor Yellow
+}
+
+
 # Returns list of project from solution file. Returns objects with properties: Name, File, Guid, Directory
 Function GetProjectsFromSolution
 {

+ 46 - 0
QConsole/@Scripts/202_publish_output.ps1

@@ -0,0 +1,46 @@
+#**************************************************************************#
+#**  QUADARAX DEPLOYMENT SCRIPTS                                         **#
+#**  File: 202_publish_output.ps1                                        **#
+#**  Description: PowerShell script library to publish current solution  **#
+#**               to output directory                                    **#
+#**  Version: 1.0.                                                       **#
+#**  Updated: 29.7.2019                                                  **# 
+#**************************************************************************#
+param(
+        # Solution file name with full path. If not defined use global solution
+        [string] $solutionFile,
+        # Build configuration Debug / Release. If not defined use Debug
+        [string] $configurationName,
+        # Defines if Clean will be called before build. If not defined use $false
+        [bool] $cleanBeforeBuild        
+)
+. ./000_bootstrap.ps1
+
+
+# Validate inputs
+if (!$solutionFile) { $solutionFile = $solutionName}
+if (!$configurationName) { $configurationName = $buildCfgDebug}
+if (!$cleanBeforeBuild) { $cleanBeforeBuild = $false}
+if ($configurationName -eq $buildCfgAll){
+    Write-Host ("Configuration name {0} for this script is not allowed. Use only {1},{2}." -f $buildCfgAll, $buildCfgDebug, $buildCfgRelease) -ForegroundColor Red
+    Break
+}
+
+# Script body section
+
+# May create output directory
+New-Item -ItemType Directory -Force -Path $projectOutputDir
+
+Write-Host "*** PUBLISH - START ***" -ForegroundColor Green
+$slnFullPath = ("{0}\{1}" -f $projectDir, $solutionFile)
+Write-Host ("Solution name: {0}" -f $slnFullPath) -ForegroundColor Yellow
+Write-host ("Configuration: {0}" -f $configurationName) -ForegroundColor Yellow
+Write-host ("Output directory: {0}" -f $projectOutputDir) -ForegroundColor Yellow
+
+if ($cleanBeforeBuild -eq $true){
+    Write-Host "Cleaning output directory" -ForegroundColor White
+    Remove-Item -Path "$projectOutputDir\*" -Recurse
+}
+
+PublishSolution -solutionFileName $slnFullPath -configurationName $configurationName -cleanBeforeBuild $cleanBeforeBuild
+Write-Host "*** PUBLISH - END ***" -ForegroundColor Green

+ 25 - 0
QConsole/@Scripts/300_cleanup.ps1

@@ -0,0 +1,25 @@
+#**************************************************************************#
+#**  QUADARAX DEPLOYMENT SCRIPTS                                         **#
+#**  File: 300_cleanup.ps1                                               **#
+#**  Description: PowerShell script library to cleanup all projects      **#
+#**               folder to minimal size                                 **#
+#**  Version: 1.0.                                                       **#
+#**  Updated: 29.7.2019                                                  **# 
+#**************************************************************************#
+. ./000_bootstrap.ps1
+
+Write-Host "*** CLEANINGUP - START ***" -ForegroundColor Green
+$removeRoot = "$projectDir\"
+$i = 0
+Get-ChildItem $removeRoot -include bin,obj,*.user,packages,TestResults,resharper*  -Recurse | foreach ($_) { 
+    Remove-Item $_.fullname -Force -Recurse 
+    Write-Host ("Deleted file {0}" -f $_.fullname) -ForegroundColor White
+    $i = $i + 1
+}
+Get-ChildItem $removeRoot -include .vs -Recurse -Hidden | foreach ($_) { 
+    Remove-Item $_.fullname -Force -Recurse 
+    Write-Host ("Deleted file {0}" -f $_.fullname) -ForegroundColor White
+    $i = $i + 1
+}
+Write-Host ("Deleted {0} files" -f $i) -ForegroundColor Yellow
+Write-Host "*** CLEANINGUP - END ***" -ForegroundColor Green

+ 25 - 0
QConsole/@Scripts/301_zip.ps1

@@ -0,0 +1,25 @@
+#**************************************************************************#
+#**  QUADARAX DEPLOYMENT SCRIPTS                                         **#
+#**  File: 301_zip.ps1                                                   **#
+#**  Description: PowerShell script library to zip minimal version       **#
+#**  Version: 1.0.                                                       **#
+#**  Updated: 29.7.2019                                                  **# 
+#**************************************************************************#
+param(
+    # Defines alternative zip file. If not defined uses automatic name
+    [string] $alternativeZipFileName
+)
+
+. ./000_bootstrap.ps1
+# Validate inputs
+if (!$alternativeZipFileName) { $alternativeZipFileName = "$zipNamePrefix$(get-date -f yyyy-MM-dd).7z"}
+
+Write-Host ("Zipping directory {0}" -f $projectDir) -ForegroundColor Yellow
+Write-Host ("Zipping to archive {0}" -f $alternativeZipFileName) -ForegroundColor Yellow
+
+Remove-Item $alternativeZipFileName -Force
+
+Write-Host "*** ZIPPING - START ***" -ForegroundColor Green
+# -xr!.vs  -xr!*.user -xr!packages -xr!TestResults -xr!resharper* 
+7zip a -tzip $alternativeZipFileName $projectDir\ -mx0 -xr!bin -xr!obj -xr!packages -xr!TestResults -xr!resharper* 
+Write-Host "*** ZIPPING - END ***" -ForegroundColor Green

+ 0 - 6
QConsole/@Scripts/aaa.txt

@@ -1,6 +0,0 @@
-000_bootstrap.ps1
-001_settings.ps1
-002_library.ps1
-100_rebuild.ps1
-aaa.txt
-readme.txt

+ 5 - 3
QConsole/@Scripts/readme.txt

@@ -3,6 +3,8 @@
 002_library.ps1										-	Deployment functions library
 100_rebuild.ps1										-	MSBuild Rebuild all
 101_clean.ps1										-	MSBuild Clean all
-200_rebuild_output									-	Rebuild all to output directory
-201_clean_output									-	Clean all in output directory
-203_publish_output									-	Publish all to output directory
+200_rebuild_output.ps1								-	Rebuild all to output directory
+201_clean_output.ps1								-	Clean all in output directory
+202_publish_output.ps1								-	Publish all to output directory
+300_cleanup.ps1                                     -   Cleanup all solution directory
+301_zip.ps1                                         -   Zip all minimal solution directory