diff --git a/src/_deployment/azurepipeline/azure-pipelines.yml b/src/_deployment/azurepipeline/azure-pipelines.yml new file mode 100644 index 00000000..2b246795 --- /dev/null +++ b/src/_deployment/azurepipeline/azure-pipelines.yml @@ -0,0 +1,27 @@ +name: $(VersionMajor).$(VersionMinor).$(VersionBuild).$(VersionRevision) + +trigger: + branches: + include: + - source + +steps: +- task: NuGetToolInstaller@1 + displayName: 'Install NuGet 4.4.1' + inputs: + versionSpec: '4.4.1' + +- task: NuGetCommand@2 + displayName: 'NuGet restore' + inputs: + restoreSolution: '$(SolutionFile)' + +- task: PowerShell@2 + displayName: 'Apply Semantic Versioning to Assemblies' + inputs: + targetType: filePath + filePath: '.\src\_deployment\scripts\ApplySemanticVersioningToAssemblies.ps1' + pwsh: true + env: + BUILD_APPLICATION_NAME: $(ApplicationName) + BUILD_SOURCE_PATH: $(Build.SourcesDirectory)\src diff --git a/src/_deployment/scripts/ApplySemanticVersioningToAssemblies.ps1 b/src/_deployment/scripts/ApplySemanticVersioningToAssemblies.ps1 new file mode 100644 index 00000000..3484e091 --- /dev/null +++ b/src/_deployment/scripts/ApplySemanticVersioningToAssemblies.ps1 @@ -0,0 +1,116 @@ +Param ( + [string]$applicationName, + [string]$pathToSearch, + [string]$buildNumber, + [regex]$pattern = "\d+\.\d+\.\d+\.\d+", + [string]$patternSplitCharacters = ".", + [int]$patternExpectedVersionNumbers = 4, + [int]$versionNumbersInVersion = 4, + [string]$searchFilter = "AssemblyInfo.*", + [string]$debugMode = 'false' +) + +# Declare functions +function Replace-Version($content, $version, $attribute) +{ + $exitFunction = $false + $content | %{ + if ($_ -match 'exclude from semantic versioning') + { + Write-Host " * Skipping $attribute due to exclude" + $exitFunction = $true + } + if ($_ -match 'include semantic versioning' -and $_ -notmatch "include semantic versioning - $applicationName") + { + Write-Host " * Skipping $attribute due to include not matching" + $exitFunction = $true + } + } + + if ($exitFunction) + { + return $content + } + + $versionAttribute = "[assembly: $attribute(""$version"")]" + $pattern = "\[assembly: $attribute\("".*""\)\]" + $versionReplaced = $false + + $content = $content | %{ + if ($_ -match $pattern) + { + $versionReplaced = $true + $_ = $_ -replace [regex]::Escape($Matches[0]),$versionAttribute + Write-Host " * Replaced $($Matches[0]) with $versionAttribute" + } + $_ + } + + if (-not $versionReplaced) + { + $content += [Environment]::NewLine + $versionAttribute + Write-Host " * Added $versionAttribute to end of content" + } + + return $content +} + +function Get-VersionString($numberOfVersions, $extractedBuildNumbers) +{ + return [string]::Join(".",($extractedBuildNumbers | select -First ($numberOfVersions))) +} + +$ErrorActionPreference = "Stop" + +if ($debugMode -eq "true") +{ + Write-Host "##[section]Starting: DEBUG INFORMATION" + + Write-Host "##[debug]applicationName = $applicationName" + Write-Host "##[debug]pathToSearch = $pathToSearch" + Write-Host "##[debug]versionFile = $versionFile" + Write-Host "##[debug]pattern = $pattern" + Write-Host "##[debug]patternSplitCharacters = $patternSplitCharacters" + Write-Host "##[debug]patternExpectedVersionNumbers = $patternExpectedVersionNumbers" + Write-Host "##[debug]versionNumbersInVersion = $versionNumbersInVersion" + Write-Host "##[debug]searchFilter = $searchFilter" + + Write-Host "##[section]Finishing: DEBUG INFORMATION" + Write-Host "" +} + +if ($buildNumber -match $pattern -ne $true) +{ + Write-Host "Could not extract a version from [$buildNumber] using pattern [$pattern]" + exit 2 +} + +# Set version variables +$extractedBuildNumbers = @($Matches[0].Split(([char[]]$patternSplitCharacters))) +if ($extractedBuildNumbers.Length -ne $patternExpectedVersionNumbers) +{ + Write-Host "The extracted build number $($Matches[0]) does not contain the expected $patternExpectedVersionNumbers elements" + exit 2 +} + +$version = Get-VersionString -numberOfVersions $versionNumbersInVersion -extractedBuildNumbers $extractedBuildNumbers +$fileVersion = Get-VersionString -numberOfVersions $versionNumbersInVersion -extractedBuildNumbers $extractedBuildNumbers +Write-Host "Using version $version and file version $fileVersion" + +# iterate the search path (and sub directories) looking for files that match the search filter +Get-ChildItem -Path $pathToSearch -Filter $searchFilter -Recurse | %{ + Write-Host " -> Checking $($_.FullName)" + + # remove the read-only bit on the file + #sp $_.FullName IsReadOnly $false + Set-ItemProperty $_.FullName -name IsReadOnly -value $false + + # run the regex replace + $content = Get-Content $_.FullName + $content = Replace-Version -content $content -version $version -attribute 'AssemblyVersion' + $content = Replace-Version -content $content -version $fileVersion -attribute 'AssemblyFileVersion' + $content | Set-Content $_.FullName -Encoding UTF8 +} + +Write-Host "Done" +exit 0 diff --git a/src/_deployment/scripts/ArkServerManager.iss b/src/_deployment/scripts/ArkServerManager.iss new file mode 100644 index 00000000..dde895a3 --- /dev/null +++ b/src/_deployment/scripts/ArkServerManager.iss @@ -0,0 +1,53 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! +;#include "D:\GitHub\ServerManagers\src\ARKServerManager\Installer.txt" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{8CF4109C-917A-4F81-A189-164E4DF22C7C} +AppName=Ark Server Manager +AppVersion={#AppVer} +AppPublisher=Bletch1971 +AppPublisherURL=http://arkservermanager.freeforums.net/ +AppSupportURL=http://arkservermanager.freeforums.net/board/3/tech-support-bug-reports +AppUpdatesURL=http://arkservermanager.freeforums.net/thread/5193/downloads +DefaultDirName={pf}\ArkServerManager +DisableProgramGroupPage=yes +SetupIconFile={#RootPath}\favicon.ico +VersionInfoVersion={#AppVerFull} + +ArchitecturesAllowed=x86 x64 ia64 +ArchitecturesInstallIn64BitMode=x64 ia64 + +Compression=lzma +SolidCompression=yes + +UninstallDisplayName=Ark Server Manager +UninstallDisplayIcon={app}\ARK Server Manager.exe + +SourceDir={#RootPath}\Application Files\ARK Server Manager_{#AppVerPath} +OutputDir={#RootPath}\ +OutputBaseFilename=ArkServerManager_{#AppVer} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 + +[Files] +Source: "ARK Server Manager.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{commonprograms}\Ark Server Manager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager" +Name: "{commondesktop}\Ark Server Manager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Ark Server Manager"; Filename: "{app}\ARK Server Manager.exe"; Comment: "Start Ark Server Manager"; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\ARK Server Manager.exe"; Description: "{cm:LaunchProgram,Ark Server Manager}"; Flags: nowait postinstall skipifsilent unchecked + diff --git a/src/_deployment/scripts/ConanServerManager.iss b/src/_deployment/scripts/ConanServerManager.iss new file mode 100644 index 00000000..3f04bbfb --- /dev/null +++ b/src/_deployment/scripts/ConanServerManager.iss @@ -0,0 +1,53 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! +;#include "D:\GitHub\ServerManagers\src\ConanServerManager\Installer.txt" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{783D6AFF-E78C-44D5-B9E2-764D7C62C7FD} +AppName=Conan Server Manager +AppVersion={#AppVer} +AppPublisher=Bletch1971 +AppPublisherURL=http://servermanagers.freeforums.net +AppSupportURL=http://servermanagers.freeforums.net/board/39/tech-support-bug-reports +AppUpdatesURL=http://servermanagers.freeforums.net/thread/36/downloads +DefaultDirName={pf}\ConanServerManager +DisableProgramGroupPage=yes +SetupIconFile={#RootPath}\favicon.ico +VersionInfoVersion={#AppVerFull} + +ArchitecturesAllowed=x86 x64 ia64 +ArchitecturesInstallIn64BitMode=x64 ia64 + +Compression=lzma +SolidCompression=yes + +UninstallDisplayName=Conan Server Manager +UninstallDisplayIcon={app}\ConanServerManager.exe + +SourceDir={#RootPath}\Application Files\ConanServerManager_{#AppVerPath} +OutputDir={#RootPath}\ +OutputBaseFilename=ConanServerManager_{#AppVer} + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked +Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 + +[Files] +Source: "ConanServerManager.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{commonprograms}\Conan Server Manager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager" +Name: "{commondesktop}\Conan Server Manager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager"; Tasks: desktopicon +Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Conan Server Manager"; Filename: "{app}\ConanServerManager.exe"; Comment: "Start Conan Server Manager"; Tasks: quicklaunchicon + +[Run] +Filename: "{app}\ConanServerManager.exe"; Description: "{cm:LaunchProgram,Conan Server Manager}"; Flags: nowait postinstall skipifsilent unchecked +