diff --git a/ModernKeePass.sln b/ModernKeePass.sln index 7c9589a..376d44d 100644 --- a/ModernKeePass.sln +++ b/ModernKeePass.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib", "ModernK EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModernKeePassLib.Test", "ModernKeePassLib.Test\ModernKeePassLib.Test.csproj", "{0A4279CF-2A67-4868-9906-052E50C25F3B}" EndProject +Project("{F5034706-568F-408A-B7B3-4D38C6DB8A32}") = "Scripts", "Scripts\Scripts.pssproj", "{6CAFC0C6-A428-4D30-A9F9-700E829FEA51}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -85,6 +87,22 @@ Global {0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.ActiveCfg = Release|x86 {0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Build.0 = Release|x86 {0A4279CF-2A67-4868-9906-052E50C25F3B}.Release|x86.Deploy.0 = Release|x86 + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|ARM.Build.0 = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|x64.ActiveCfg = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|x64.Build.0 = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|x86.ActiveCfg = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Debug|x86.Build.0 = Debug|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|Any CPU.Build.0 = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|ARM.ActiveCfg = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|ARM.Build.0 = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|x64.ActiveCfg = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|x64.Build.0 = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|x86.ActiveCfg = Release|Any CPU + {6CAFC0C6-A428-4D30-A9F9-700E829FEA51}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Scripts/ImportCertificate.ps1 b/Scripts/ImportCertificate.ps1 new file mode 100644 index 0000000..726ebf1 --- /dev/null +++ b/Scripts/ImportCertificate.ps1 @@ -0,0 +1,8 @@ +# Enable -Verbose option +[CmdletBinding()] + +param( + [string]$CertPath = "$Env:BUILD_ARTIFACTSTAGINGDIRECTORY", + [Parameter(Mandatory=$true)][string]$FileName +) +Import-Certificate -Filepath "$CertPath\$FileName" \ No newline at end of file diff --git a/Scripts/Scripts.pssproj b/Scripts/Scripts.pssproj new file mode 100644 index 0000000..5d67404 --- /dev/null +++ b/Scripts/Scripts.pssproj @@ -0,0 +1,35 @@ + + + + Debug + 2.0 + 6CAFC0C6-A428-4d30-A9F9-700E829FEA51 + Exe + MyApplication + MyApplication + Scripts + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + \ No newline at end of file diff --git a/Scripts/UpdateVersion.ps1 b/Scripts/UpdateVersion.ps1 new file mode 100644 index 0000000..4e16865 --- /dev/null +++ b/Scripts/UpdateVersion.ps1 @@ -0,0 +1,99 @@ +#Based on https://www.visualstudio.com/docs/build/scripts/index +# Enable -Verbose option +[CmdletBinding()] + +$VersionRegex = "\d+\.\d+\.\d+\.\d+" + +$ManifestVersionRegex = " Version=""\d+\.\d+\.\d+\.\d+""" + +if (-not $Env:BUILD_BUILDNUMBER) +{ + Write-Error ("BUILD_BUILDNUMBER environment variable is missing.") + exit 1 +} +Write-Verbose "BUILD_BUILDNUMBER: $Env:BUILD_BUILDNUMBER" + +$ScriptPath = $null +try +{ + $ScriptPath = (Get-Variable MyInvocation).Value.MyCommand.Path + $ScriptDir = Split-Path -Parent $ScriptPath +} +catch {} + +if (!$ScriptPath) +{ + Write-Error "Current path not found!" + exit 1 +} + +# Get and validate the version data +$VersionData = [regex]::matches($Env:BUILD_BUILDNUMBER,$VersionRegex) +switch($VersionData.Count) +{ + 0 + { + Write-Error "Could not find version number data in BUILD_BUILDNUMBER." + exit 1 + } + 1 {} + default + { + Write-Warning "Found more than instance of version data in BUILD_BUILDNUMBER." + Write-Warning "Will assume first instance is version." + } +} +$NewVersion = $VersionData[0] +Write-Verbose "Version: $NewVersion" + + +$AssemblyVersion = $NewVersion +$ManifestVersion = " Version=""$NewVersion""" + +Write-Host "Version: $AssemblyVersion" +Write-Host "Manifest: $ManifestVersion" +Write-Host "ScriptDir: " $ScriptDir + +# Apply the version to the assembly property files +$assemblyInfoFiles = gci $ScriptDir -recurse -include "*Properties*","My Project" | + ?{ $_.PSIsContainer } | + foreach { gci -Path $_.FullName -Recurse -include AssemblyInfo.* } + +if($assemblyInfoFiles) +{ + Write-Host "Will apply $AssemblyVersion to $($assemblyInfoFiles.count) Assembly Info Files." + + foreach ($file in $assemblyInfoFiles) { + $filecontent = Get-Content($file) + attrib $file -r + $filecontent -replace $VersionRegex, $AssemblyVersion | Out-File $file utf8 + + Write-Host "$file.FullName - version applied" + } +} +else +{ + Write-Warning "No Assembly Info Files found." +} + +# Try Manifests +$manifestFiles = gci .\ -recurse -include "Package.appxmanifest" + +if($manifestFiles) +{ + Write-Host "Will apply $ManifestVersion to $($manifestFiles.count) Manifests." + + foreach ($file in $manifestFiles) { + $filecontent = Get-Content($file) + attrib $file -r + $filecontent -replace $ManifestVersionRegex, $ManifestVersion | Out-File $file utf8 + + Write-Host "$file.FullName - version applied to Manifest" + } +} +else +{ + Write-Warning "No Manifest files found." +} + +Write-Host ("##vso[task.setvariable variable=AppxVersion;]$NewVersion")