conversations
listlengths 2
3
| source
stringclasses 1
value | stack
stringclasses 1
value |
|---|---|---|
[
{
"from": "system",
"value": "Fix appveyor version script to look at correct file.\n"
},
{
"from": "human",
"value": "$regex = New-Object System.Text.RegularExpressions.Regex('<MajorVersion>(\\d\\.\\d)</MajorVersion>')\n$m = $regex.Match((Get-Content src\\Salesforce.VisualStudio.Services\\Salesforce.VisualStudio.Services.csproj))\n$majorMinor = $m.Groups[1].Value\n$version = $majorMinor + '.' + $env:BuildNumber\n\nAdd-AppveyorMessage -Message \"Updating version to $version\" -Category Information\n\nUpdate-AppveyorBuild -Version $version\n"
},
{
"from": "gpt",
"value": "$regex = New-Object System.Text.RegularExpressions.Regex('<MajorVersion>(\\d\\.\\d)</MajorVersion>')\n$m = $regex.Match((Get-Content Salesforce.props))\n$majorMinor = $m.Groups[1].Value\n$version = $majorMinor + '.' + $env:BuildNumber\n\nAdd-AppveyorMessage -Message \"Updating version to $version\" -Category Information\n\nUpdate-AppveyorBuild -Version $version\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add notes about rewriting history.\n"
},
{
"from": "gpt",
"value": "git commit --amend\r\n-avoid if you've already pushed\r\n-change the commit message, or\r\n-change the snapshot with `add` or `rm`\r\n-warning: is a mini-rebase, changes the SHA\r\n\r\ngit rebase -i\r\n-supply the parent of the last commit you want to edit\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use the application manifest in the Chocolatey package over the setup executable\n"
},
{
"from": "human",
"value": "$packageName = 'Chocolatey Explorer'\n$installerType = 'exe'\n$url = 'http://chocolatey-explorer.jdibble.co.uk/setup.exe'\n$silentArgs = '/i /s'\n$validExitCodes = @(0)\n\nInstall-ChocolateyPackage \"$packageName\" \"$installerType\" \"$silentArgs\" \"$url\" -validExitCodes $validExitCodes"
},
{
"from": "gpt",
"value": "$packageName = 'Chocolatey Explorer'\n$installerType = 'exe'\n$url = 'http://chocolatey-explorer.jdibble.co.uk/chocolatey-explorer.application'\n$silentArgs = '/i /s'\n$validExitCodes = @(0)\n\nInstall-ChocolateyPackage \"$packageName\" \"$installerType\" \"$silentArgs\" \"$url\" -validExitCodes $validExitCodes"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Enable Bash-Like Tab-Complete With Powershell\n\nBecause:\n- I'm using powershell as my main shell even on linux\n- powershell's default tab-complete is frustrating\n- Bash's tab-complete is like a quick 'ls' and is very helpful\n"
},
{
"from": "human",
"value": "Set-PSReadLineOption -EditMode \"Vi\" -Colors @{\n Command = [ConsoleColor]::White\n Comment = [ConsoleColor]::White\n ContinuationPrompt = [ConsoleColor]::White\n DefaultToken = [ConsoleColor]::White\n Emphasis = [ConsoleColor]::White\n Error = [ConsoleColor]::White\n Keyword = [ConsoleColor]::White\n Member = [ConsoleColor]::White\n Number = [ConsoleColor]::White\n Operator = [ConsoleColor]::White\n Parameter = [ConsoleColor]::White\n Selection = [ConsoleColor]::White\n String = [ConsoleColor]::White\n Type = [ConsoleColor]::White\n Variable = [ConsoleColor]::White\n}\n\nfunction prompt {\n Write-Host \"┏╸\" -ForegroundColor Magenta -NoNewLine\n Write-Host $pwd -ForegroundColor DarkYellow\n\n $branch = & git branch 2>out-null\n if ($branch -ne $null) {\n Set-PSReadLineOption -ExtraPromptLineCount 2\n Write-Host \"┣╸\" -ForegroundColor Magenta -NoNewLine\n Write-Host \"<\" -ForegroundColor DarkYellow -NoNewLine\n Write-Host $branch.SubString(2) -ForegroundColor Magenta -NoNewLine\n Write-Host \">\" -ForegroundColor DarkYellow\n }\n else {\n Set-PSReadLineOption -ExtraPromptLineCount 1\n # Write-Host \"┣╸\" -ForegroundColor Magenta\n }\n\n Write-Host \"┗\" -ForegroundColor Magenta -NoNewLine\n \"╸\"\n}\n\nfunction awscli {\n Import-Module AWSPowerShell.NetCore\n}\n\n"
},
{
"from": "gpt",
"value": "Set-PSReadLineOption -EditMode \"Vi\" -Colors @{\n Command = [ConsoleColor]::White\n Comment = [ConsoleColor]::White\n ContinuationPrompt = [ConsoleColor]::White\n DefaultToken = [ConsoleColor]::White\n Emphasis = [ConsoleColor]::White\n Error = [ConsoleColor]::White\n Keyword = [ConsoleColor]::White\n Member = [ConsoleColor]::White\n Number = [ConsoleColor]::White\n Operator = [ConsoleColor]::White\n Parameter = [ConsoleColor]::White\n Selection = [ConsoleColor]::White\n String = [ConsoleColor]::White\n Type = [ConsoleColor]::White\n Variable = [ConsoleColor]::White\n}\n\nSet-PSReadlineKeyHandler -Key Tab -Function Complete\n\nfunction prompt {\n Write-Host \"┏╸\" -ForegroundColor Magenta -NoNewLine\n Write-Host $pwd -ForegroundColor DarkYellow\n\n $branch = & git branch 2>out-null\n if ($branch -ne $null) {\n Set-PSReadLineOption -ExtraPromptLineCount 2\n Write-Host \"┣╸\" -ForegroundColor Magenta -NoNewLine\n Write-Host \"<\" -ForegroundColor DarkYellow -NoNewLine\n Write-Host $branch.SubString(2) -ForegroundColor Magenta -NoNewLine\n Write-Host \">\" -ForegroundColor DarkYellow\n }\n else {\n Set-PSReadLineOption -ExtraPromptLineCount 1\n # Write-Host \"┣╸\" -ForegroundColor Magenta\n }\n\n Write-Host \"┗\" -ForegroundColor Magenta -NoNewLine\n \"╸\"\n}\n\nfunction awscli {\n Import-Module AWSPowerShell.NetCore\n}\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use RepoRoot instead of repoDir\n"
},
{
"from": "human",
"value": "[CmdletBinding(PositionalBinding=$false)]\nparam (\n [switch]$release = $false)\n\nSet-StrictMode -version 2.0\n$ErrorActionPreference = \"Stop\"\n\ntry {\n . (Join-Path $PSScriptRoot \"build-utils.ps1\")\n Push-Location $repoDir\n \n Write-Host \"Repo Dir $repoDir\"\n Write-Host \"Binaries Dir $binariesDir\"\n \n $buildConfiguration = if ($release) { \"Release\" } else { \"Debug\" }\n $configDir = Join-Path (Join-Path $binariesDir \"VSSetup\") $buildConfiguration\n \n $optProfToolDir = Get-PackageDir \"Roslyn.OptProf.RunSettings.Generator\"\n $optProfToolExe = Join-Path $optProfToolDir \"tools\\roslyn.optprof.runsettings.generator.exe\"\n $configFile = Join-Path $repoDir \"build\\config\\optprof.json\"\n $outputFolder = Join-Path $configDir \"Insertion\\RunSettings\"\n $optProfArgs = \"--configFile $configFile --outputFolder $outputFolder --buildNumber 28302.01 \"\n \n Exec-Console $optProfToolExe $optProfArgs\n exit 0\n}\ncatch {\n Write-Host $_\n Write-Host $_.Exception\n Write-Host $_.ScriptStackTrace\n exit 1\n}\nfinally {\n Pop-Location\n}"
},
{
"from": "gpt",
"value": "[CmdletBinding(PositionalBinding=$false)]\nparam (\n [switch]$release = $false)\n\nSet-StrictMode -version 2.0\n$ErrorActionPreference = \"Stop\"\n\ntry {\n . (Join-Path $PSScriptRoot \"build-utils.ps1\")\n Push-Location $RepoRoot\n \n Write-Host \"Repo Dir $RepoRoot\"\n Write-Host \"Binaries Dir $binariesDir\"\n \n $buildConfiguration = if ($release) { \"Release\" } else { \"Debug\" }\n $configDir = Join-Path (Join-Path $binariesDir \"VSSetup\") $buildConfiguration\n \n $optProfToolDir = Get-PackageDir \"Roslyn.OptProf.RunSettings.Generator\"\n $optProfToolExe = Join-Path $optProfToolDir \"tools\\roslyn.optprof.runsettings.generator.exe\"\n $configFile = Join-Path $RepoRoot \"build\\config\\optprof.json\"\n $outputFolder = Join-Path $configDir \"Insertion\\RunSettings\"\n $optProfArgs = \"--configFile $configFile --outputFolder $outputFolder --buildNumber 28302.01 \"\n \n Exec-Console $optProfToolExe $optProfArgs\n exit 0\n}\ncatch {\n Write-Host $_\n Write-Host $_.Exception\n Write-Host $_.ScriptStackTrace\n exit 1\n}\nfinally {\n Pop-Location\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove auth params for doc generation\nAuthentication and repo management should be moved to another script...\n"
},
{
"from": "human",
"value": "param($username, $password, [switch]$Buildserver)\r\n\r\n$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition\r\n\r\n$module = \"Keith\"\r\n\r\nImport-Module \"$PSScriptRoot\\src\\$module\" -Force\r\n\r\nNew-PsDoc -Module $module -Path \"$PSScriptRoot\\docs\\\" -OutputLocation \"$PSScriptRoot\\docs-generated\"\r\n\r\nNew-GitBook \"$PSScriptRoot\\docs-generated\" \"$PSScriptRoot\\temp\" $username $password -Buildserver:$Buildserver\r\n"
},
{
"from": "gpt",
"value": "$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition\r\n\r\n$module = \"Keith\"\r\n\r\nImport-Module \"$PSScriptRoot\\src\\$module\" -Force\r\n\r\nNew-PsDoc -Module $module -Path \"$PSScriptRoot\\docs\\\" -OutputLocation \"$PSScriptRoot\\docs-generated\"\r\n\r\nNew-GitBook \"$PSScriptRoot\\docs-generated\" \"$PSScriptRoot\\temp\""
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix hash for chocolate package install\n\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = 'Stop';\n$toolsDir = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$url64 = 'https://certifytheweb.s3.amazonaws.com/downloads/CertifyTheWebSetup.exe'\n\n$packageArgs = @{\n packageName = $env:ChocolateyPackageName\n unzipLocation = $toolsDir\n fileType = 'exe'\n url64bit = $url64\n softwareName = 'Certify The Web*'\n checksum64 = '0578b907488eb426060ce6a098f0d4da8e533ae49b47f18193efbab81fa965bd'\n checksumType64= 'sha256'\n validExitCodes= @(0)\n silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-'\n}\n\nInstall-ChocolateyPackage @packageArgs\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = 'Stop';\n$toolsDir = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$url64 = 'https://certifytheweb.s3.amazonaws.com/downloads/CertifyTheWebSetup.exe'\n\n$packageArgs = @{\n packageName = $env:ChocolateyPackageName\n unzipLocation = $toolsDir\n fileType = 'exe'\n url64bit = $url64\n softwareName = 'Certify The Web*'\n checksum64 = '417af6e1ea83c7180166590b753a3111e6410327273eb402b3782be951598576'\n checksumType64= 'sha256'\n validExitCodes= @(0)\n silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-'\n}\n\nInstall-ChocolateyPackage @packageArgs\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Check tag name to determine if it's time to deploy.\n"
},
{
"from": "human",
"value": "if (($env:appveyor_repo_tag -eq \"True\") -and ($env:appveyor_repo_branch.StartsWith(\"v\"))) {\n write-output \"Deploying to PyPI...\"\n Invoke-Expression \"twine upload -u mcflugen -p $env:PYPI_PASS dist/*\"\n write-output \"OK\"\n} else {\n write-output \"Not deploying.\"\n write-output \"Repo tag is $env:appveyor_repo_tag\"\n write-output \"Branch name $env:appveyor_repo_branch\"\n}\n"
},
{
"from": "gpt",
"value": "if (($env:appveyor_repo_tag -eq \"true\") -and ($env:appveyor_repo_tag_name.StartsWith(\"v\"))) {\n write-output \"Deploying to PyPI...\"\n Invoke-Expression \"twine upload -u mcflugen -p $env:PYPI_PASS dist/*\"\n write-output \"OK\"\n} else {\n write-output \"Not deploying.\"\n write-output \"Repo tag is $env:appveyor_repo_tag\"\n write-output \"Branch name $env:appveyor_repo_tag_name\"\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix windows install script to set Path for the user\n\nOtherwise the path will be set for the session only\n\nSigned-off-by: Jose Cortes <90db7b580b32d49369f56eb8df8e548917a57096@datawire.io>\n"
},
{
"from": "human",
"value": "param\r\n(\r\n $Path = \"C:\\telepresence\"\r\n)\r\n\r\necho \"Installing telepresence to $Path\"\r\n\r\nStart-Process msiexec -Wait -verb runAs -Args \"/i $current_directory\\winfsp.msi /passive /qn /L*V winfsp-install.log\"\r\nStart-Process msiexec -Wait -verb runAs -Args \"/i $current_directory\\sshfs-win.msi /passive /qn /L*V sshfs-win-install.log\"\r\n\r\nif(!(test-path $Path))\r\n{\r\n New-Item -ItemType Directory -Force -Path $Path\r\n}\r\n\r\nCopy-Item \"telepresence.exe\" -Destination \"$Path\" -Force\r\nCopy-Item \"wintun.dll\" -Destination \"$Path\" -Force\r\n\r\n# We update the PATH to include telepresence and its dependency, sshfs-win\r\n[Environment]::SetEnvironmentVariable(\"Path\", \"C:\\$Path;C:\\\\Program Files\\\\SSHFS-Win\\\\bin;$ENV:Path\")\r\n"
},
{
"from": "gpt",
"value": "param\r\n(\r\n $Path = \"C:\\telepresence\"\r\n)\r\n\r\necho \"Installing telepresence to $Path\"\r\n\r\nStart-Process msiexec -Wait -verb runAs -Args \"/i $current_directory\\winfsp.msi /passive /qn /L*V winfsp-install.log\"\r\nStart-Process msiexec -Wait -verb runAs -Args \"/i $current_directory\\sshfs-win.msi /passive /qn /L*V sshfs-win-install.log\"\r\n\r\nif(!(test-path $Path))\r\n{\r\n New-Item -ItemType Directory -Force -Path $Path\r\n}\r\n\r\nCopy-Item \"telepresence.exe\" -Destination \"$Path\" -Force\r\nCopy-Item \"wintun.dll\" -Destination \"$Path\" -Force\r\n\r\n# We update the PATH to include telepresence and its dependency, sshfs-win\r\n[Environment]::SetEnvironmentVariable(\"Path\", \"$Path;C:\\Program Files\\SSHFS-Win\\bin;$ENV:Path\", \"Machine\")\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Rewrite to use $TESTDRIVE which does auto cleanup\n"
},
{
"from": "human",
"value": "# Tests related to TFS item 1370133 [PSUpgrade] Need -NoNewline parameter on Out-File, Add-Content and Set-Content\n# Connect request https://connect.microsoft.com/PowerShell/feedback/details/524739/need-nonewline-parameter-on-out-file-add-content-and-set-content\n\nDescribe \"Tests for -NoNewline parameter of Out-File, Add-Content and Set-Content\" -tags \"Feature\" {\n \n It \"NoNewline parameter works on Out-File\" {\n $temp = New-TemporaryFile\n 1..5 | Out-File $temp.FullName -Encoding 'ASCII' -NoNewline\n (Get-Content $temp -Encoding Byte).Count | Should Be 5\n Remove-Item $temp -ErrorAction SilentlyContinue -Force\n }\n\n It \"NoNewline parameter works on Set-Content\" {\n $temp = New-TemporaryFile\n Set-Content -Path $temp.FullName -Value 'a','b','c' -Encoding 'ASCII' -NoNewline\n (Get-Content $temp -Encoding Byte).Count | Should Be 3\n Remove-Item $temp -ErrorAction SilentlyContinue -Force\n }\n\n It \"NoNewline parameter works on Add-Content\" {\n $temp = New-TemporaryFile\n 1..9 | %{Add-Content -Path $temp.FullName -Value $_ -Encoding 'ASCII' -NoNewline}\n (Get-Content $temp -Encoding Byte).Count | Should Be 9\n Remove-Item $temp -ErrorAction SilentlyContinue -Force\n }\n}\n"
},
{
"from": "gpt",
"value": "# Tests related to TFS item 1370133 [PSUpgrade] Need -NoNewline parameter on Out-File, Add-Content and Set-Content\n# Connect request https://connect.microsoft.com/PowerShell/feedback/details/524739/need-nonewline-parameter-on-out-file-add-content-and-set-content\n\nDescribe \"Tests for -NoNewline parameter of Out-File, Add-Content and Set-Content\" -tags \"Feature\" {\n \n It \"NoNewline parameter works on Out-File\" {\n $temp = \"${TESTDRIVE}/test1.txt\"\n 1..5 | Out-File $temp -Encoding 'ASCII' -NoNewline\n (Get-Content $temp -Encoding Byte).Count | Should Be 5\n }\n\n It \"NoNewline parameter works on Set-Content\" {\n $temp = \"${TESTDRIVE}/test2.txt\"\n Set-Content -Path $temp -Value 'a','b','c' -Encoding 'ASCII' -NoNewline\n (Get-Content $temp -Encoding Byte).Count | Should Be 3\n }\n\n It \"NoNewline parameter works on Add-Content\" {\n $temp = \"${TESTDRIVE}/test3.txt\"\n $temp = New-TemporaryFile\n 1..9 | %{Add-Content -Path $temp -Value $_ -Encoding 'ASCII' -NoNewline}\n (Get-Content $temp -Encoding Byte).Count | Should Be 9\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update of the powershell script\n"
},
{
"from": "human",
"value": "# params\r\n$location = \"LOCATION\"\r\n$ResourceGroupName = \"GEN-KEYVAULT-RESOURCEGROUP-NAM\"\r\n$KeyVaultName = \"GEN-KEYVAULT-NAME\"\r\n$KeyName = \"GEN-KEYVAULT-ENCRYPTION-KEY\"\r\n\r\n#Connect to your Azure account\r\n# Add-AzureAccount\r\n\r\n#Select your subscription if you have more than one\r\n# Select-AzureSubscription -SubscriptionName \"My Subscription Name\"\r\n\r\n# Create a new Key vault, with enable soft delete (prerequisites to use a stored key as encryption protector for SQL)\r\nNew-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName $ResourceGroupName -Location $location -EnableSoftDelete\r\n\r\n# Generate a key\r\nAdd-AzureKeyVaultKey -VaultName $KeyVaultName -Name $KeyName -Destination 'Software'"
},
{
"from": "gpt",
"value": "function New-KeyVaultAndKey()\r\n{\r\n #<#\r\n\t#.Synopsis\r\n\t#\t Deploy a new Key Vault and add a key that will be used as encryption protector for Azure SQL Server\r\n\t#.Description\r\n # Use this script if you do not have already a Key Vault - otherwise, you can use yours in the ARM template included in this repo\r\n #\r\n\t#.Parameter SubscriptionId\r\n # SubscriptionId is the identifier of the subscription to use. \r\n\t#.Parameter ResourceGroupName\r\n # Azure resource group name. If this resource group exists, it will be used for the new Key Vault deployment\r\n #.Parameter KeyVaultLocation\r\n # Azure Key Vault deployment location \r\n #.Parameter KeyVaultName\r\n # Azure Key Vault name to deploy\r\n #.Parameter KeyName\r\n # Azure Key Vault key name to insert in the Azure Key Vault\r\n\t##>\r\n param\r\n (\r\n [Parameter(Mandatory)]\r\n [string]$SubscriptionId,\r\n\r\n [Parameter(Mandatory)]\r\n [string]$ResourceGroupName,\r\n \r\n [Parameter(Mandatory)]\r\n [string]$KeyVaultLocation,\r\n\r\n [Parameter(Mandatory)]\r\n [string]$KeyVaultName,\r\n\r\n [Parameter(Mandatory)]\r\n [string]$KeyName\r\n )\r\n\r\n Add-AzureRmAccount\r\n\r\n Write-Host 'Selecting Azure Subscription...' $SubscriptionId -foregroundcolor Yellow\r\n Select-AzureRmSubscription -SubscriptionId $SubscriptionId\r\n\r\n # Create a new Key vault, with enable soft delete (prerequisites to use a stored key as encryption protector for SQL)\r\n Write-Host 'Creating the new Key Vault...' -foregroundcolor Yellow\r\n New-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName $ResourceGroupName -Location $KeyVaultLocation -EnableSoftDelete\r\n\r\n # Generate a key\r\n Write-Host 'Adding the new key inside the Key Vault...' -foregroundcolor Yellow\r\n Add-AzureKeyVaultKey -VaultName $KeyVaultName -Name $KeyName -Destination 'Software'\r\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix for missing package version due to an non-working meta data extractor\n"
},
{
"from": "human",
"value": "[OutputType([void])]\nparam(\n\t[Parameter()]\n\t$config = \"Release\"\n)\n\nRemove-Item *.nupkg\n\n$nuspecFiles = get-childitem FubarDev.FtpServer*\\*.nuspec\nForEach ($nuspecFile in $nuspecFiles)\n{\n\t$csFile = [System.IO.Path]::ChangeExtension($nuspecFile, \".csproj\")\n\t& nuget pack \"$csFile\" -Properties \"Configuration=$config\" -IncludeReferencedProjects\n}\n"
},
{
"from": "gpt",
"value": "[OutputType([void])]\nparam(\n\t[Parameter()]\n\t$version = \"1.0.0-beta20\",\n\t[Parameter()]\n\t$config = \"Release\"\n)\n\nRemove-Item *.nupkg\n\n$nuspecFiles = get-childitem FubarDev.FtpServer*\\*.nuspec\nForEach ($nuspecFile in $nuspecFiles)\n{\n\t$csFile = [System.IO.Path]::ChangeExtension($nuspecFile, \".csproj\")\n\t& nuget pack \"$csFile\" -Properties \"Configuration=$config;Version=$version\" -IncludeReferencedProjects\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add 'converge' alias for running chef-client.\n"
},
{
"from": "human",
"value": "# Use the Git and posh-git from GitHub for Windows.\n# See <http://stackoverflow.com/a/12524788>\n. (Resolve-Path \"$env:LOCALAPPDATA\\GitHub\\shell.ps1\")\n. $env:github_posh_git\\profile.example.ps1\n\nImport-Module PSReadLine\nSet-PSReadlineOption -EditMode Emacs"
},
{
"from": "gpt",
"value": "# Use the Git and posh-git from GitHub for Windows.\n# See <http://stackoverflow.com/a/12524788>\n. (Resolve-Path \"$env:LOCALAPPDATA\\GitHub\\shell.ps1\")\n. $env:github_posh_git\\profile.example.ps1\n\nImport-Module PSReadLine\nSet-PSReadlineOption -EditMode Emacs\n\n# Shortcut for running chef-client. '-A' makes chef-client fail out if\n# not run as administrator.\nfunction converge {\n\tchef-client -A\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Upgrade to Dolphin VM v7.0.31\n"
},
{
"from": "human",
"value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.30\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion"
},
{
"from": "gpt",
"value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.31\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add nologo to publish script\n"
},
{
"from": "human",
"value": "param([String]$Version=\"0.0.0\");\n\nForEach ($category in \"Core\", \"Modules\", \"Bundles\")\n{\n ForEach ($folder in (Get-ChildItem -Path $category -Directory))\n {\n dotnet pack $folder.FullName -c Release;\n nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).nupkg\";\n nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).snupkg\";\n }\n}\n"
},
{
"from": "gpt",
"value": "param([String]$Version=\"0.0.0\");\n\nForEach ($category in \"Core\", \"Modules\", \"Bundles\")\n{\n ForEach ($folder in (Get-ChildItem -Path $category -Directory))\n {\n dotnet pack $folder.FullName --configuration Release --nologo;\n nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).nupkg\";\n nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).snupkg\";\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix to stop script from failing if solution doesn't exist\n"
},
{
"from": "human",
"value": "#\n# Filename: RemoveSolution.ps1\n#\nparam(\n[string]$SolutionName, #The unique CRM solution name\n[string]$CrmConnectionString, #The connection string as per CRM Sdk\n[int]$Timeout=360\n) \n\n$ErrorActionPreference = \"Stop\"\n\nWrite-Verbose 'Entering RemoveSolution.ps1'\n\nWrite-Verbose \"SolutionName = $SolutionName\"\nWrite-Verbose \"ConnectionString = $CrmConnectionString\"\nWrite-Verbose \"Timeout = $Timeout\"\n\n#Script Location\n$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition\nWrite-Verbose \"Script Path: $scriptPath\"\n\n#Load XrmCIFramework\n$xrmCIToolkit = $scriptPath + \"\\Xrm.Framework.CI.PowerShell.Cmdlets.dll\"\nWrite-Verbose \"Importing CIToolkit: $xrmCIToolkit\" \nImport-Module $xrmCIToolkit\nWrite-Verbose \"Imported CIToolkit\"\n\n$solution = Get-XrmSolution -UniqueSolutionName $SolutionName -ConnectionString $CrmConnectionString -Timeout $Timeout -Verbose\n\nif ($solution -eq $null)\n{\n Write-Error \"Solution is not currently installed.\"\n}\n\nWrite-Host \"Removing solution, version: $solution.Version\"\nRemove-XrmRecord -EntityName \"solution\" -Id $solution.Id -ConnectionString $CrmConnectionString -Timeout $Timeout -Verbose\nWrite-Host \"Solution removed\"\n\nWrite-Verbose 'Leaving RemoveSolution.ps1'"
},
{
"from": "gpt",
"value": "#\n# Filename: RemoveSolution.ps1\n#\nparam(\n[string]$SolutionName, #The unique CRM solution name\n[string]$CrmConnectionString, #The connection string as per CRM Sdk\n[int]$Timeout=360\n) \n\n$ErrorActionPreference = \"Stop\"\n\nWrite-Verbose 'Entering RemoveSolution.ps1'\n\nWrite-Verbose \"SolutionName = $SolutionName\"\nWrite-Verbose \"ConnectionString = $CrmConnectionString\"\nWrite-Verbose \"Timeout = $Timeout\"\n\n#Script Location\n$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition\nWrite-Verbose \"Script Path: $scriptPath\"\n\n#Load XrmCIFramework\n$xrmCIToolkit = $scriptPath + \"\\Xrm.Framework.CI.PowerShell.Cmdlets.dll\"\nWrite-Verbose \"Importing CIToolkit: $xrmCIToolkit\" \nImport-Module $xrmCIToolkit\nWrite-Verbose \"Imported CIToolkit\"\n\n$solution = Get-XrmSolution -UniqueSolutionName $SolutionName -ConnectionString $CrmConnectionString -Timeout $Timeout -Verbose\n\nif ($solution -eq $null)\n{\n Write-Warning \"Solution is not currently installed.\"\n}\nelse\n{\n\tWrite-Host \"Removing solution, version: $solution.Version\"\n\tRemove-XrmRecord -EntityName \"solution\" -Id $solution.Id -ConnectionString $CrmConnectionString -Timeout $Timeout -Verbose\n\tWrite-Host \"Solution removed\"\n}\n\nWrite-Verbose 'Leaving RemoveSolution.ps1'"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove unneeded files after download.\n"
},
{
"from": "human",
"value": "$ffmpeg = \"ffmpeg-20191118.0.0-d831edc\"\n$version = ($ffmpeg -split '-')[1]\n$rel32 = \"$ffmpeg-lgpl21-v142-static-md-x86\"\n$rel64 = \"$ffmpeg-lgpl21-v142-static-md-x64\"\n$wc = New-Object System.Net.WebClient\n\nif (!(Test-Path \"$rel32.7z\")) { $wc.DownloadFile(\"https://github.com/mcmtroffaes/ffmpeg-msvc-build/releases/download/$version/$rel32.zip\", \"$env:temp/$rel32.7z\") }\nif (!(Test-Path \"$rel64.7z\")) { $wc.DownloadFile(\"https://github.com/mcmtroffaes/ffmpeg-msvc-build/releases/download/$version/$rel64.zip\", \"$env:temp/$rel64.7z\") }\n\nif (!(Test-Path $rel32)) { 7z x \"$env:temp/$rel32.7z\" }\nif (!(Test-Path $rel64)) { 7z x \"$env:temp/$rel64.7z\" }\n"
},
{
"from": "gpt",
"value": "$ffmpeg = \"ffmpeg-20191118.0.0-d831edc\"\n$version = ($ffmpeg -split '-')[1]\n$rel32 = \"$ffmpeg-lgpl21-v142-static-md-x86\"\n$rel64 = \"$ffmpeg-lgpl21-v142-static-md-x64\"\n$wc = New-Object System.Net.WebClient\n\nif (!(Test-Path \"$rel32.7z\")) { $wc.DownloadFile(\"https://github.com/mcmtroffaes/ffmpeg-msvc-build/releases/download/$version/$rel32.zip\", \"$env:temp/$rel32.7z\") }\nif (!(Test-Path \"$rel64.7z\")) { $wc.DownloadFile(\"https://github.com/mcmtroffaes/ffmpeg-msvc-build/releases/download/$version/$rel64.zip\", \"$env:temp/$rel64.7z\") }\n\nif (!(Test-Path $rel32)) { 7z x \"$env:temp/$rel32.7z\" }\nif (!(Test-Path $rel64)) { 7z x \"$env:temp/$rel64.7z\" }\n\nGet-ChildItem * -Recurse -Include vcpkg_abi_info.txt, *.cmake, vpx*.lib, vpx*.pdb, zlib*.lib, pkgconfig, libvpx, zlib, vpx, zconf.h, zlib.h | Remove-Item -Recurse -Verbose\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add PowerShell script to start Docker stack\n\nThis commit adds a PowerShell script that mirrors the existing `deploy_stack.*` scripts.\n\nIt also checks that docker is installed and returns a readable error if not found (the alternative is a rather cryptic PowerShell error).\n\nThe docker stack command itself returns a readable error if no swarm has been initialised.\n\nSigned-off-by: John McCabe <a51dda7c7ff50b61eaea0444371f4a6a9301e501@johnmccabe.net>\n"
},
{
"from": "gpt",
"value": "#!ps1\r\n\r\nif (Get-Command docker -errorAction SilentlyContinue)\r\n{\r\n Write-Host \"Deploying stack\"\r\n docker stack deploy func --compose-file ./docker-compose.yml\r\n}\r\nelse\r\n{\r\n Write-Host \"Unable to find docker command, please install Docker (https://www.docker.com/) and retry\"\r\n}\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix ensconce function when used with pipe operator.\n"
},
{
"from": "human",
"value": "$deployToolsDir = Split-Path ((Get-Variable MyInvocation -Scope 0).Value.MyCommand.Path)\n\nif (Test-Path variable:\\OctopusParameters)\n{\n foreach($kp in $OctopusParameters.GetEnumerator())\n {\n Set-Content (\"env:\\\" + $kp.Key) ($kp.Value) -Force\n }\n}\n\nif(!(Test-Path \"env:\\ConfigOnly\"))\n{\n Set-Content \"env:\\ConfigOnly\" $false\n}\n\nfunction ensconce\n{\n $results = & \"$deployToolsDir\\ensconce.exe\" $args 2>&1\n if ($LASTEXITCODE -ne 0)\n {\n throw (\n\"Ensconce operation failed.\n$results\")\n }\n $results\n}\n"
},
{
"from": "gpt",
"value": "$deployToolsDir = Split-Path ((Get-Variable MyInvocation -Scope 0).Value.MyCommand.Path)\n\nif (Test-Path variable:\\OctopusParameters)\n{\n foreach($kp in $OctopusParameters.GetEnumerator())\n {\n Set-Content (\"env:\\\" + $kp.Key) ($kp.Value) -Force\n }\n}\n\nif(!(Test-Path \"env:\\ConfigOnly\"))\n{\n Set-Content \"env:\\ConfigOnly\" $false\n}\n\nfunction ensconce\n{\n if (@($input).Count -ne 0)\n {\n $input.Reset()\n $results = $input | & \"$deployToolsDir\\ensconce.exe\" $args 2>&1\n }\n else {\n $results = & \"$deployToolsDir\\ensconce.exe\" $args 2>&1\n }\n if ($LASTEXITCODE -ne 0)\n {\n throw (\n\"Ensconce operation failed.\n$results\")\n }\n $results\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update registry image, use C:/registry volume\n"
},
{
"from": "human",
"value": "if (!(Test-Path C:\\vagrant\\registry-v2)) {\n mkdir -p C:\\vagrant\\registry-v2\n}\ndocker run --restart=always -d -p 5000:5000 -v \"C:\\vagrant\\registry-v2:C:\\data\" sixeyed/registry:nanoserver\n"
},
{
"from": "gpt",
"value": "if (!(Test-Path C:\\vagrant\\registry-v2)) {\n mkdir -p C:\\vagrant\\registry-v2\n}\ndocker run --restart=always -d -p 5000:5000 -v \"C:\\vagrant\\registry-v2:C:\\registry\" stefanscherer/registry-windows:2.6.0\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Format output from json to return to hyper-v driver\n"
},
{
"from": "human",
"value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId\n)\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n Hyper-V\\Get-VMHardDiskDrive -VMName $VM\n} catch {\n Write-ErrorMessage \"Failed to retrieve all disk info from ${VM}: ${PSItem}\"\n exit 1\n}\n"
},
{
"from": "gpt",
"value": "#Requires -Modules VagrantMessages\n\nparam(\n [Parameter(Mandatory=$true)]\n [string]$VmId\n)\n\ntry {\n $VM = Hyper-V\\Get-VM -Id $VmId\n $Disks = @(Hyper-V\\Get-VMHardDiskDrive -VMName $VM)\n} catch {\n Write-ErrorMessage \"Failed to retrieve all disk info from ${VM}: ${PSItem}\"\n exit 1\n}\n\n$result = ConvertTo-json $Disks\nWrite-OutputMessage $result\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove updating linux docker engine"
},
{
"from": "human",
"value": "param(\n [string]$name\n)\n\nif (! $name) {\n $name = \"dev\"\n}\n\n# ensure that we are running as administrator\nif (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] \"Administrator\")) {#\n Start-Process powershell.exe \"-NoProfile -ExecutionPolicy Bypass -File `\"$PSCommandPath`\" -Name $name\" -Verb RunAs; exit\n}\n\n# create a virtual switch\nif (((Get-VMSwitch).name | grep docker) -ne \"docker\") {\n $description=(Get-NetAdapter).InterfaceDescription | grep -v Hyper-V\n New-VMSwitch -NetAdapterInterfaceDescription $description -Name \"docker\"\n\n Write-Host \"Waiting for internet connectivity\"\n Sleep 15\n}\n\n# create a Hyper-V Linux docker machine\ndocker-machine create -d hyperv --hyperv-virtual-switch \"docker\" $name\n\n# known issues\n# https://github.com/docker/machine/issues/2267\n# https://github.com/docker/machine/issues/2362\n# workaround: https://github.com/docker/machine/issues/2267#issuecomment-156426874\ndocker-machine start $name\ndocker-machine regenerate-certs -f $name\n\n# windows docker client has different API version\n# workaround: update the docker engine in the Hyper-V Linux docker machine\ndocker-machine ssh $name sudo /etc/init.d/docker stop\ndocker-machine ssh $name sudo curl -o /usr/local/bin/docker https://master.dockerproject.org/linux/amd64/docker\ndocker-machine ssh $name sudo /etc/init.d/docker start\n"
},
{
"from": "gpt",
"value": "param(\n [string]$name\n)\n\nif (! $name) {\n $name = \"dev\"\n}\n\n# ensure that we are running as administrator\nif (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] \"Administrator\")) {#\n Start-Process powershell.exe \"-NoProfile -ExecutionPolicy Bypass -File `\"$PSCommandPath`\" -Name $name\" -Verb RunAs; exit\n}\n\n# create a virtual switch\nif (((Get-VMSwitch).name | grep docker) -ne \"docker\") {\n $description=(Get-NetAdapter).InterfaceDescription | grep -v Hyper-V\n New-VMSwitch -NetAdapterInterfaceDescription $description -Name \"docker\"\n\n Write-Host \"Waiting for internet connectivity\"\n Sleep 15\n}\n\n# create a Hyper-V Linux docker machine\ndocker-machine create -d hyperv --hyperv-virtual-switch \"docker\" $name\n\n# known issues\n# https://github.com/docker/machine/issues/2267\n# https://github.com/docker/machine/issues/2362\n# workaround: https://github.com/docker/machine/issues/2267#issuecomment-156426874\ndocker-machine start $name\ndocker-machine regenerate-certs -f $name\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use different database for IATA code.\n"
},
{
"from": "human",
"value": "\n$req_query_iata\n\n$Fields = @{\"iatacode\" = \"$req_query_iata\"}\n$WebResponse = Invoke-RestMethod -Uri \"http://www.airlinecodes.co.uk/airlcoderes.asp\" -Method Post -Body $Fields -Verbose\n\n$regex = '<TD>\\D{3}<\\/TD>'\n\n$WebResponse -match $regex\n\n$result = $Matches[0]\n\nOut-File -Encoding Ascii $res -inputObject $result.Substring(4,3)"
},
{
"from": "gpt",
"value": "\n$req_query_iata\n\n# status Y means current data\n$Fields = @{\"status\" = \"Y\"; \"iataairl\" = \"$req_query_iata\"}\n$WebResponse = Invoke-RestMethod -Uri \"http://avcodes.co.uk/airlcoderes.asp\" -Method Post -Body $Fields -Verbose\n\n$regex = 'ICAO Code:<br /> \\D{3}'\n\n$WebResponse -match $regex\n$result = $Matches[0]\n\nOut-File -Encoding Ascii $res -inputObject $result.Split(';')[1]"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add stub to load user files.\n"
},
{
"from": "human",
"value": "#!/usr/local/bin/pwsh\n#Terminate on powershell error in function or cmd-let. External\n#commands still need to be checked with $LastExitCode, $? checks\n#both, $Error contains a full set of last errors and can be cleared.\n#This preference can be reset on command basis.\n$ErrorActionPreference=\"Stop\"\n$Env:PSModulePath=\"${Env:PSModulePath}:$PSScriptRoot/lib\"\nImport-Module ConfigReader\n\n$cfgFile = \"${PSScriptRoot}/etc/holiday.conf\"\nif (Test-Path $cfgFile) {\n $cfg = ConfigReader\\Read-ConfigFile $cfgFile\n} else {\n $cfg = @{ \"global\" = @( @{ \"port\"=@(1970); \"server\"=@(\"localhost\") } ) }\n}\n#$cfg.global[0].port[0]\n#$cfg.global[0].privileged[0]\n#$cfg.global[0].privileged[1]\n"
},
{
"from": "gpt",
"value": "#!/usr/local/bin/pwsh\n#Terminate on powershell error in function or cmd-let. External\n#commands still need to be checked with $LastExitCode, $? checks\n#both, $Error contains a full set of last errors and can be cleared.\n#This preference can be reset on command basis.\n$ErrorActionPreference=\"Stop\"\n$Env:PSModulePath=\"${Env:PSModulePath}:$PSScriptRoot/lib\"\nImport-Module ConfigReader\n\nfunction Load-UsrFile ([String]$fn) {\n $userName = Split-Path -LeafBase $fn\n $lines = Get-Content -Path $fn\n #if ($lines.Count -lt 1)\n $usr = @{ group = $lines[0]; table = @() }\n for ($i = 1; $i -le $lines.Count; $i++) {\n Write-Host(\"Holiday line:\" + $lines[$i])\n #FIXME: Split and check\n if ($lines[$i] -gt 0) {\n $usr.table += $lines[$i]\n }\n }\n $userDicts.Add($userName, $usr)\n}\n\n$cfgFile = \"${PSScriptRoot}/etc/holiday.conf\"\n$userDicts = @{}\nif (Test-Path $cfgFile) {\n $cfg = ConfigReader\\Read-ConfigFile $cfgFile\n} else {\n $cfg = @{ \"global\" = @( @{ \"port\"=@(1970); \"server\"=@(\"localhost\") } ) }\n}\nGet-ChildItem -Filter *.usr | ForEach-Object { Load-UsrFile $_.FullName }\n#Then startup server\n\n#$cfg.global[0].port[0]\n#$cfg.global[0].privileged[0]\n#$cfg.global[0].privileged[1]\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script for release build\n"
},
{
"from": "gpt",
"value": "$msbuild = \"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe\"\r\n\r\ncd ..\r\nInvoke-Expression ($msbuild + \" BuildSample.sln /p:Configuration=Release /t:Clean\")\r\nInvoke-Expression ($msbuild + \" BuildSample.sln /p:Configuration=Release /t:Rebuild\")\r\n\r\nexplorer Downloads\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add java and python dev tools section\n"
},
{
"from": "human",
"value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Development Tools - Common\n\ncinst papercut\n\n## cinst redis\n\n## cinst jenkins\n\n## cinst rabbitmq\n\n## cinst MongoVUE\n\n## Development Tools - Android\n\n## cinst android-sdk\n\n## cinst python3\n\n## cinst ruby\n\n## cinst python"
},
{
"from": "gpt",
"value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Development Tools - Common\n\ncinst papercut\n\n## cinst redis\n\n## cinst jenkins\n\n## cinst rabbitmq\n\n## cinst mongodb\n\n## cinst MongoVUE\n\n## Development Tools - Java\n\ncinst java.jdk\n\n## cinst Grails\n\n## Development Tools - Ruby\n\n## cinst ruby\n\n## Development Tools - Android\n\n## cinst android-sdk\n\n## Development Tools - Python\n\n## cinst python3\n\n## cinst python\n\n## cinst easy.install"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Tweak node based on Microsoft's version\n"
},
{
"from": "human",
"value": "## This configuration file uses BoxStarter to configure the system\r\n## and Chocolatey to install necessary packages\r\n\r\n## Development Tools - Node.JS & Yarn\r\n\r\nchoco install nvm\r\n\r\nchoco install yarn\r\n\r\nnvm install latest\r\n\r\n# choco install visualstudio2019-workload-node\r\n"
},
{
"from": "gpt",
"value": "## This configuration file uses BoxStarter to configure the system\r\n## and Chocolatey to install necessary packages\r\n\r\n# Based on https://github.com/microsoft/azure-pipelines-image-generation/blob/master/images/win/scripts/Installers/Install-NodeLts.ps1\r\n\r\n$PrefixPath = 'C:\\npm\\prefix'\r\n$CachePath = 'C:\\npm\\cache'\r\n\r\nNew-Item -Path $PrefixPath -Force -ItemType Directory\r\nNew-Item -Path $CachePath -Force -ItemType Directory\r\n\r\nchoco install nodejs-lts -y --force\r\n\r\nsetx NPM_CONFIG_PREFIX $PrefixPath /M\r\n$env:NPM_CONFIG_PREFIX = $PrefixPath\r\n\r\nsetx NPM_CONFIG_CACHE $CachePath /M\r\n$env:NPM_CONFIG_CACHE = $CachePath\r\n\r\nnpm config set registry http://registry.npmjs.org/\r\n\r\nnpm install -g cordova\r\nnpm install -g grunt-cli\r\nnpm install -g gulp-cli\r\nnpm install -g parcel-bundler\r\nnpm install -g --save-dev webpack webpack-cli\r\nnpm install -g yarn\r\n\r\n## Development Tools - Node.JS & Yarn\r\n\r\nchoco install nvm\r\n\r\nnvm install latest\r\n\r\n# choco install visualstudio2019-workload-node"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix release notes path in build\n"
},
{
"from": "human",
"value": "$env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(\"$env:APPVEYOR_BUILD_FOLDER/artifacts/ServerHost/Tgstation.Server.Host.dll\").FileVersion\n\nWrite-Host \"TGS Version: $env:TGSVersion\"\n\nif (($env:CONFIGURATION -match \"Release\") -And ($env:APPVEYOR_REPO_BRANCH -match \"master\") -And ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match \"\\[TGSDeploy\\]\")) {\n Write-Host \"Deploying...\"\n $env:TGSDeploy = \"Do it.\" \n\n Write-Host \"Generating release notes...\"\n dotnet run -p \"$env:APPVEYOR_BUILD_FOLDER/tools/ReleaseNotes\" $env:TGSVersion\n $env:TGSDraftNotes = !($?)\n $releaseNotesPath = \"$env:APPVEYOR_BUILD_FOLDER/tools/ReleaseNotes/release_notes.md\"\n Write-Host \"Reading release notes from $releaseNotesPath...\"\n if (Test-Path $releaseNotesPath -PathType Leaf) {\n $env:TGSReleaseNotes = [IO.File]::ReadAllText($releaseNotesPath)\n }\n else {\n Write-Host \"Release note generation failed, release will be created as a draft!\"\n $env:TGSReleaseNotes = \"Automatic generation failed, please fill manually!\"\n } \n \n if ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match \"\\[NugetDeploy\\]\") {\n $env:NugetDeploy = \"Do it.\"\n Write-Host \"Nuget deployment enabled\"\n } \n}\n"
},
{
"from": "gpt",
"value": "$env:TGSVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(\"$env:APPVEYOR_BUILD_FOLDER/artifacts/ServerHost/Tgstation.Server.Host.dll\").FileVersion\n\nWrite-Host \"TGS Version: $env:TGSVersion\"\n\nif (($env:CONFIGURATION -match \"Release\") -And ($env:APPVEYOR_REPO_BRANCH -match \"master\") -And ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match \"\\[TGSDeploy\\]\")) {\n Write-Host \"Deploying...\"\n $env:TGSDeploy = \"Do it.\" \n\n Write-Host \"Generating release notes...\"\n $bf = $env:APPVEYOR_BUILD_FOLDER\n dotnet run -p \"$bf/tools/ReleaseNotes\" $env:TGSVersion\n $env:TGSDraftNotes = !($?)\n $releaseNotesPath = \"$bf/release_notes.md\"\n Write-Host \"Reading release notes from $releaseNotesPath...\"\n if (Test-Path $releaseNotesPath -PathType Leaf) {\n $env:TGSReleaseNotes = [IO.File]::ReadAllText($releaseNotesPath)\n }\n else {\n Write-Host \"Release note generation failed, release will be created as a draft!\"\n $env:TGSReleaseNotes = \"Automatic generation failed, please fill manually!\"\n } \n \n if ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match \"\\[NugetDeploy\\]\") {\n $env:NugetDeploy = \"Do it.\"\n Write-Host \"Nuget deployment enabled\"\n } \n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Switch to using my docker image\n"
},
{
"from": "human",
"value": "trap [Management.Automation.CommandNotFoundException] {\n Write-Error 'Docker cannot be found. Make sure it is installed and added to the path.'\n Start-Process -FilePath 'https://docs.docker.com/docker-for-windows/install/'\n continue;\n}\n\ndocker run --rm -it -v ${PSScriptRoot}:/nunit-console -w=/nunit-console mono:5.10.0 bash build.sh $args"
},
{
"from": "gpt",
"value": "trap [Management.Automation.CommandNotFoundException] {\n Write-Error 'Docker cannot be found. Make sure it is installed and added to the path.'\n Start-Process -FilePath 'https://docs.docker.com/docker-for-windows/install/'\n continue;\n}\n\ndocker run --rm -it -v ${PSScriptRoot}:/nunit-console -w=/nunit-console rprouse/nunit-docker:latest bash build.sh $args"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add Unit Test for Get-Host\n"
},
{
"from": "human",
"value": "Describe \"Get-Host\" {\n It \"Should return a type of InternalHost for Get-Host cmdlet\" {\n\n\t(Get-Host).GetType().Name | Should Be InternalHost\n\n }\n\n It \"Should have $ host variable be equivalent to Get-Host object\" {\n\n\tGet-Host | Should Be $host\n\n }\n}\n"
},
{
"from": "gpt",
"value": "Describe \"Get-Host DRT Unit Tests\" -Tags DRT{\n It \"Should works proper with get-host\" {\n $results = Get-Host \n $results | Should Be $Host\n $results.GetType().Name | Should Be InternalHost\n }\n}\n\nDescribe \"Get-Host\" {\n It \"Should return a type of InternalHost for Get-Host cmdlet\" {\n\n\t(Get-Host).GetType().Name | Should Be InternalHost\n\n }\n\n It \"Should have $ host variable be equivalent to Get-Host object\" {\n\n\tGet-Host | Should Be $host\n\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add a script to decode kubernetes secret.\n\nChange-Id: Ie668ecccb93d3c7e235df16cfce746a8334e01d5\n"
},
{
"from": "gpt",
"value": "# Copyright (c) 2019 Google LLC.\n# \n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n# use this file except in compliance with the License. You may obtain a copy of\n# the License at\n# \n# http://www.apache.org/licenses/LICENSE-2.0\n# \n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n# License for the specific language governing permissions and limitations under\n# the License.\n\n##############################################################################\n#.SYNOPSIS\n# Decode a Kubernetes secret to a file.\n#\n#.DESCRIPTION\n# Invokes kubectl.\n#\n#.PARAMETER SecretName\n# The Kubernetes secret name.\n#\n#.PARAMETER FileName\n# The name of the file in the Kubernetes secret.\n#\n#.PARAMETER OutputFileName\n# Optional. The name of the file to write. Clobbers any existing file.\n# If none, then dumps the file contents to stdout.\n#\n#.EXAMPLE\n# .\\Get-SecretFile.ps1 my-kubernetes-secret super-secrets.json super-secrets.json\n##############################################################################\n\nparam(\n [Parameter(Mandatory=$true)][string]$SecretName,\n [Parameter(Mandatory=$true)][string]$FileName,\n [string]$OutputFileName)\n\n$base64text = (kubectl get secret $SecretName -o json | ConvertFrom-Json).data.$FileName\n$bytes = [System.Convert]::FromBase64String($base64text)\nif ($OutputFileName) {\n [io.file]::WriteAllBytes($OutputFileName, $bytes)\n} else {\n [System.Text.Encoding]::UTF8.GetString($bytes)\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Handle environment not being present initially in script\n"
},
{
"from": "human",
"value": "<#\n .DESCRIPTION\n Create a docker compose .env file\n#>\n$scriptPath = Split-Path -parent $PSCommandPath\n$envFilePath = Resolve-Path \"$scriptPath\\..\\.env\"\n$getEnvCommand = Resolve-Path \"$scriptPath\\..\\lib\\killrvideo-docker-common\\get-environment.ps1\"\n\n# Base environment variables to be written\n$dockerEnv = @(\"COMPOSE_PROJECT_NAME=killrvideoweb\", \"COMPOSE_FILE=.\\lib\\killrvideo-docker-common\\docker-compose.yaml\")\n\n# Get the docker environment using the common script and add to array\n& \"$getEnvCommand\" |% { $dockerEnv += $_ }\n\n# We have to use .NET to do this so it gets written as UTF-8 without the BOM\n$Utf8NoBom = New-Object System.Text.UTF8Encoding($false)\n[System.IO.File]::WriteAllLines($envFilePath, $dockerEnv, $Utf8NoBom)\nWrite-Host \"Environment file written to $envFilePath\" "
},
{
"from": "gpt",
"value": "<#\n .DESCRIPTION\n Create a docker compose .env file\n#>\n$scriptPath = Split-Path -parent $PSCommandPath\n$envFilePath = \"$scriptPath\\..\\.env\"\n$getEnvCommand = Resolve-Path \"$scriptPath\\..\\lib\\killrvideo-docker-common\\get-environment.ps1\"\n\n# Base environment variables to be written\n$dockerEnv = @(\"COMPOSE_PROJECT_NAME=killrvideoweb\", \"COMPOSE_FILE=.\\lib\\killrvideo-docker-common\\docker-compose.yaml\")\n\n# Get the docker environment using the common script and add to array\n& \"$getEnvCommand\" |% { $dockerEnv += $_ }\n\n# We have to use .NET to do this so it gets written as UTF-8 without the BOM\n$Utf8NoBom = New-Object System.Text.UTF8Encoding($false)\n[System.IO.File]::WriteAllLines($envFilePath, $dockerEnv, $Utf8NoBom)\n$envFilePath = Resolve-Path $envFilePath\nWrite-Host \"Environment file written to $envFilePath\" "
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script to download test files from GH folder via build\n"
},
{
"from": "gpt",
"value": "[CmdletBinding()]\nparam (\n [Parameter(Mandatory=$false)][string]$githubTestFilesFolderUri,\n [Parameter(Mandatory=$false)][string]$githubBuildFilesFolderUri\n)\n\nif(!$githubTestFilesFolderUri) {\n # default to azure quickstart template uri\n Write-Host \"Defaulting to azure quick start uri\"\n $githubTestFilesFolderUri = \"https://api.github.com/repos/Azure/azure-quickstart-templates/contents/test/solution-template-validation-tests/test\"\n}\n\nif(!$githubBuildFilesFolderUri) {\n # default to azure quickstart template uri\n Write-Host \"Defaulting to azure quick start uri\"\n $githubBuildFilesFolderUri = \"https://api.github.com/repos/Azure/azure-quickstart-templates/contents/test/solution-template-validation-tests/buildfiles\"\n}\n\nWrite-Host \"Getting contents from $githubTestFilesFolderUri\"\n$folderContents = Invoke-WebRequest $githubTestFilesFolderUri | Select-Object -ExpandProperty Content | ConvertFrom-Json\n\nWrite-Host \"Creating test directory if one doesn't exist already\"\n$path = (Get-Item -Path \".\\\" -Verbose).FullName + \"\\test\"\nIf(!(test-path $path))\n{\n Write-Host \"Creating test directory\"\n New-Item -ItemType Directory -Force -Path $path\n}\n\ncd $path\nforeach($file in $folderContents) \n{\n Write-Host \"Downloading file $file.name\"\n Invoke-WebRequest $file.download_url -OutFile $file.name\n}\n\nWrite-Host \"Listing files downloaded\"\ndir\n\n# go back to current directory\ncd ..\n\nWrite-Host \"Getting contents from $githubBuildFilesFolderUri\"\n$folderContents = Invoke-WebRequest $githubBuildFilesFolderUri | Select-Object -ExpandProperty Content | ConvertFrom-Json\n\nforeach($file in $folderContents) \n{\n Write-Host \"Downloading file $file.name\"\n Invoke-WebRequest $file.download_url -OutFile $file.name\n}\n\n$packageJsonFile = \"https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/test/solution-template-validation-tests/package.json\"\nWrite-Host \"Downloading package.json file from $packageJsonFile\"\nInvoke-WebRequest $packageJsonFile -OutFile \"package.json\"\n\nWrite-Host \"Listing files downloaded\"\ndir"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add helper script for pulling in latest from subtree dependencies\n"
},
{
"from": "gpt",
"value": "<#\n .DESCRIPTION\n Pull the latest from the projects that are git subtrees.\n#>\n\ngit subtree pull --prefix lib/killrvideo-docker-common git@github.com:KillrVideo/killrvideo-docker-common.git master --squash\ngit subtree pull --prefix lib/killrvideo-service-protos git@github.com:KillrVideo/killrvideo-service-protos.git master --squash"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update to deployment script for 7-zip\n"
},
{
"from": "human",
"value": "function ZipFile\n{\n\tparam(\n\t\t[String]$sourceFile,\n\t\t[String]$zipFile\n\t)\n\n\tset-alias sz \"C:\\Program Files\\7-Zip\\7z.exe\" \n\tsz a -tzip -r $zipFile $sourceFile | Out-Null\n}\n\n$root = $PSScriptRoot\n$source = $root.Replace(\"deployment\", \"\") + \"\\source\"\n$version = Read-Host -Prompt \"What version are we building?\"\n\n# build for mongo db \nWrite-Host \"Building SqlServerReportRunner version $version\"\n$binfolder = \"$source\\SqlServerReportRunner\\bin\\Release\"\n[system.io.file]::Delete(\"$binfolder\\Connections.config\")\n$zip = \"$root\\Output\\SqlServerReportRunner_v$version.zip\"\n[system.io.file]::Delete($zip)\nZipFile -sourcefile \"$binfolder\\*.*\" -zipfile $zip \n\nWrite-Host \"Done\" -BackgroundColor Green -ForegroundColor White\n\n"
},
{
"from": "gpt",
"value": "function ZipFile\n{\n\tparam(\n\t\t[String]$sourceFile,\n\t\t[String]$zipFile\n\t)\n\n\tset-alias sz \"C:\\Program Files (x86)\\7-Zip\\7z.exe\" \n\tsz a -tzip -r $zipFile $sourceFile | Out-Null\n}\n\n$root = $PSScriptRoot\n$source = $root.Replace(\"deployment\", \"\") + \"\\source\"\n$version = Read-Host -Prompt \"What version are we building?\"\n\n# build for mongo db \nWrite-Host \"Building SqlServerReportRunner version $version\"\n$binfolder = \"$source\\SqlServerReportRunner\\bin\\Release\"\n[system.io.file]::Delete(\"$binfolder\\Connections.config\")\n$zip = \"$root\\Output\\SqlServerReportRunner_v$version.zip\"\n[system.io.file]::Delete($zip)\nZipFile -sourcefile \"$binfolder\\*.*\" -zipfile $zip \n\nWrite-Host \"Done\" -BackgroundColor Green -ForegroundColor White\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix security vulnerability in npm lodash used in PackageVSTS cake.build task\n\n* https://nodesecurity.io/advisories?search=lodash&version=3.10.1\n"
},
{
"from": "human",
"value": "npm i -g tfx-cli\ntfx extension create --manifest-globs vss-extension.json"
},
{
"from": "gpt",
"value": "npm i npm@latest -g \nnpm i -g tfx-cli\ntfx extension create --manifest-globs vss-extension.json"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add PowerShell script to upload VSIX to MyGet feed"
},
{
"from": "gpt",
"value": "$artifactsSearchPattern = \"./*.vsix\"\n$artifactsCollection = (Get-ChildItem $artifactsSearchPattern -Recurse)\n\n$vsixMyGetUploadEndpoint = \"https://www.myget.org/F/nanoframework-dev/vsix/upload\"\n\n# for the environment variable MyGetToken to work here it has to be set in AppVeyor UI\n\nforeach($file in $artifactsCollection)\n{\n 'Uploading VSIX package to MyGet feed...' | Write-Host -ForegroundColor White -NoNewline\n\n $webClient = New-Object System.Net.WebClient\n $webClient.Headers.add('X-NuGet-ApiKey', $env:MyGetToken)\n $webClient.UploadFile($vsixMyGetUploadEndpoint, 'POST', $file)\n 'OK' | Write-Host -ForegroundColor Green\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Test properly for atom and code availability\n"
},
{
"from": "human",
"value": "chcp 65001 | out-null\n\nfunction prompt {\n '[' + $env:username + '@' + $env:computername + ' ' + $pwd + \"]`r`n$ \"\n}\n\nfunction .. {\n Set-Location ..\n}\nfunction ... {\n Set-Location ..\\..\n}\nfunction .... {\n Set-Location ..\\..\\..\n}\n\nSet-Alias l Get-ChildItem\nSet-Alias ll Get-ChildItem\nSet-Alias open Invoke-Item\n\nif (Test-Path 'C:\\Program Files\\Sublime Text 3') {\n Set-Alias edit 'C:\\Program Files\\Sublime Text 3\\sublime_text'\n}\n\nif (Test-Path 'C:\\Program Files (x86)\\Microsoft VS Code') {\n Set-Alias edit 'C:\\Program Files (x86)\\Microsoft VS Code\\code'\n}\n\n[net.webrequest]::defaultwebproxy.credentials = [net.credentialcache]::defaultcredentials\n"
},
{
"from": "gpt",
"value": "chcp 65001 | out-null\n\nfunction prompt {\n '[' + $env:username + '@' + $env:computername + ' ' + $pwd + \"]`r`n$ \"\n}\n\nfunction .. {\n Set-Location ..\n}\nfunction ... {\n Set-Location ..\\..\n}\nfunction .... {\n Set-Location ..\\..\\..\n}\n\nSet-Alias l Get-ChildItem\nSet-Alias ll Get-ChildItem\nSet-Alias open Invoke-Item\n\nif (Test-Path 'C:\\Program Files\\Sublime Text 3') {\n Set-Alias edit 'C:\\Program Files\\Sublime Text 3\\sublime_text'\n}\nif (Get-Command \"atom\" -ErrorAction SilentlyContinue) { \n Set-Alias edit atom\n}\nif (Get-Command \"code\" -ErrorAction SilentlyContinue) { \n Set-Alias edit code\n}\n\n[net.webrequest]::defaultwebproxy.credentials = [net.credentialcache]::defaultcredentials\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use net6.0 as framework for code coverage\n"
},
{
"from": "human",
"value": "# Framework to use when generating coverage. Must be a \"real\" framework, i.e. not netstandard.\n$framework = \"netcoreapp3.1\";\n# The file path passed to coverlet...\n$coverletWantedOutput = \"$PSScriptRoot\\coverage.xml\";\n# ...which will result in the following filename.\n$coverletActualOutput = \"$PSScriptRoot\\\" + \"coverage.{framework}.xml\".Replace(\"{framework}\", $framework);\nIf (Test-Path $coverletActualOutput) {\n\tRemove-Item $coverletActualOutput -Force\n}\n\ndotnet test -f $framework /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$coverletWantedOutput /p:Exclude=\"[xunit.*]*\" ../source/tusdotnet.sln\n\n$key = Read-Host -Prompt 'Input Codecov key'\n\nif(-not (Test-Path $coverletActualOutput)) {\n\tthrow \"$coverletActualOutput was not found\";\n}\n./codecov.sh -t $key"
},
{
"from": "gpt",
"value": "# Framework to use when generating coverage. Must be a \"real\" framework, i.e. not netstandard.\n$framework = \"net6.0\";\n# The file path passed to coverlet...\n$coverletWantedOutput = \"$PSScriptRoot\\coverage.xml\";\n# ...which will result in the following filename.\n$coverletActualOutput = \"$PSScriptRoot\\\" + \"coverage.{framework}.xml\".Replace(\"{framework}\", $framework);\nIf (Test-Path $coverletActualOutput) {\n\tRemove-Item $coverletActualOutput -Force\n}\n\ndotnet test -f $framework /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=$coverletWantedOutput /p:Exclude=\"[xunit.*]*\" ../source/tusdotnet.sln\n\n$key = Read-Host -Prompt 'Input Codecov key'\n\nif(-not (Test-Path $coverletActualOutput)) {\n\tthrow \"$coverletActualOutput was not found\";\n}\n./codecov.sh -t $key"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add PS script for electron-winstaller packaging\n"
},
{
"from": "gpt",
"value": "<#\nPackage script for electron-winstaller\n\nThe NPM package electron-winstaller allows developers to\nbuild Windows installers for Electron apps using Squirrel\n(https://github.com/electron/windows-installer)\n\nThis script copies the required files into a single folder\nwhich can then be copied to the electron-winstaller/vendor folder\n(either manually or in an automated way).\n#>\n\n# Stop the script if an error occurs\n$ErrorActionPreference = \"Stop\"\n$In = \".\\build\\Release\\\"\n$Out = \".\\build\\electron-winstaller\\\"\n$Folders = @(\"./build\", \"./packages\", \"./test/bin\", \"./test/obj\")\n\n# Ensure a clean state by removing build/package folders\nforeach ($Folder in $Folders) {\n if (Test-Path $Folder) {\n Remove-Item -path $Folder -Recurse -Force\n }\n}\n\n# Build Squirrel\ngit submodule update --init --recursive\n.\\.NuGet\\NuGet.exe restore\nmsbuild /p:Configuration=Release\n\n# Create the electron-winstaller folder\nNew-Item -Path $Out -ItemType \"directory\" | Out-Null\n\n# Copy over all files we need\nCopy-Item \"$In\\net45\\Update.exe\" -Destination \"$Out\\Squirrel.exe\"\nCopy-Item \"$In\\net45\\update.com\" -Destination \"$Out\\Squirrel.com\"\nCopy-Item \"$In\\net45\\Update.pdb\" -Destination \"$Out\\Squirrel.pdb\"\nCopy-Item \"$In\\Win32\\Setup.exe\" -Destination $Out\nCopy-Item \"$In\\Win32\\Setup.pdb\" -Destination $Out\nCopy-Item \"$In\\net45\\Update-Mono.exe\" -Destination \"$Out\\Squirrel-Mono.exe\"\nCopy-Item \"$In\\net45\\Update-Mono.pdb\" -Destination \"$Out\\Squirrel-Mono.pdb\"\nCopy-Item \"$In\\Win32\\StubExecutable.exe\" -Destination $Out\nCopy-Item \"$In\\net45\\SyncReleases.exe\" -Destination $Out\nCopy-Item \"$In\\net45\\SyncReleases.pdb\" -Destination $Out\nCopy-Item \"$In\\Win32\\WriteZipToSetup.exe\" -Destination $Out\nCopy-Item \"$In\\Win32\\WriteZipToSetup.pdb\" -Destination $Out\n\nWrite-Output \"Successfully copied files for electron-winstaller to build/electron-winstaller.\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Clean up a little code\n"
},
{
"from": "human",
"value": "$hostname = $(get-childitem -path env:computername).value\n$ipaddress = $(ipconfig | where {$_ -match 'IPv4.+\\s(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})' } | out-null; $Matches[1])\n\n$puppet = 'C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet.bat'\nTest-Path $puppet\nif($?){\n Write-Host \"puppet-agent OK\"\n choco upgrade puppet-agent\n} else {\n choco install puppet-agent --force -y\n}\n& $puppet module install puppetlabs-chocolatey --version 2.0.2\n"
},
{
"from": "gpt",
"value": "$hostname = $(get-childitem -path env:computername).value\n$ipaddress = $(ipconfig | where {$_ -match 'IPv4.+\\s(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})' } | out-null; $Matches[1])\n\n$puppet = 'C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet.bat'\nTest-Path $puppet\nif($?){\n Write-Host \"puppet-agent OK\"\n choco upgrade puppet-agent\n} else {\n choco install puppet-agent --force -y\n}\n& $puppet module install puppetlabs-chocolatey --version 2.0.2\n& $puppet 'apply' '--test' \"$PSScriptRoot\\test.pp\" \n\nnssm set consul Application (Get-Command consul).Path\nnssm set consul AppParameters agent -bootstrap -server -ui -node $hostname -advertise $ipaddress --data-dir c:\\var\\consul\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix bug in version script.\n"
},
{
"from": "human",
"value": "param([String]$oldVersion=\"\", [String]$newVersion=\"\")\niex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/StephenCleary/BuildTools/18aed44c432381eaa11329d82f63dfaf835d219c/Version.ps1'))\n"
},
{
"from": "gpt",
"value": "param([String]$oldVersion=\"\", [String]$newVersion=\"\")\niex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/StephenCleary/BuildTools/0297d9e34cc1ff5391b474b4fa29d6be9b236b83/Version.ps1'))\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update default version of Microsoft.PowerShell.SDK to 6.2.3\n"
},
{
"from": "human",
"value": "if (!($DefaultFunctionMemory))\n{\n New-Variable -Name DefaultFunctionMemory -Value 512 -Option Constant\n}\n\nif (!($DefaultFunctionTimeout))\n{\n New-Variable -Name DefaultFunctionTimeout -Value 90 -Option Constant\n}\n\nif (!($ProjectModuleDirectory))\n{\n New-Variable -Name ProjectModuleDirectory -Value 'Modules' -Option Constant\n}\n\nif (!($AwsPowerShellFunctionEnvName))\n{\n New-Variable -Name AwsPowerShellFunctionEnvName -Value 'AWS_POWERSHELL_FUNCTION_HANDLER' -Option Constant\n}\n\nif (!($AwsPowerShellDefaultSdkVersion))\n{\n New-Variable -Name AwsPowerShellDefaultSdkVersion -Value '6.1.1' -Option Constant\n}\n"
},
{
"from": "gpt",
"value": "if (!($DefaultFunctionMemory))\n{\n New-Variable -Name DefaultFunctionMemory -Value 512 -Option Constant\n}\n\nif (!($DefaultFunctionTimeout))\n{\n New-Variable -Name DefaultFunctionTimeout -Value 90 -Option Constant\n}\n\nif (!($ProjectModuleDirectory))\n{\n New-Variable -Name ProjectModuleDirectory -Value 'Modules' -Option Constant\n}\n\nif (!($AwsPowerShellFunctionEnvName))\n{\n New-Variable -Name AwsPowerShellFunctionEnvName -Value 'AWS_POWERSHELL_FUNCTION_HANDLER' -Option Constant\n}\n\nif (!($AwsPowerShellDefaultSdkVersion))\n{\n New-Variable -Name AwsPowerShellDefaultSdkVersion -Value '6.2.3' -Option Constant\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Print the cmake build command.\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = \"Stop\"\n\n$BUILD_MODE = $Env:BUILD_MODE\n$VS_PLATFORM = $Env:VS_PLATFORM\n\nif(!$BUILD_MODE) {$BUILD_MODE = \"Debug\"}\nif(!$VS_PLATFORM) {$VS_PLATFORM = \"Win32\"}\n\n# Use the bundled vulkan SDK.\n$Env:VULKAN_SDK = \"$(pwd)\\thirdparty\\vulkan-sdk-windows\"\n\nmkdir build\ncd build\ncmake.exe .. -G \"Visual Studio 16 2019\" -A $VS_PLATFORM\ncmake.exe --build . --config $BUILD_MODE\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = \"Stop\"\n\n$BUILD_MODE = $Env:BUILD_MODE\n$VS_PLATFORM = $Env:VS_PLATFORM\n\nif(!$BUILD_MODE) {$BUILD_MODE = \"Debug\"}\nif(!$VS_PLATFORM) {$VS_PLATFORM = \"Win32\"}\n\n# Use the bundled vulkan SDK.\n$Env:VULKAN_SDK = \"$(pwd)\\thirdparty\\vulkan-sdk-windows\"\n\nmkdir build\ncd build\necho cmake.exe .. -G \"Visual Studio 16 2019\" -A $VS_PLATFORM\ncmake.exe .. -G \"Visual Studio 16 2019\" -A $VS_PLATFORM\necho cmake.exe --build . --config $BUILD_MODE\ncmake.exe --build . --config $BUILD_MODE\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add first PowerShell script for copying in Windows 8/8.1/10 .\n\nHopefully works on WIndows 7 with PowerShell 4.\n"
},
{
"from": "gpt",
"value": "[CmdletBinding()]\nParam(\n [Parameter(Mandatory=$false)]\n [switch]$force,\n [Parameter(Mandatory=$true)]\n [string]$source\n)\n\n$DISKLIVE = [System.IO.Path]::GetTempFileName()\nNew-Item -Path $DISKLIVE -itemtype file -force | OUT-NULL\nAdd-Content -Path $DISKLIVE \"LIST DISK\"\n$LISTDISK=(diskpart.exe /s $DISKLIVE)\nRemove-Item -Force $DISKLIVE\n$TOTALDISK=$LISTDISK.count\nif ($TOTALDISK -eq 0) {\n Write-Output 'Please run as Administrator.'\n Pause\n exit\n}\n$TOTALDISK=($LISTDISK.count)-9\n$DISKID=$LISTDISK[-1].substring(7,5).trim()\n$j = @()\n$DLs = @()\nfor ($i=0; $i -le $DISKID; $i++) {\n $DISKDETAIL = [System.IO.Path]::GetTempFileName()\n New-Item -Path $DISKDETAIL -itemtype file -force | OUT-NULL\n Add-Content -Path $DISKDETAIL \"SELECT DISK $i\"\n Add-Content -Path $DISKDETAIL \"DETAIL DISK\"\n $DETAIL=(diskpart.exe /s $DISKDETAIL)\n $TYPE=$DETAIL[10].substring(11).trim()\n $LABEL=$DETAIL[-1].substring(18,11).trim()\n if ($TYPE -eq \"USB\") {\n if (($LABEL -ne \"MATERIAPPS\") -or ($FORCE)) {\n $DISKFORMAT = [System.IO.Path]::GetTempFileName()\n New-Item -Path $DISKFORMAT -ItemType file -Force | OUT-NULL\n Add-Content -Path $DISKFORMAT \"SELECT DISK $i\"\n Add-Content -Path $DISKFORMAT \"CLEAN\"\n Add-Content -Path $DISKFORMAT \"CONVERT GPT\"\n Add-Content -Path $DISKFORMAT \"CREATE PARTITION PRIMARY\"\n Add-Content -Path $DISKFORMAT \"FORMAT QUICK FS=FAT32 LABEL=`\"MATERIAPPS`\"\"\n Add-Content -Path $DISKFORMAT \"ASSIGN\"\n Add-Content -Path $DISKFORMAT \"EXIT\"\n $FORMAT=(diskpart.exe /s $DISKFORMAT)\n }\n $DETAIL=(diskpart.exe /s $DISKDETAIL)\n $DRIVELETTER=$DETAIL[-1].substring(15,1)\n $j += Start-Job -ScriptBlock {param($SOURCE, $DESTINATION) Copy-Item $SOURCE -Destination $DESTINATION -Recurse -Force} -Argumentlist $source,${DRIVELETTER}:\\\n $DLs += $DRIVELETTER\n }\n Remove-Item -Force $DISKDETAIL\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add $RPROMPT support similar to zsh\n"
},
{
"from": "human",
"value": "function Get-GitBranch\r\n{\r\n\t$branch = git branch -a 2> $null | Where-Object {$_ -match \"^\\*\"}\r\n\tif ($branch -eq $null) {\r\n\t\treturn $null;\r\n\t}\r\n\t\r\n\t$branch = $branch.Substring(2)\r\n\t\r\n\tif ($branch -match \"^\\(.*\\)$\") {\r\n\t\t$branch = (git name-rev HEAD 2> $null).Substring(5)\r\n\t}\r\n\t\r\n\t$workdir = ([io.fileinfo](git workdir 2> $null)).basename\r\n\t\r\n\t\"$($workdir):$($branch)\"\r\n}\r\n\r\nfunction prompt\r\n{\r\n\t$git = Get-GitBranch\r\n\tif ($git -ne $null) { \r\n\t\t$git = \"[$git] \"\r\n\t}\r\n\t\"$($git)$($executionContext.SessionState.Path.CurrentLocation) $('$' * ($nestedPromptLevel + 1)) \"\r\n}"
},
{
"from": "gpt",
"value": "function Get-GitBranch\r\n{\r\n\t$branch = git branch -a 2> $null | Where-Object {$_ -match \"^\\*\"}\r\n\tif ($branch -eq $null) {\r\n\t\treturn $null\r\n\t}\r\n\t\r\n\t$branch = $branch.Substring(2)\r\n\t\r\n\tif ($branch -match \"^\\(.*\\)$\") {\r\n\t\t$branch = (git name-rev HEAD 2> $null).Substring(5)\r\n\t}\r\n\t\r\n\t$workdir = ([io.fileinfo](git workdir 2> $null)).basename\r\n\t\r\n\t\"$($workdir):$($branch)\"\r\n}\r\n\r\nfunction prompt\r\n{\r\n\t$exit = $LastExitCode\r\n\tif ($exit -eq $null) {\r\n\t\t$exit = 0\r\n\t}\r\n\t\r\n\t$git = Get-GitBranch\r\n\tif ($git -ne $null) { \r\n\t\t$git = \"[$git] \"\r\n\t}\r\n\t\r\n\t# Reset $LastExitCode so we don't get confusing things happening because of stuff we've run\r\n\tcmd /c \"exit $($exit)\"\r\n\t\r\n\t# Right prompt\r\n\t$rprompt = \"[$($exit)]\"\r\n\tWrite-Host (\" \" * ($host.ui.rawui.windowsize.width - $rprompt.length - 1) + \"$($rprompt)`r\") -nonewline\r\n\t\r\n\t# Left prompt\r\n\t\"$($git)$($executionContext.SessionState.Path.CurrentLocation) $('$' * ($nestedPromptLevel + 1)) \"\r\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Build script now clears build output folder before building.\n"
},
{
"from": "human",
"value": "$scriptDir = $MyInvocation.MyCommand.Path | split-path\n$outputDir = \"$scriptDir\\BuildOutput\"\n\nmd $outputDir -f | out-null\n\ngci $scriptDir -include Regalo.Core.csproj,Regalo.RavenDB.csproj,Regalo.SqlServer.csproj,Regalo.Testing.csproj,Regalo.ObjectCompare.csproj -recurse | %{ \n Write-Host -ForegroundColor Green \"$_\"\n nuget.exe pack $_ -Build -Symbols -outputdirectory $outputDir -Properties Configuration=Release\n}"
},
{
"from": "gpt",
"value": "$scriptDir = $MyInvocation.MyCommand.Path | split-path\n$outputDir = \"$scriptDir\\BuildOutput\"\n\nmd $outputDir -f | out-null\ndel $outputDir\\*\n\ngci $scriptDir -include Regalo.Core.csproj,Regalo.RavenDB.csproj,Regalo.SqlServer.csproj,Regalo.Testing.csproj,Regalo.ObjectCompare.csproj -recurse | %{ \n Write-Host -ForegroundColor Green \"$_\"\n nuget.exe pack $_ -Build -Symbols -outputdirectory $outputDir -Properties Configuration=Release\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update install root for package\n"
},
{
"from": "human",
"value": "$packageName = 'PneumaticTube.portable' \n$url = 'https://github.com/hartez/PneumaticTube/releases/download/1.0.0/PneumaticTube.zip' \n\ntry { \n $binRoot = \"$env:systemdrive\\tools\"\n if($env:chocolatey_bin_root -ne $null -and $env:chocolatey_bin_root -notlike '*:\\*'){$binRoot = join-path $env:systemdrive $env:chocolatey_bin_root}\n $installDir = Join-Path $binRoot \"$packageName\"\n Write-Host \"Adding `'$installDir`' to the path and the current shell path\"\n Install-ChocolateyPath \"$installDir\"\n $env:Path = \"$($env:Path);$installDir\"\n \n Install-ChocolateyZipPackage \"$packageName\" \"$url\" \"$installDir\"\n \n Write-ChocolateySuccess \"$packageName\"\n} catch {\n Write-ChocolateyFailure \"$packageName\" \"$($_.Exception.Message)\"\n throw \n}"
},
{
"from": "gpt",
"value": "$packageName = 'PneumaticTube.portable' \n$url = 'https://github.com/hartez/PneumaticTube/releases/download/1.0.0/PneumaticTube.zip' \n\ntry { \n $binRoot = Get-BinRoot\n $installDir = Join-Path $binRoot \"$packageName\"\n Write-Host \"Adding `'$installDir`' to the path and the current shell path\"\n Install-ChocolateyPath \"$installDir\"\n $env:Path = \"$($env:Path);$installDir\"\n \n Install-ChocolateyZipPackage \"$packageName\" \"$url\" \"$installDir\"\n \n Write-ChocolateySuccess \"$packageName\"\n} catch {\n Write-ChocolateyFailure \"$packageName\" \"$($_.Exception.Message)\"\n throw \n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Copy all the files from sdl develop libraries\n\n"
},
{
"from": "human",
"value": "#Download SDL\nStart-FileDownload \"https://www.libsdl.org/release/SDL2-devel-2.0.5-VC.zip\" -FileName \"${env:Temp}\\sdl2.zip\"\n\nAdd-Type -AssemblyName System.IO.Compression.FileSystem\nfunction Unzip\n{\n param([string]$zipfile, [string]$outpath)\n\n [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)\n}\n\nUnzip \"${env:Temp}\\sdl2.zip\" \"${env:Temp}\\sdl2\"\n\n\nif (-Not (Test-Path \"msvc\\lib\\\"))\n{\n md -path \"msvc\\lib\\\"\n}\n\nCopy-Item \"${env:Temp}\\sdl2\\SDL2-2.0.5\\lib\\*\" \"msvc\\lib\\\"\nfunction GetFiles($path = $pwd, [string[]]$exclude)\n{\n foreach ($item in Get-ChildItem $path)\n {\n if ($exclude | Where {$item -like $_}) { continue }\n\n $item\n if (Test-Path $item.FullName -PathType Container)\n {\n GetFiles $item.FullName $exclude\n }\n }\n}\n\nGetFiles(\"msvc\\lib\\\")"
},
{
"from": "gpt",
"value": "#Download SDL\nStart-FileDownload \"https://www.libsdl.org/release/SDL2-devel-2.0.5-VC.zip\" -FileName \"${env:Temp}\\sdl2.zip\"\n\nAdd-Type -AssemblyName System.IO.Compression.FileSystem\nfunction Unzip\n{\n param([string]$zipfile, [string]$outpath)\n\n [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)\n}\n\nUnzip \"${env:Temp}\\sdl2.zip\" \"${env:Temp}\\sdl2\"\n\n\nif (-Not (Test-Path \"msvc\\lib\\\"))\n{\n md -path \"msvc\\lib\\\"\n}\n\nCopy-Item \"${env:Temp}\\sdl2\\SDL2-2.0.5\\lib\\*\" \"msvc\\lib\\\" -Recurse\nfunction GetFiles($path = $pwd, [string[]]$exclude)\n{\n foreach ($item in Get-ChildItem $path)\n {\n if ($exclude | Where {$item -like $_}) { continue }\n\n $item\n if (Test-Path $item.FullName -PathType Container)\n {\n GetFiles $item.FullName $exclude\n }\n }\n}\n\nGetFiles(\"msvc\\lib\\\")"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add slnf support to powershell local framework script\n"
},
{
"from": "human",
"value": "# Run this script to use a local copy of osu-framework rather than fetching it from nuget.\n# It expects the osu-framework directory to be at the same level as the osu directory\n#\n# https://github.com/ppy/osu-framework/wiki/Testing-local-framework-checkout-with-other-projects\n\n$CSPROJ=\"osu.Game/osu.Game.csproj\"\n$SLN=\"osu.sln\"\n\ndotnet remove $CSPROJ package ppy.osu.Framework;\ndotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj;\ndotnet add $CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj\n"
},
{
"from": "gpt",
"value": "# Run this script to use a local copy of osu-framework rather than fetching it from nuget.\n# It expects the osu-framework directory to be at the same level as the osu directory\n#\n# https://github.com/ppy/osu-framework/wiki/Testing-local-framework-checkout-with-other-projects\n\n$CSPROJ=\"osu.Game/osu.Game.csproj\"\n$SLN=\"osu.sln\"\n\ndotnet remove $CSPROJ package ppy.osu.Framework;\ndotnet sln $SLN add ../osu-framework/osu.Framework/osu.Framework.csproj ../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj;\ndotnet add $CSPROJ reference ../osu-framework/osu.Framework/osu.Framework.csproj\n\n$SLNF=Get-Content \"osu.Desktop.slnf\" | ConvertFrom-Json\n$TMP=New-TemporaryFile\n$SLNF.solution.projects += (\"../osu-framework/osu.Framework/osu.Framework.csproj\", \"../osu-framework/osu.Framework.NativeLibs/osu.Framework.NativeLibs.csproj\")\nConvertTo-Json $SLNF | Out-File $TMP -Encoding UTF8\nMove-Item -Path $TMP -Destination \"osu.Desktop.slnf\" -Force\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix path to nuspec ps\n"
},
{
"from": "human",
"value": "$root = $env:APPVEYOR_BUILD_FOLDER\n$versionStr = $env:APPVEYOR_BUILD_VERSION\n\nWrite-Host $root\nWrite-Host \"Setting .nuspec version tag to $versionStr\"\n\n$content = (Get-Content $root\\source\\IdentityServer3.ElasticSearchEventService\\IdentityServer3.ElasticSearchEventService.nuspec) \n$content = $content -replace '\\$version\\$',$versionStr\n\n$content | Out-File $root\\source\\IdentityServer3.ElasticSearchEventService\\IdentityServer3.ElasticSearchEventService.nuspec\n"
},
{
"from": "gpt",
"value": "$root = $env:APPVEYOR_BUILD_FOLDER\n$versionStr = $env:APPVEYOR_BUILD_VERSION\n\nWrite-Host $root\nWrite-Host \"Setting .nuspec version tag to $versionStr\"\n\n$content = (Get-Content $root\\source\\IdentityServer3.Localization\\IdentityServer3.Localization.nuspec) \n$content = $content -replace '\\$version\\$',$versionStr\n\n$content | Out-File $root\\source\\IdentityServer3.Localization\\IdentityServer3.Localization.nuspec\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add npm build and open shortcuts\n"
},
{
"from": "human",
"value": "# Install into $HOME\\Documents\\WindowsPowerShell\n\nSet-Alias g git\nSet-Alias n npm\n\nfunction ns {npm start}\nfunction ncb {npm run clean; npm run build}\nfunction nr {Param($task) npm run $task}\n\nfunction nip {cd $HOME\\code\\nip}\nfunction home {cd $HOME}\n"
},
{
"from": "gpt",
"value": "# Install into $HOME\\Documents\\WindowsPowerShell\n\nSet-Alias g git\nSet-Alias n npm\n\nfunction ns {npm start}\nfunction ncb {npm run clean; npm run build}\nfunction nr {Param($task) npm run $task}\nfunction nb {npm run build}\n\nfunction nip {cd $HOME\\code\\nip}\nfunction home {cd $HOME}\nfunction open {ii $args} #file:// paths are ok, other url schemes didn't work\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Make sure repo is not dirty.\n"
},
{
"from": "human",
"value": "Write-Host \"\"\nWrite-Host \"Pulling the latest:\" -ForegroundColor Green\ngit pull\n\n# if(git status --porcelain | Where-Object {$_ -match '^\\?\\?'}){\n# throw \"Untracked files exist\"\n# exit \n# } \n# elseif(git status --porcelain | Where-Object {$_ -notmatch '^\\?\\?'}) {\n# throw \"Uncommitted changes\"\n# }\n\nPush-Location packages\n\n\n$dir = dir .\n$c = $dir.count\n$c += 1\n\nforeach ($d in $dir){\n\n $i = $dir.IndexOf($d)\n $i += 1\n \n Push-Location $d\n Write-Host \"\"\n Write-Host \"($i/$c) Upgrading ste-events:\" -ForegroundColor Yellow\n npx npm-check-updates -u\n npm install\n npm audit fix\n Pop-Location\n}\n\nPop-Location\n\nWrite-Host \"\"\nWrite-Host \"($c/$c) Upgrading root\" -ForegroundColor Yellow\n\nnpx npm-check-updates -u\nnpm install\nnpm audit fix\n\nWrite-Host \"\"\nWrite-Host \"Building & testing:\" -ForegroundColor Green\n\nnpm install\nnpm run build\nnpm test\n\nWrite-Host \"\"\nWrite-Host \"Commit to Git\" -ForegroundColor Yellow\n\ngit add .\ngit commit -m \"Packages upgrade\" -ForegroundColor Green\ngit push\n\nWrite-Host \"\" -ForegroundColor Yellow\nWrite-Host \"Publish\" -ForegroundColor Yellow\nnpm run make\n\nWrite-Host \"\"\nWrite-Host \"Ready!\" -ForegroundColor Green"
},
{
"from": "gpt",
"value": "Write-Host \"\"\nWrite-Host \"Pulling the latest:\" -ForegroundColor Green\ngit pull\n\nif(git status --porcelain | Where-Object {$_ -match '^\\?\\?'}){\n throw \"Untracked files exist\"\n exit \n} \nelseif(git status --porcelain | Where-Object {$_ -notmatch '^\\?\\?'}) {\n throw \"Uncommitted changes\"\n}\n\nPush-Location packages\n\n\n$dir = dir .\n$c = $dir.count\n$c += 1\n\nforeach ($d in $dir){\n\n $i = $dir.IndexOf($d)\n $i += 1\n \n Push-Location $d\n Write-Host \"\"\n Write-Host \"($i/$c) Upgrading ste-events:\" -ForegroundColor Yellow\n npx npm-check-updates -u\n npm install\n npm audit fix\n Pop-Location\n}\n\nPop-Location\n\nWrite-Host \"\"\nWrite-Host \"($c/$c) Upgrading root\" -ForegroundColor Yellow\n\nnpx npm-check-updates -u\nnpm install\nnpm audit fix\n\nWrite-Host \"\"\nWrite-Host \"Building & testing:\" -ForegroundColor Green\n\nnpm install\nnpm run build\nnpm test\n\nWrite-Host \"\"\nWrite-Host \"Commit to Git\" -ForegroundColor Yellow\n\ngit add .\ngit commit -m \"Packages upgrade\" -ForegroundColor Green\ngit push\n\nWrite-Host \"\" -ForegroundColor Yellow\nWrite-Host \"Publish\" -ForegroundColor Yellow\nnpm run make\n\nWrite-Host \"\"\nWrite-Host \"Ready!\" -ForegroundColor Green"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove -Confirm flag from test\n"
},
{
"from": "human",
"value": "function Start-Test\r\n{\r\n Import-Module -Name (Join-Path $TestDir 'RivetTest') -ArgumentList 'ForcePop' \r\n Start-RivetTest\r\n}\r\n\r\nfunction Stop-Test\r\n{\r\n Stop-RivetTest\r\n Remove-Module RivetTest\r\n}\r\n\r\nfunction Test-ForcePop\r\n{\r\n\r\n @'\r\nfunction Push-Migration\r\n{\r\n Add-Table -Name 'Foobar1' -Column {\r\n DateTime2 'id' -Precision 6\r\n } -Option 'data_compression = none'\r\n\r\n}\r\n\r\nfunction Pop-Migration\r\n{\r\n Remove-Table -Name 'Foobar1'\r\n}\r\n\r\n'@ | New-Migration -Name 'A'\r\n\r\nStart-Sleep -Seconds 1\r\n\r\n @'\r\nfunction Push-Migration\r\n{\r\n Add-Table -Name 'Foobar2' -Column {\r\n DateTime2 'id' -Precision 6\r\n } -Option 'data_compression = none'\r\n\r\n\r\n}\r\n\r\nfunction Pop-Migration\r\n{\r\n Remove-Table -Name 'Foobar2'\r\n}\r\n\r\n'@ | New-Migration -Name 'B'\r\n\r\n Invoke-Rivet -Push 'A' -Confirm\r\n Invoke-Rivet -Push 'B'\r\n \r\n Invoke-Rivet -Force\r\n \r\n Assert-False (Test-Table 'Foobar1')\r\n Assert-False (Test-Table 'Foobar2')\r\n}"
},
{
"from": "gpt",
"value": "function Start-Test\r\n{\r\n Import-Module -Name (Join-Path $TestDir 'RivetTest') -ArgumentList 'ForcePop' \r\n Start-RivetTest\r\n}\r\n\r\nfunction Stop-Test\r\n{\r\n Stop-RivetTest\r\n Remove-Module RivetTest\r\n}\r\n\r\nfunction Test-ForcePop\r\n{\r\n\r\n @'\r\nfunction Push-Migration\r\n{\r\n Add-Table -Name 'Foobar1' -Column {\r\n DateTime2 'id' -Precision 6\r\n } -Option 'data_compression = none'\r\n\r\n}\r\n\r\nfunction Pop-Migration\r\n{\r\n Remove-Table -Name 'Foobar1'\r\n}\r\n\r\n'@ | New-Migration -Name 'A'\r\n\r\nStart-Sleep -Seconds 1\r\n\r\n @'\r\nfunction Push-Migration\r\n{\r\n Add-Table -Name 'Foobar2' -Column {\r\n DateTime2 'id' -Precision 6\r\n } -Option 'data_compression = none'\r\n\r\n\r\n}\r\n\r\nfunction Pop-Migration\r\n{\r\n Remove-Table -Name 'Foobar2'\r\n}\r\n\r\n'@ | New-Migration -Name 'B'\r\n\r\n Invoke-Rivet -Push 'A'\r\n Invoke-Rivet -Push 'B'\r\n \r\n Invoke-Rivet -Force\r\n \r\n Assert-False (Test-Table 'Foobar1')\r\n Assert-False (Test-Table 'Foobar2')\r\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix powershell null comparison warning\n"
},
{
"from": "human",
"value": "$pacname = $args[0]\nif ($pacname -eq $null)\n{\n $pacname = (Get-PackageName)\n}\nadb shell monkey -p $pacname -c android.intent.category.LAUNCHER 1\n# adb shell am start -n \"$pacname/com.unity3d.player.UnityPlayerActivity\"\n"
},
{
"from": "gpt",
"value": "$pacname = $args[0]\nif ($null -eq $pacname)\n{\n $pacname = (Get-PackageName)\n}\nadb shell monkey -p $pacname -c android.intent.category.LAUNCHER 1\n# adb shell am start -n \"$pacname/com.unity3d.player.UnityPlayerActivity\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix 'UnitTests' task to invoke Pester just once\n"
},
{
"from": "human",
"value": "#Requires -Modules 'InvokeBuild'\nParam (\n [string]$BuildOutput = \"$PSScriptRoot\\BuildOutput\",\n\n [string[]]$Dependency = @('Coveralls','Pester','PsScriptAnalyzer')\n)\n\nFunction Write-TaskBanner ( [string]$TaskName )\n{\n \"`n\" + ('-' * 79) + \"`n\" + \"`t`t`t $TaskName `n\" + ('-' * 79) + \"`n\"\n}\n\ntask Clean {\n Write-TaskBanner -TaskName $Task.Name\n\n If (Test-Path -Path $BuildOutput) {\n \"Removing existing files and folders in $BuildOutput\\\"\n Get-ChildItem .\\BuildOutput\\ | Remove-Item -Force -Recurse\n }\n Else {\n \"$BuildOutput is not present, nothing to clean up.\"\n New-Item -ItemType Directory -Path $BuildOutput\n }\n}\n\ntask InstallDependencies {\n Write-TaskBanner -TaskName $Task.Name\n\n Foreach ( $Depend in $Script:Dependency ) {\n Install-Module $Depend -Scope CurrentUser -Force\n Import-Module $Depend -Force\n }\n}\n\ntask UnitTests {\n Write-TaskBanner -TaskName $Task.Name\n\n $UnitTestParams = @{\n Script = '.\\Tests'\n CodeCoverage = '.\\PSCodeHealth\\P*\\*'\n OutputFile = 'UnitTestsResult.xml'\n PassThru = $True\n }\n $Script:UnitTestsResult = Invoke-Pester @UnitTestParams\n $TestsOutput = Invoke-Pester -Script '.\\Tests' -CodeCoverage '.\\PSCodeHealth\\P*\\*' -OutputFile TestResults.xml -PassThru\n\n}\n\n# Default task : runs all tasks\ntask . Clean, InstallDependencies, UnitTests"
},
{
"from": "gpt",
"value": "#Requires -Modules 'InvokeBuild'\nParam (\n [string]$BuildOutput = \"$PSScriptRoot\\BuildOutput\",\n\n [string[]]$Dependency = @('Coveralls','Pester','PsScriptAnalyzer')\n)\n\nFunction Write-TaskBanner ( [string]$TaskName )\n{\n \"`n\" + ('-' * 79) + \"`n\" + \"`t`t`t $TaskName `n\" + ('-' * 79) + \"`n\"\n}\n\ntask Clean {\n Write-TaskBanner -TaskName $Task.Name\n\n If (Test-Path -Path $BuildOutput) {\n \"Removing existing files and folders in $BuildOutput\\\"\n Get-ChildItem .\\BuildOutput\\ | Remove-Item -Force -Recurse\n }\n Else {\n \"$BuildOutput is not present, nothing to clean up.\"\n $Null = New-Item -ItemType Directory -Path $BuildOutput\n }\n}\n\ntask InstallDependencies {\n Write-TaskBanner -TaskName $Task.Name\n\n Foreach ( $Depend in $Script:Dependency ) {\n Install-Module $Depend -Scope CurrentUser -Force\n Import-Module $Depend -Force\n }\n}\n\ntask UnitTests {\n Write-TaskBanner -TaskName $Task.Name\n\n $UnitTestParams = @{\n Script = '.\\Tests'\n CodeCoverage = '.\\PSCodeHealth\\P*\\*'\n OutputFile = 'UnitTestsResult.xml'\n PassThru = $True\n }\n $Script:UnitTestsResult = Invoke-Pester @UnitTestParams\n}\n\n# Default task : runs all tasks\ntask . Clean, InstallDependencies, UnitTests"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove module loading from vlan script\n"
},
{
"from": "human",
"value": "#Requires -Modules VagrantMessages\n\nparam (\n [parameter (Mandatory=$true)]\n [string]$VmId,\n [parameter (Mandatory=$true)]\n [int]$VlanId\n)\n\n# Include the following modules\n$presentDir = Split-Path -parent $PSCommandPath\n$modules = @()\n$modules += $presentDir + \"\\utils\\write_messages.ps1\"\nforEach ($module in $modules) { . $module }\n\ntry {\n $vm = Hyper-V\\Get-VM -Id $VmId -ErrorAction \"stop\"\n Hyper-V\\Set-VMNetworkAdapterVlan $vm -Access -Vlanid $VlanId\n}\ncatch {\n Write-ErrorMessage \"Failed to set VM's Vlan ID $_\"\n}\n"
},
{
"from": "gpt",
"value": "#Requires -Modules VagrantMessages\n\nparam (\n [parameter (Mandatory=$true)]\n [string]$VmId,\n [parameter (Mandatory=$true)]\n [int]$VlanId\n)\n\ntry {\n $vm = Hyper-V\\Get-VM -Id $VmId -ErrorAction \"stop\"\n Hyper-V\\Set-VMNetworkAdapterVlan $vm -Access -Vlanid $VlanId\n}\ncatch {\n Write-ErrorMessage \"Failed to set VM's Vlan ID $_\"\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add patch version number script\n"
},
{
"from": "gpt",
"value": "param(\n [Parameter(Mandatory=$true)]\n [string]\n $projectFile,\n\n [Parameter(Mandatory=$true)]\n [string]\n $version \n)\n\ntrap \n{ \n write-output $_ \n exit 1 \n} \n\nif (-Not (Test-Path $projectFile)) {\n throw \"Could not file project file '$projectFile'\"\n}\n\n$object = Get-Content $projectFile | ConvertFrom-Json\n$object.version = $version\n$object | ConvertTo-Json -Depth 20 | Set-Content $projectFile"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "build: Change location to script's directory\n"
},
{
"from": "human",
"value": "sv version $env:APPVEYOR_BUILD_NUMBER\nsv version 9999.0.$version-nightly\n.\\build-version.ps1 $version\n"
},
{
"from": "gpt",
"value": "$scriptpath = $MyInvocation.MyCommand.Path\n$dir = Split-Path $scriptpath\nPush-Location $dir\n\nsv version $env:APPVEYOR_BUILD_NUMBER\nsv version 9999.0.$version-nightly\n.\\build-version.ps1 $version\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix invalid PSAvoidUsingCmdletAliases rule name in settings\n"
},
{
"from": "human",
"value": "# The PowerShell Script Analyzer will generate a warning\n# diagnostic record for this file due to a bug -\n# https://github.com/PowerShell/PSScriptAnalyzer/issues/472\n@{\n # Only diagnostic records of the specified severity will be generated.\n # Uncomment the following line if you only want Errors and Warnings but\n # not Information diagnostic records.\n #Severity = @('Error','Warning')\n\n # Analyze **only** the following rules. Use IncludeRules when you want\n # to invoke only a small subset of the defualt rules.\n IncludeRules = @('PSAvoidDefaultValueSwitchParameter',\n 'PSMisleadingBacktick',\n 'PSMissingModuleManifestField',\n 'PSReservedCmdletChar',\n 'PSReservedParams',\n 'PSShouldProcess',\n 'PSUseApprovedVerbs',\n 'PSAvoidUsingAliases',\n 'PSUseDeclaredVarsMoreThanAssigments')\n\n # Do not analyze the following rules. Use ExcludeRules when you have\n # commented out the IncludeRules settings above and want to include all\n # the default rules except for those you exclude below.\n # Note: if a rule is in both IncludeRules and ExcludeRules, the rule\n # will be excluded.\n #ExcludeRules = @('PSAvoidUsingWriteHost')\n}\n"
},
{
"from": "gpt",
"value": "# The PowerShell Script Analyzer will generate a warning\n# diagnostic record for this file due to a bug -\n# https://github.com/PowerShell/PSScriptAnalyzer/issues/472\n@{\n # Only diagnostic records of the specified severity will be generated.\n # Uncomment the following line if you only want Errors and Warnings but\n # not Information diagnostic records.\n #Severity = @('Error','Warning')\n\n # Analyze **only** the following rules. Use IncludeRules when you want\n # to invoke only a small subset of the defualt rules.\n IncludeRules = @('PSAvoidDefaultValueSwitchParameter',\n 'PSMisleadingBacktick',\n 'PSMissingModuleManifestField',\n 'PSReservedCmdletChar',\n 'PSReservedParams',\n 'PSShouldProcess',\n 'PSUseApprovedVerbs',\n 'PSAvoidUsingCmdletAliases',\n 'PSUseDeclaredVarsMoreThanAssigments')\n\n # Do not analyze the following rules. Use ExcludeRules when you have\n # commented out the IncludeRules settings above and want to include all\n # the default rules except for those you exclude below.\n # Note: if a rule is in both IncludeRules and ExcludeRules, the rule\n # will be excluded.\n #ExcludeRules = @('PSAvoidUsingWriteHost')\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add expID as a parameter\n"
},
{
"from": "human",
"value": "#\n#\nparam (\n\t[string] $drive = \"Y\",\n [string] $solutionPath = \"LongTest2\",\n\t[string] $solutionName = \"LongTest2\",\n\t[int] $machines = 1,\n\t[int] $numberOfMethods = 100\n\t)\n\n# http://orleansservicedg.cloudapp.net:8080/api/Experiments?drive=Y&solutionPath=LongTest2&solutionName=LongTest2&machines=1\n\nif($env:ISEMULATED -ne $true) {\n\t$port = \"45002\"\n\t$resource = \"http://orleansservicedg.cloudapp.net:\"+$port+\"/\"\n}\nelse\n{\n\t$resource = \"http://localhost:49176/\"\n\t$drive = \"C\"\n\t$solutionPath = \"\\Users\\diegog\\Source\\Repos\\Call-Graph-Builder-DotNet\\TestsSolutions\\\" + $solutionPath\n}\n$controler=\"api/Experiments\"\n$cmd = \"?drive=\"+$drive+\"&solutionPath=\"+$solutionPath+\"&solutionName=\"+$solutionName+\"&machines=\"+$machines <#+\"&numberOfMethods=\"+$numberOfMethods#>\n$uri = $resource+$controler+$cmd\nWrite-Host \"Invoking\" $uri\nInvoke-WebRequest -Uri $uri -TimeoutSec 5000 "
},
{
"from": "gpt",
"value": "#\n#\nparam (\n\t[string] $drive = \"Y\",\n [string] $solutionPath = \"LongTest2\",\n\t[string] $solutionName = \"LongTest2\",\n\t[int] $machines = 1,\n\t[string] expID= \"\",\n\t[int] $numberOfMethods = 100\n\t)\n\n# http://orleansservicedg.cloudapp.net:8080/api/Experiments?drive=Y&solutionPath=LongTest2&solutionName=LongTest2&machines=1\n\nif($env:ISEMULATED -ne $true) {\n\t$port = \"45002\"\n\t$resource = \"http://orleansservicedg.cloudapp.net:\"+$port+\"/\"\n}\nelse\n{\n\t$resource = \"http://localhost:49176/\"\n\t$drive = \"C\"\n\t$solutionPath = \"\\Users\\diegog\\Source\\Repos\\Call-Graph-Builder-DotNet\\TestsSolutions\\\" + $solutionPath\n}\n$controler=\"api/Experiments\"\n$cmd = \"?drive=\"+$drive+\"&solutionPath=\"+$solutionPath+\"&solutionName=\"+$solutionName+\"&machines=\"+$machines+\"&expID=\"+$expID <#+\"&numberOfMethods=\"+$numberOfMethods#>\n$uri = $resource+$controler+$cmd\nWrite-Host \"Invoking\" $uri\nInvoke-WebRequest -Uri $uri -TimeoutSec 5000 "
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Support other version bump types\n"
},
{
"from": "human",
"value": "$me = $MyInvocation.MyCommand.Definition;\n\nfunction Update-Version\n{\n param([string] $path)\n\n $xml = [xml](Get-Content $path)\n $versionAttr = $xml.DocumentElement['Metadata']['Identity'].Attributes['Version']\n $oldVersion = $versionAttr.Value\n $parts = $oldVersion.Split('.');\n $parts[3] = ([convert]::ToInt32($parts[3]) + 1).ToString()\n $newVersion = [string]::Join('.', $parts)\n Write-Host \"Updated\" ([IO.Path]::GetFileName([IO.Path]::GetDirectoryName($path))) \"from\" $oldVersion \"to\" $newVersion\n $versionAttr.Value = $newVersion\n $xml.Save($path)\n}\n\nfunction Update-Manifest\n{\n param([string] $name)\n $path = [IO.Path]::Combine($me, '..\\..\\Nodejs\\Product\\', $name, 'source.extension.vsixmanifest')\n Update-Version $path\n}\n\nUpdate-Manifest 'InteractiveWindow'\nUpdate-Manifest 'NodeJs'\nUpdate-Manifest 'Profiling'\n"
},
{
"from": "gpt",
"value": "param (\n [string]$bump = \"build\" # or 'revision' or 'minor' or 'major'\n )\n\n$me = $MyInvocation.MyCommand.Definition;\n\nfunction Update-Version\n{\n param([string] $path)\n\n $xml = [xml](Get-Content $path)\n $versionAttr = $xml.DocumentElement['Metadata']['Identity'].Attributes['Version']\n $oldVersion = $versionAttr.Value\n $parts = $oldVersion.Split('.');\n $incrementIndex = -1;\n switch($bump) {\n \"build\" {\n $incrementIndex = 3 \n }\n \"revision\" {\n $incrementIndex = 2\n $parts[3] = \"0\"\n }\n \"minor\" {\n $incrementIndex = 1\n $parts[3] = $parts[2] = \"0\"\n }\n \"major\" {\n $incrementIndex = 0\n $parts[3] = $parts[2] = $parts[1] = \"0\"\n }\n default {\n Write-Host 'Must specify \"build\", \"revision\", \"minor\", or \"major\"'\n exit 1\n }\n }\n $parts[$incrementIndex] = ([convert]::ToInt32($parts[$incrementIndex]) + 1).ToString()\n $newVersion = [string]::Join('.', $parts)\n Write-Host \"Updated\" ([IO.Path]::GetFileName([IO.Path]::GetDirectoryName($path))) \"from\" $oldVersion \"to\" $newVersion\n $versionAttr.Value = $newVersion\n $xml.Save($path)\n}\n\nfunction Update-Manifest\n{\n param([string] $name)\n $path = [IO.Path]::Combine($me, '..\\..\\Nodejs\\Product\\', $name, 'source.extension.vsixmanifest')\n Update-Version $path\n}\n\nUpdate-Manifest 'InteractiveWindow'\nUpdate-Manifest 'NodeJs'\nUpdate-Manifest 'Profiling'\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use default script for self signing.\n"
},
{
"from": "human",
"value": "$cert = New-SelfSignedCertificate -DnsName (\"localtest.me\",\"*.localtest.me\") -CertStoreLocation cert:\\LocalMachine\\My\n$rootStore = Get-Item cert:\\LocalMachine\\Root\n$rootStore.Open(\"ReadWrite\")\n$rootStore.Add($cert)\n$rootStore.Close();\nImport-Module WebAdministration\nSet-Location IIS:\\SslBindings\nNew-WebBinding -Name \"Kitos\" -IP \"*\" -Port 44300 -Protocol https\n$cert | New-Item 0.0.0.0!44300"
},
{
"from": "gpt",
"value": "$cert = New-SelfSignedCertificate -DnsName (\"localtest.me\",\"*.localtest.me\") -CertStoreLocation cert:\\LocalMachine\\My\n$rootStore = Get-Item cert:\\LocalMachine\\Root\n$rootStore.Open(\"ReadWrite\")\n$rootStore.Add($cert)\n$rootStore.Close();\nImport-Module WebAdministration\nSet-Location IIS:\\SslBindings\nNew-WebBinding -Name \"Default Web Site\" -IP \"*\" -Port 443 -Protocol https\n$cert | New-Item 0.0.0.0!443\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Refactor run-tests.ps1 to use selected scripts instead testnames\n"
},
{
"from": "human",
"value": "<#\n.SYNOPSIS\nThis script invokes all pester tests.\n#>\n\nparam(\n [string[]]$SelectedTests\n)\n\n$srcDir = Split-Path $PSScriptRoot -Parent;\n$pester = (Get-Item \"$srcDir\\packages\\pester.*\\tools\\Pester.psm1\" | Select-Object -Last 1 -ExpandProperty FullName);\n\nif (-not (Test-Path $pester -PathType Leaf))\n{\n Write-Error \"The pester module is missing.\";\n}\n\nImport-Module $pester;\ntry\n{\n Push-Location $PSScriptRoot;\n if ($Tests.Length -gt 0) \n { Invoke-Pester -TestName $SelectedTests; }\n else \n { Invoke-Pester; } \n}\nfinally\n{\n Pop-Location;\n if (Get-Module pester) { Remove-Module pester; }\n}"
},
{
"from": "gpt",
"value": "<#\n.SYNOPSIS\nThis script invokes all pester tests.\n#>\n\nparam(\n [string[]]$SelectedTests\n)\n\n$srcDir = Split-Path $PSScriptRoot -Parent;\n$pester = (Get-Item \"$srcDir\\packages\\pester.*\\tools\\Pester.psm1\" | Select-Object -Last 1 -ExpandProperty FullName);\n\nif (-not (Test-Path $pester -PathType Leaf))\n{\n Write-Error \"The pester module is missing.\";\n}\n\nImport-Module $pester;\ntry\n{\n Push-Location $PSScriptRoot;\n if ($Tests.Length -gt 0) \n { Invoke-Pester -Script $SelectedTests; }\n else \n { Invoke-Pester; } \n}\nfinally\n{\n Pop-Location;\n if (Get-Module pester) { Remove-Module pester; }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add settings for Stroustrup style.\n\nThis is a copy of OTBS with just the PlaceOpenBrace.OnSameLine set to $false.\n"
},
{
"from": "gpt",
"value": "# Inspired by http://eslint.org/docs/rules/brace-style#stroustrup\n@{\n IncludeRules = @(\n 'PSPlaceOpenBrace',\n 'PSPlaceCloseBrace',\n 'PSUseConsistentWhitespace',\n 'PSUseConsistentIndentation',\n 'PSAlignAssignmentStatement'\n )\n\n Rules = @{\n PSPlaceOpenBrace = @{\n Enable = $true\n OnSameLine = $false\n NewLineAfter = $true\n IgnoreOneLineBlock = $true\n }\n\n PSPlaceCloseBrace = @{\n Enable = $true\n NewLineAfter = $false\n IgnoreOneLineBlock = $true\n NoEmptyLineBefore = $false\n }\n\n PSUseConsistentIndentation = @{\n Enable = $true\n IndentationSize = 4\n }\n\n PSUseConsistentWhitespace = @{\n Enable = $true\n CheckOpenBrace = $true\n CheckOpenParen = $true\n CheckOperator = $true\n CheckSeparator = $true\n }\n\n PSAlignAssignmentStatement = @{\n Enable = $true\n CheckHashtable = $true\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add PS script for DB creation\n"
},
{
"from": "gpt",
"value": "#Variables\n$Image= \"mcr.microsoft.com/mssql/server:2017-CU9-ubuntu\"\n$Container = \"HomebankDevSqlServer\"\n$Password = \"H0mebankPassw0rd!\"\n$Database = \"Homebank\"\n\n#The first item is the header row so check for == 2\nif((docker ps -f name=$Container).Count -eq 2){\n docker stop $Container\n docker rm $Container\n}\n\n#The first item is the header row so check for == 1\nif((docker image ls $Image).Count -eq 1){\n docker pull $Image\n}\n\n#Start container\ndocker run --name $Container -e \"ACCEPT_EULA=Y\" -e \"SA_PASSWORD=$Password\" -e \"MSSQL_PID=Standard\" -p 1433:1433 -d $Image\n\n#Create DB\ndocker exec -it $Container /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $Password -Q \"CREATE DATABASE $Database\" -l 60"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add the -pre suffix if not from master\n"
},
{
"from": "human",
"value": "$root = (split-path -parent $MyInvocation.MyCommand.Definition)\n$lib = \"$root\\.package\\lib\\45\\\"\nIf (Test-Path $lib)\n{\n\tRemove-Item $lib -recurse\n}\nnew-item -Path $lib -ItemType directory\nnew-item -Path $root\\.nupkg -ItemType directory -force\nCopy-Item $root\\Idunn.SqlServer.Console\\bin\\Debug\\* $lib\n\nWrite-Host \"Setting .nuspec version tag to $env:GitVersion_NuGetVersion\"\n\n$content = (Get-Content $root\\Idunn.SqlServer.nuspec -Encoding UTF8) \n$content = $content -replace '\\$version\\$',$env:GitVersion_NuGetVersion\n\n$content | Out-File $root\\.package\\Idunn.SqlServer.compiled.nuspec -Encoding UTF8\n\n& NuGet.exe pack $root\\.package\\Idunn.SqlServer.compiled.nuspec -Version $env:GitVersion_NuGetVersion -OutputDirectory $root\\.nupkg\n"
},
{
"from": "gpt",
"value": "$root = (split-path -parent $MyInvocation.MyCommand.Definition)\n$lib = \"$root\\.package\\lib\\45\\\"\nif (Test-Path $lib)\n{\n\tRemove-Item $lib -recurse\n}\nnew-item -Path $lib -ItemType directory\nnew-item -Path $root\\.nupkg -ItemType directory -force\nCopy-Item $root\\Idunn.SqlServer.Console\\bin\\Debug\\* $lib\n\n$version = $env:GitVersion_NuGetVersion\nif ($env:APPVEYOR_REPO_BRANCH -ne \"master\")\n{\n $version += '-pre'\n}\nWrite-Host \"Setting .nuspec version tag to $version\"\n\n$content = (Get-Content $root\\Idunn.SqlServer.nuspec -Encoding UTF8) \n$content = $content -replace '\\$version\\$',$version\n\n$content | Out-File $root\\.package\\Idunn.SqlServer.compiled.nuspec -Encoding UTF8\n\n& NuGet.exe pack $root\\.package\\Idunn.SqlServer.compiled.nuspec -Version $version -OutputDirectory $root\\.nupkg\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add a script to find Program IDs usable in COM\n"
},
{
"from": "gpt",
"value": "# Source: https://blogs.msdn.microsoft.com/powershell/2009/03/20/get-progid/\nfunction Get-ProgID {\n #.Synopsis\n # Gets all of the ProgIDs registered on a system\n #.Description\n # Gets all ProgIDs registered on the system. The ProgIDs returned can be used with New-Object -comObject\n #.Example\n # Get-ProgID\n #.Example\n # Get-ProgID | Where-Object { $_.ProgID -like \"*Image*\" }\n param()\n $paths = @(\"REGISTRY::HKEY_CLASSES_ROOT\\CLSID\")\n if ($env:Processor_Architecture -eq \"amd64\") {\n $paths+=\"REGISTRY::HKEY_CLASSES_ROOT\\Wow6432Node\\CLSID\"\n }\n Get-ChildItem $paths -include VersionIndependentPROGID -recurse | \n Select-Object @{\n Name='ProgID'\n Expression={$_.GetValue(\"\")} \n }, @{\n Name='32Bit'\n Expression={\n if ($env:Processor_Architecture -eq \"amd64\") {\n $_.PSPath.Contains(\"Wow6432Node\")\n } else {\n $true\n }\n }\n }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add Microsoft Azure Storage Explorer to o365/azure setup\n"
},
{
"from": "human",
"value": "#Script Name: New-EasyDevWorkstation.ps1\n#Purpose: Quick and clean way to setup a simple developer workstation. Tested only for Windows 10\n#Author Nissan Dookeran\n#Date 23-06-2016\n#Version 0.01\n\n#set the execution policy to allow chocolatey to install and chocolatey scripts to install software\nSet-ExecutionPolicy RemoteSigned\n\n#install chocolatey\niwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex\nrefreshenv\n\n#Install the basics - Git, Chrome browser, updated Powershell (if running on older Windows like Win Server 2008R2)\n# Visual Studio Code (which is free), and latest SQL Server Management Studio (also free)\nchoco install -y --allow-empty-checksums git GoogleChrome powershell visualstudiocode sql-server-management-studio postman fiddler4\n"
},
{
"from": "gpt",
"value": "#Script Name: New-EasyDevWorkstation.ps1\n#Purpose: Quick and clean way to setup a simple developer workstation. Tested only for Windows 10\n#Author Nissan Dookeran\n#Date 23-06-2016\n#Version 0.01\n\n#set the execution policy to allow chocolatey to install and chocolatey scripts to install software\nSet-ExecutionPolicy RemoteSigned\n\n#install chocolatey\niwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex\nrefreshenv\n\n#Install the basics - Git, Chrome browser, updated Powershell (if running on older Windows like Win Server 2008R2)\n# Visual Studio Code (which is free), and latest SQL Server Management Studio (also free)\n# Microsoft Azure Storage Explorer\nchoco install -y --allow-empty-checksums git GoogleChrome powershell visualstudiocode sql-server-management-studio postman fiddler4 microsoftazurestorageexplorer\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add Invoke-Expression Pester Unit Test\n"
},
{
"from": "human",
"value": "Describe \"Invoke-Expression\" {\n\n Context \"Should execute the invoked command validly\" {\n\n\tIt \"Should return the echoed text\" {\n\t (Invoke-Expression -command \"echo pestertest1\") | Should be \"pestertest1\"\n\t}\n\n\tIt \"Should return the echoed text for the alias\" {\n\t (iex -command \"echo pestertest2\") | Should Be \"pestertest2\"\n\t}\n\n\tIt \"Should return the echoed text from a script\" {\n\t $testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1\n\t $testcommand = \"echo pestertestscript\"\n\t $testcommand | Add-Content -Path $testfile\n\t (Invoke-Expression $testfile) | Should Be \"pestertestscript\"\n\t Remove-Item $testfile\n\t}\n\n\tIt \"Should return the echoed text from a script from the alias\" {\n\t $testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1\n\t $testcommand = \"echo pestertestscript\"\n\t $testcommand | Add-Content -Path $testfile\n\t (iex $testfile) | Should Be \"pestertestscript\"\n\t Remove-Item $testfile\n\t}\n }\n}\n"
},
{
"from": "gpt",
"value": "Describe \"Invoke-Expression\" {\n\n Context \"Should execute the invoked command validly\" {\n\n\tIt \"Should return the echoed text\" {\n\t (Invoke-Expression -command \"echo pestertest1\") | Should be \"pestertest1\"\n\t}\n\n\tIt \"Should return the echoed text for the alias\" {\n\t (iex -command \"echo pestertest2\") | Should Be \"pestertest2\"\n\t}\n\n\tIt \"Should return the echoed text from a script\" {\n\t $testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1\n\t $testcommand = \"echo pestertestscript\"\n\t $testcommand | Add-Content -Path $testfile\n\t (Invoke-Expression $testfile) | Should Be \"pestertestscript\"\n\t Remove-Item $testfile\n\t}\n\n\tIt \"Should return the echoed text from a script from the alias\" {\n\t $testfile = Join-Path -Path (Join-Path $PSScriptRoot -ChildPath assets) -ChildPath echoscript.ps1\n\t $testcommand = \"echo pestertestscript\"\n\t $testcommand | Add-Content -Path $testfile\n\t (iex $testfile) | Should Be \"pestertestscript\"\n\t Remove-Item $testfile\n\t}\n }\n}\nDescribe \"Invoke-Expression DRT Unit Tests\" -Tags DRT{\n\tIt \"Invoke-Expression should work\"{\t\n\t\t$result=invoke-expression -Command 2+2\n\t\t$result|Should Be 4\n\t}\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add status to query and message\n"
},
{
"from": "human",
"value": "# Based on a conversation at the Seattle SWUG about using the API\n# to clean up non-up interfaces, this has been written/provided.\n\nImport-Module SwisPowerShell\n\n$OrionServer = 'localhost'\n$Username = 'admin'\n$Password = ''\n\n$swis = Connect-Swis -Hostname $OrionServer -Username $Username -Password $Password\n\n# query to get node name, interface name, and interface URI of each non-up\n# interface\n$query = \"\n SELECT\n Nodes.Caption AS NodeName\n ,Interfaces.Caption AS InterfaceName\n ,Interfaces.URI\n FROM Orion.Nodes AS Nodes\n JOIN Orion.NPM.Interfaces AS Interfaces ON Nodes.NodeID = Interfaces.NodeID\n WHERE Interfaces.Status != 1\n\"\n\n$results = Get-SwisData $swis $query\n\nforeach ($result in $results) {\n Write-Host (\"Deleting interface [{0}] from node [{1}] with status [{2}]\" -f $result.InterfaceName, $result.NodeName)\n\n # un-comment this line to do the actual deletion\n # Remove-SwisObject $swis $results.URI\n}\n"
},
{
"from": "gpt",
"value": "# Based on a conversation at the Seattle SWUG about using the API\n# to clean up non-up interfaces, this has been written/provided.\n\nImport-Module SwisPowerShell\n\n$OrionServer = 'localhost'\n$Username = 'admin'\n$Password = ''\n\n$swis = Connect-Swis -Hostname $OrionServer -Username $Username -Password $Password\n\n# query to get node name, interface name, and interface URI of each non-up\n# interface\n$query = \"\n SELECT\n Nodes.Caption AS NodeName\n ,Interfaces.Caption AS InterfaceName\n ,Interfaces.URI\n ,Interfaces.Status\n FROM Orion.Nodes AS Nodes\n JOIN Orion.NPM.Interfaces AS Interfaces ON Nodes.NodeID = Interfaces.NodeID\n WHERE Interfaces.Status != 1\n\"\n\n$results = Get-SwisData $swis $query\n\nforeach ($result in $results) {\n Write-Host (\"Deleting interface [{0}] from node [{1}] with status [{2}]\" -f $result.InterfaceName, $result.NodeName, $result.Status)\n\n # un-comment this line to do the actual deletion\n # Remove-SwisObject $swis $results.URI\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add a script to install vscode extensions\n"
},
{
"from": "gpt",
"value": "# Script to install extensions for Visual Studio Code\n\n# Install golang extensions\ncode --install-extension lukehoban.go\n\n# Install Python extensions\ncode --install-extension freakypie.code-python-isort\ncode --install-extension ms-python.python\ncode --install-extension njpwerner.autodocstring\n\n# Install C++ extensions\ncode --install-extension ms-vscode.cpptools\n\n# Install TypeScript extensions\ncode --install-extension eg2.tslint\n\n# Install PlantUML extensions\ncode --install-extension jebbs.plantuml\n\npause\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Improve running of tests during CI build.\n"
},
{
"from": "human",
"value": "$testProjects = Get-ChildItem test/HTTPlease*.csproj -File -Recurse\n\nForEach ($testProject In $testProjects) {\n\tdotnet test $testProject\n}\n"
},
{
"from": "gpt",
"value": "$testDir = Join-Path $PSScriptRoot 'test'\n$testProjects = Get-ChildItem $testDir -Recurse -File -Filter '*.Tests.csproj'\n\nForEach ($testProject In $testProjects) {\n\tdotnet test --no-build $testProject.FullName\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add setting preset for Allman-style formatting\n"
},
{
"from": "gpt",
"value": "@{\n IncludeRules = @(\n 'PSPlaceOpenBrace',\n 'PSPlaceCloseBrace',\n 'PSUseConsistentWhitespace',\n 'PSUseConsistentIndentation',\n 'PSAlignAssignmentStatement'\n )\n\n Rules = @{\n PSPlaceOpenBrace = @{\n Enable = $true\n OnSameLine = $false\n NewLineAfter = $true\n IgnoreOneLineBlock = $true\n }\n\n PSPlaceCloseBrace = @{\n Enable = $true\n NewLineAfter = $true\n IgnoreOneLineBlock = $true\n NoEmptyLineBefore = $false\n }\n\n PSUseConsistentIndentation = @{\n Enable = $true\n IndentationSize = 4\n }\n\n PSUseConsistentWhitespace = @{\n Enable = $true\n CheckOpenBrace = $true\n CheckOpenParen = $true\n CheckOperator = $true\n CheckSeparator = $true\n }\n\n PSAlignAssignmentStatement = @{\n Enable = $true\n CheckHashtable = $true\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update message in Test case for WriteHost Rule\n"
},
{
"from": "human",
"value": "Import-Module PSScriptAnalyzer\nSet-Alias ctss ConvertTo-SecureString\n$writeHostMessage = [Regex]::Escape(\"File 'AvoidUsingWriteHost.ps1' uses Write-Host. This is not recommended because it may not work in some hosts or there may even be no hosts at all. Use Write-Output instead.\")\n$writeHostName = \"PSAvoidUsingWriteHost\"\n$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$violations = Invoke-ScriptAnalyzer $directory\\AvoidUsingWriteHost.ps1 | Where-Object {$_.RuleName -eq $writeHostName}\n$noViolations = Invoke-ScriptAnalyzer $directory\\AvoidUsingWriteHostNoViolations.ps1 | Where-Object {$_.RuleName -eq $clearHostName}\n\nDescribe \"AvoidUsingWriteHost\" {\n Context \"When there are violations\" {\n It \"has 4 Write-Host violations\" {\n $violations.Count | Should Be 4\n }\n\n It \"has the correct description message for Write-Host\" {\n $violations[0].Message | Should Match $writeHostMessage\n }\n }\n\n Context \"When there are no violations\" {\n It \"returns no violations\" {\n $noViolations.Count | Should Be 0\n }\n }\n}"
},
{
"from": "gpt",
"value": "Import-Module PSScriptAnalyzer\nSet-Alias ctss ConvertTo-SecureString\n$writeHostMessage = [Regex]::Escape(\"File 'AvoidUsingWriteHost.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.\")\n$writeHostName = \"PSAvoidUsingWriteHost\"\n$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$violations = Invoke-ScriptAnalyzer $directory\\AvoidUsingWriteHost.ps1 | Where-Object {$_.RuleName -eq $writeHostName}\n$noViolations = Invoke-ScriptAnalyzer $directory\\AvoidUsingWriteHostNoViolations.ps1 | Where-Object {$_.RuleName -eq $clearHostName}\n\nDescribe \"AvoidUsingWriteHost\" {\n Context \"When there are violations\" {\n It \"has 4 Write-Host violations\" {\n $violations.Count | Should Be 4\n }\n\n It \"has the correct description message for Write-Host\" {\n $violations[0].Message | Should Match $writeHostMessage\n }\n }\n\n Context \"When there are no violations\" {\n It \"returns no violations\" {\n $noViolations.Count | Should Be 0\n }\n }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add new Power Shell script\n"
},
{
"from": "gpt",
"value": "<#\n\n.SYNOPSIS\n\nMonitors a Window's Service and indicates if it is running.\n\n.EXAMPLE\n\nPS > Check-Service \nGets the number of handles allocated by all the processes running on the host.\n\n#>\nparam(ServiceName)\n\n$service = Get-Service -Name $ServiceName\n\nif ($service.Status -ne \"Started\") {\n Write-Host \"BOUNDARY_WINDOWS_SERVICE 1 $ServiceName\" \n}\nelse {\n Write-Host \"BOUNDARY_WINDOWS_SERVICE 0 $ServiceName\" \n}\n\n# Output the metric, standard out??\n\"BOUNDARY_WINDOWS_HANDLES $handleCount $source\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Deploy multiple App Service Plans and loadbalance across them using Azure Front Door\n"
},
{
"from": "gpt",
"value": "# Deploy multiple App Service Plans and loadbalance across them using Azure Front Door\n\n$location = 'australiaeast'\n$loc = 'aue'\n$rg = 'appserviceplanscale-rg'\n$plan1 = \"appserviceplanscale1-$loc-plan\"\n$plan2 = \"appserviceplanscale2-$loc-plan\"\n$tags = 'project=appserviceplan-scale-afd'\n$app1 = \"appserviceplanscale1-$loc\"\n$app2 = \"appserviceplanscale2-$loc\"\n$frontDoor = 'appserviceplanscale'\n$insights = 'appserviceplanscale-insights'\n$insightsLocation = 'ase'\n\n# Create resource group\naz group create -n $rg --location $location --tags $tags\n\n# Create App Service Plans\naz appservice plan create -n $plan1 -g $rg --location $location --sku B1 --number-of-workers 2 --tags $tags\naz appservice plan create -n $plan2 -g $rg --location $location --sku B1 --number-of-workers 2 --tags $tags\n\n# Create Apps, deploy from Github\naz webapp create -n $app1 --plan $plan1 -g $rg --tags $tags `\n --deployment-source-url 'https://github.com/DanielLarsenNZ/HelloAspDotNetCore'\naz webapp create -n $app2 --plan $plan2 -g $rg --tags $tags `\n --deployment-source-url 'https://github.com/DanielLarsenNZ/HelloAspDotNetCore'\n\n# Turn off ARR\naz webapp update -n $app1 -g $rg --client-affinity-enabled false\naz webapp update -n $app2 -g $rg --client-affinity-enabled false\n\n# Create Front Door\naz extension add --name front-door\naz network front-door create -n $frontDoor -g $rg --tags $tags --backend-address \"$app1.azurewebsites.net\" --accepted-protocols Http Https\n\n# Add second Backend\naz network front-door backend-pool backend add -g $rg --front-door-name $frontDoor --address \"$app2.azurewebsites.net\" --pool-name 'DefaultBackendPool'\n\n\n\n# Open the apps in the browser\nstart \"https://$app1.azurewebsites.net\"\nstart \"https://$app2.azurewebsites.net\"\nstart \"https://$frontDoor.azurefd.net\"\n\n# Tear down\n# & az group delete -n $rg --yes"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Revert \"Improve speed pulling images\"\n\nThis reverts commit 9784b2c6c97f0b05e4eed946a115efa27dfff243.\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = 'Stop';\n$files = \"\"\nWrite-Host Starting build\n\nWrite-Host Disable Windows Defender\nSet-MpPreference -DisableRealtimeMonitoring $true\n\nWrite-Host Updating base images\ndocker pull microsoft/windowsservercore\ndocker pull microsoft/nanoserver\n\nif ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {\n Write-Host Pull request $env:APPVEYOR_PULL_REQUEST_NUMBER\n $files = $(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master))\n} else {\n Write-Host Branch $env:APPVEYOR_REPO_BRANCH\n $files = $(git diff --name-only HEAD~1)\n}\n\nWrite-Host Changed files:\n\n$dirs = @{}\n\n$files | ForEach-Object {\n Write-Host $_\n $dir = $_ -replace \"\\/[^\\/]+$\", \"\"\n $dir = $dir -replace \"/\", \"\\\"\n if (Test-Path \"$dir\\build.ps1\") {\n Write-Host \"Storing $dir for build\"\n $dirs.Set_Item($dir, 1)\n } else {\n $dir = $dir -replace \"\\\\[^\\\\]+$\", \"\"\n if (Test-Path \"$dir\\build.ps1\") {\n Write-Host \"Storing $dir for build\"\n $dirs.Set_Item($dir, 1)\n }\n }\n}\n\n$dirs.GetEnumerator() | Sort-Object Name | ForEach-Object {\n $dir = $_.Name\n Write-Host Building in directory $dir\n pushd $dir\n .\\build.ps1\n popd\n}\n\ndocker images\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = 'Stop';\n$files = \"\"\nWrite-Host Starting build\n\nWrite-Host Updating base images\ndocker pull microsoft/windowsservercore\ndocker pull microsoft/nanoserver\n\nif ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {\n Write-Host Pull request $env:APPVEYOR_PULL_REQUEST_NUMBER\n $files = $(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD master))\n} else {\n Write-Host Branch $env:APPVEYOR_REPO_BRANCH\n $files = $(git diff --name-only HEAD~1)\n}\n\nWrite-Host Changed files:\n\n$dirs = @{}\n\n$files | ForEach-Object {\n Write-Host $_\n $dir = $_ -replace \"\\/[^\\/]+$\", \"\"\n $dir = $dir -replace \"/\", \"\\\"\n if (Test-Path \"$dir\\build.ps1\") {\n Write-Host \"Storing $dir for build\"\n $dirs.Set_Item($dir, 1)\n } else {\n $dir = $dir -replace \"\\\\[^\\\\]+$\", \"\"\n if (Test-Path \"$dir\\build.ps1\") {\n Write-Host \"Storing $dir for build\"\n $dirs.Set_Item($dir, 1)\n }\n }\n}\n\n$dirs.GetEnumerator() | Sort-Object Name | ForEach-Object {\n $dir = $_.Name\n Write-Host Building in directory $dir\n pushd $dir\n .\\build.ps1\n popd\n}\n\ndocker images\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add management of missing environment variable when building on my own PC\n"
},
{
"from": "human",
"value": "$root = (split-path -parent $MyInvocation.MyCommand.Definition)\n$lib = \"$root\\.package\\lib\\45\\\"\nif (Test-Path $lib)\n{\n\tRemove-Item $lib -recurse\n}\nnew-item -Path $lib -ItemType directory\nnew-item -Path $root\\.nupkg -ItemType directory -force\nCopy-Item $root\\Idunn.SqlServer.Console\\bin\\Debug\\* $lib\n\n$version = $env:GitVersion_NuGetVersion\nWrite-Host \"Setting .nuspec version tag to $version\"\n\n$content = (Get-Content $root\\Idunn.SqlServer.nuspec -Encoding UTF8) \n$content = $content -replace '\\$version\\$',$version\n\n$content | Out-File $root\\.package\\Idunn.SqlServer.compiled.nuspec -Encoding UTF8\n\n& NuGet.exe pack $root\\.package\\Idunn.SqlServer.compiled.nuspec -Version $version -OutputDirectory $root\\.nupkg\n\n"
},
{
"from": "gpt",
"value": "$root = (split-path -parent $MyInvocation.MyCommand.Definition)\n$lib = \"$root\\.package\\lib\\45\\\"\nif (Test-Path $lib)\n{\n\tRemove-Item $lib -recurse\n}\nnew-item -Path $lib -ItemType directory\nnew-item -Path $root\\.nupkg -ItemType directory -force\nCopy-Item $root\\Idunn.SqlServer.Console\\bin\\Debug\\* $lib\n\n$version = $env:GitVersion_NuGetVersion\nif ([string]::IsNullOrEmpty($version))\n{\n Write-Warning \"No version found in environment variables, using version of the dll\"\n $version = (Get-Item $lib\\Idunn.SqlServer.Core.dll).VersionInfo.FileVersion\n}\nWrite-Host \"Setting .nuspec version tag to $version\"\n\n$content = (Get-Content $root\\Idunn.SqlServer.nuspec -Encoding UTF8) \n$content = $content -replace '\\$version\\$',$version\n\n$content | Out-File $root\\.package\\Idunn.SqlServer.compiled.nuspec -Encoding UTF8\n\n& NuGet.exe pack $root\\.package\\Idunn.SqlServer.compiled.nuspec -Version $version -OutputDirectory $root\\.nupkg\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add version for Office 365 and/or Azure Developer workstation\n"
},
{
"from": "gpt",
"value": "#Script Name: New-EasyDevWorkstation.ps1\n#Purpose: Quick and clean way to setup a simple developer workstation. Tested only for Windows 10\n#Author Nissan Dookeran\n#Date 23-06-2016\n#Version 0.01\n\n#set the execution policy to allow chocolatey to install and chocolatey scripts to install software\n#Use ByPass to avoid prompts when installing PowerShell modules\nSet-ExecutionPolicy Bypass\n\n#install chocolatey\niwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex\nrefreshenv\n\n#Install the basics - Git, Chrome browser, updated Powershell (if running on older Windows like Win Server 2008R2)\n# Visual Studio Code (which is free), and latest SQL Server Management Studio (also free)\n# Fiddler4 and PostMan\nchoco install -y --allow-empty-checksums git GoogleChrome powershell visualstudiocode sql-server-management-studio postman fiddler4\n\n#Install the Azure Resource Manager and SharePoint PNP Powershell modules\nInstall-Module AzureRM -AllowClobber\nInstall-Module SharePointPnPPowerShellOnline -AllowClobber\n\nSet-ExecutionPolicy RemoteSigned"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Scale up/down Event Hubs example\n"
},
{
"from": "gpt",
"value": "$rg = 'hellomessaging-rg'\n$location = 'australiaeast'\n$eventhubNamespace = 'hellomessaging-hub'\n\n$ErrorActionPreference = 'Stop'\n\nGet-AzEventHubNamespace -ResourceGroupName $rg -NamespaceName $eventhubNamespace \n\n# Scale up\nSet-AzEventHubNamespace -ResourceGroupName $rg -Location $location -NamespaceName $eventhubNamespace -SkuCapacity 5 -SkuName 'Standard' -Verbose\n\n# Run the Test Script\nWrite-Host \"Running Test Script\"\n# Your code here\nStart-Sleep 10\n\n# Scale down\nSet-AzEventHubNamespace -ResourceGroupName $rg -Location $location -NamespaceName $eventhubNamespace -SkuCapacity 1 -SkuName 'Standard' -Verbose\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add Azure Policy Compliance Data script\n"
},
{
"from": "gpt",
"value": "\n<#PSScriptInfo\n\n.VERSION 1.0\n\n.GUID f2d5adaf-ed37-4dcc-96d5-2ac72b770cf8\n\n.AUTHOR Francois-Xavier Cat\n\n.COMPANYNAME\n\n.COPYRIGHT\n\n.TAGS\n\n.LICENSEURI\n\n.PROJECTURI\n https://github.com/lazywinadmin/PowerShell\n\n.ICONURI\n\n.EXTERNALMODULEDEPENDENCIES\n\n.REQUIREDSCRIPTS\n\n.EXTERNALSCRIPTDEPENDENCIES\n\n.RELEASENOTES\n\n.PRIVATEDATA\n\n#>\n\n<#\n.SYNOPSIS\n Retrieve Azure Policy Compliance Data for a specific Assignment under a specific ManagementGroupName\n.DESCRIPTION\n Retrieve Azure Policy Compliance Data for a specific Assignment under a specific ManagementGroupName\n This will also retrieve the subscription name\n\n This script assume you are already connected and authenticated to Azure.\n\n.PARAMETER ManagementGroupName\n Specify the ManagementGroupName\n\n.PARAMETER AssignmentID\n Specify the AssignmentID\n\n.EXAMPLE\n Get-PolicyComplianceData.ps1 -ManagementGroupName <id> -AssignmentID <id>\n\n.LINK\n https://github.com/lazywinadmin/PowerShell\n\n#>\n[CmdletBinding()]\nParam(\n $ManagementGroupName,\n $AssignmentID\n)\ntry{\n # Retrieve the Compliance data\n $State = Get-AzPolicyState -ManagementGroupName $ManagementGroupName -Filter \"(AssignmentID eq $AssignmentID)\"\n\n $SubscriptionNames = $State | Group-Object -Property SubscriptionId | ForEach-Object -Process {\n Get-AzSubscription -SubscriptionId $_.Name\n }\n\n $State | Select-Object -Property *,@{\n Label='SubscriptionName';\n Expression=@{\n #keep current state in var\n $CurrentState=$_\n # retrieve sub name\n ($SubscriptionNames | Where-Object -Filter {$_.id -eq $currentState.subscriptionid}).name\n }\n }\n}catch{\n throw $_\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add ipmo Docker completion modules\n"
},
{
"from": "human",
"value": "sv DESKTOP (Join-Path $HOME Desktop) -Option ReadOnly, AllScope\nsv DOWNLOADS (Join-Path $HOME Downloads) -Option ReadOnly, AllScope\nsv PROFILEDIR (Split-Path $PROFILE) -Option ReadOnly, AllScope\nsv SCRIPTS (Join-Path $HOME Scripts) -Option ReadOnly, AllScope\n\nsal gh help\nsal gcb Get-Clipboard\nsal scb Set-Clipboard\n\nsal d docker\nsal dc docker-compose\nsal dm docker-machine\nsal g git\n\nfunction ll([string[]]$Path = '.') { gci $Path -Exclude .* }\nfunction sl.. { sl .. }\nfunction sl~ { sl ~ }\nfunction Get-FileHash { $fh = Microsoft.PowerShell.Utility\\Get-FileHash @Args; Set-Clipboard $fh.hash; $fh }\nfunction codep { code $PROFILEDIR $PROFILE.CurrentUserAllHosts }\nfunction codes { code $SCRIPTS }\n\n$env:PSModulePath = -join ((Join-Path $PROFILEDIR PSModules), [System.IO.Path]::PathSeparator, $env:PSModulePath)\n\n$env:Path = @(\n\t$SCRIPTS\n\t\"$HOME\\Apps\\Git\\cmd\"\n\t\"$HOME\\Apps\\VSCode\\bin\"\n\t$env:Path\n) -join \";\"\n\nfunction prompt {\n\t$Host.UI.RawUI.WindowTitle = \"PS $($ExecutionContext.SessionState.Path.CurrentLocation)$('>' * ($NestedPromptLevel + 1))\"\n\treturn 'PS> '\n}\n"
},
{
"from": "gpt",
"value": "sv DESKTOP (Join-Path $HOME Desktop) -Option ReadOnly, AllScope\nsv DOWNLOADS (Join-Path $HOME Downloads) -Option ReadOnly, AllScope\nsv PROFILEDIR (Split-Path $PROFILE) -Option ReadOnly, AllScope\nsv SCRIPTS (Join-Path $HOME Scripts) -Option ReadOnly, AllScope\n\nsal gh help\nsal gcb Get-Clipboard\nsal scb Set-Clipboard\n\nsal d docker\nsal dc docker-compose\nsal dm docker-machine\nsal g git\n\nfunction ll([string[]]$Path = '.') { gci $Path -Exclude .* }\nfunction sl.. { sl .. }\nfunction sl~ { sl ~ }\nfunction Get-FileHash { $fh = Microsoft.PowerShell.Utility\\Get-FileHash @Args; Set-Clipboard $fh.hash; $fh }\nfunction codep { code $PROFILEDIR $PROFILE.CurrentUserAllHosts }\nfunction codes { code $SCRIPTS }\n\n$env:PSModulePath = -join ((Join-Path $PROFILEDIR PSModules), [System.IO.Path]::PathSeparator, $env:PSModulePath)\n\n$env:Path = @(\n\t$SCRIPTS\n\t\"$HOME\\Apps\\Git\\cmd\"\n\t\"$HOME\\Apps\\VSCode\\bin\"\n\t$env:Path\n) -join \";\"\n\nipmo DockerCompletion -ea SilentlyContinue\nipmo DockerComposeCompletion -ea SilentlyContinue\nipmo DockerMachineCompletion -ea SilentlyContinue\n\nfunction prompt {\n\t$Host.UI.RawUI.WindowTitle = \"PS $($ExecutionContext.SessionState.Path.CurrentLocation)$('>' * ($NestedPromptLevel + 1))\"\n\treturn 'PS> '\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add tests for command name matching\n"
},
{
"from": "human",
"value": "Describe \"NativeLinuxCommands\" {\n It \"Should return a type of System.Object for hostname cmdlet\" {\n (hostname).GetType().BaseType | Should Be 'System.Object'\n (hostname).GetType().Name | Should Be String\n }\n\n It \"Should find Application grep\" -Skip:$IsWindows {\n (get-command grep).CommandType | Should Be Application\n }\n\n It \"Should pipe to grep and get result\" -Skip:$IsWindows {\n \"hello world\" | grep hello | Should Be \"hello world\"\n }\n\n It \"Should find Application touch\" -Skip:$IsWindows {\n (get-command touch).CommandType | Should Be Application\n }\n}\n"
},
{
"from": "gpt",
"value": "Describe \"NativeLinuxCommands\" {\n It \"Should return a type of System.Object for hostname cmdlet\" {\n (hostname).GetType().BaseType | Should Be 'System.Object'\n (hostname).GetType().Name | Should Be String\n }\n\n It \"Should find Application grep\" -Skip:$IsWindows {\n (get-command grep).CommandType | Should Be Application\n }\n\n It \"Should pipe to grep and get result\" -Skip:$IsWindows {\n \"hello world\" | grep hello | Should Be \"hello world\"\n }\n\n It \"Should find Application touch\" -Skip:$IsWindows {\n (get-command touch).CommandType | Should Be Application\n }\n}\n\nDescribe \"Scripts with extensions\" {\n BeforeAll {\n $data = \"Hello World\"\n Setup -File testScript.ps1 -Content \"'$data'\"\n $originalPath = $env:PATH\n $env:PATH += [IO.Path]::PathSeparator + $TestDrive\n }\n\n AfterAll {\n $env:PATH = $originalPath\n }\n\n It \"Should run a script with its full name\" {\n testScript.ps1 | Should Be $data\n }\n\n It \"Should run a script with its short name\" {\n testScript | Should Be $data\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script to decode strings from DFM\n"
},
{
"from": "gpt",
"value": "<#\n.SYNOPSIS\n Create .NET string from DFM-encoded string.\n#>\nparam (\n [string]$String\n)\n\n$chars = $String.Split(@('#'), 'RemoveEmptyEntries') | % { [char] [int]$_ }\nNew-Object System.String (, $chars)\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Check Domain and Application Directory contexts for credentials when validating SMB creds\n"
},
{
"from": "human",
"value": "Param(\r\n [Parameter(Mandatory=$true)]\r\n [string]$username,\r\n [Parameter(Mandatory=$true)]\r\n [string]$password\r\n)\r\n\r\nAdd-Type -AssemblyName System.DirectoryServices.AccountManagement\r\n\r\n$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext(\r\n [System.DirectoryServices.AccountManagement.ContextType]::Machine,\r\n $env:COMPUTERNAME\r\n)\r\n\r\nif ( $DSContext.ValidateCredentials( $username, $password ) ) {\r\n exit 0\r\n} else {\r\n exit 1\r\n}"
},
{
"from": "gpt",
"value": "Param(\r\n [Parameter(Mandatory=$true)]\r\n [string]$username,\r\n [Parameter(Mandatory=$true)]\r\n [string]$password\r\n)\r\n\r\nAdd-Type -AssemblyName System.DirectoryServices.AccountManagement\r\n\r\n$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext(\r\n [System.DirectoryServices.AccountManagement.ContextType]::Machine,\r\n $env:COMPUTERNAME\r\n)\r\nif ( $DSContext.ValidateCredentials( $username, $password ) ) {\r\n exit 0\r\n} \r\n\r\n$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext(\r\n [System.DirectoryServices.AccountManagement.ContextType]::Domain,\r\n $env:COMPUTERNAME\r\n)\r\nif ( $DSContext.ValidateCredentials( $username, $password ) ) {\r\n exit 0\r\n} \r\n\r\n$DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext(\r\n [System.DirectoryServices.AccountManagement.ContextType]::ApplicationDirectory,\r\n $env:COMPUTERNAME\r\n)\r\nif ( $DSContext.ValidateCredentials( $username, $password ) ) {\r\n exit 0\r\n} \r\n\r\nexit 1\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove Windows Defender, keep TrustedInstaller\n"
},
{
"from": "human",
"value": "Write-Host Downloading debloat zip\n$url=\"https://github.com/StefanScherer/Debloat-Windows-10/archive/master.zip\"\n(New-Object System.Net.WebClient).DownloadFile($url, \"$env:TEMP\\debloat.zip\")\nExpand-Archive -Path $env:TEMP\\debloat.zip -DestinationPath $env:TEMP -Force\n\nWrite-Host Disable scheduled tasks\n. $env:TEMP\\Debloat-Windows-10-master\\utils\\disable-scheduled-tasks.ps1\nWrite-Host Block telemetry\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\block-telemetry.ps1\nWrite-Host Disable services\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\disable-services.ps1\nWrite-host Disable Windows Defender\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\disable-windows-defender.ps1\nWrite-host Optimize Windows Update\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\optimize-windows-update.ps1\nWrite-host Disable Windows Update\nset-service wuauserv -startuptype disabled\nset-service trustedinstaller -startuptype disabled\nWrite-Host Remove OneDrive\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\remove-onedrive.ps1\n"
},
{
"from": "gpt",
"value": "Write-Host Downloading debloat zip\n$url=\"https://github.com/StefanScherer/Debloat-Windows-10/archive/master.zip\"\n(New-Object System.Net.WebClient).DownloadFile($url, \"$env:TEMP\\debloat.zip\")\nExpand-Archive -Path $env:TEMP\\debloat.zip -DestinationPath $env:TEMP -Force\n\nWrite-Host Disable scheduled tasks\n. $env:TEMP\\Debloat-Windows-10-master\\utils\\disable-scheduled-tasks.ps1\nWrite-Host Block telemetry\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\block-telemetry.ps1\nWrite-Host Disable services\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\disable-services.ps1\nWrite-host Disable Windows Defender\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\disable-windows-defender.ps1\nUninstall-WindowsFeature Windows-Defender-Features\nWrite-host Optimize Windows Update\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\optimize-windows-update.ps1\nWrite-host Disable Windows Update\nSet-Service wuauserv -StartupType Disabled\nWrite-Host Remove OneDrive\n. $env:TEMP\\Debloat-Windows-10-master\\scripts\\remove-onedrive.ps1\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add sample script to create volume and Containers\n"
},
{
"from": "gpt",
"value": "# Docker volume für PostgresDB\ndocker volume create PostgresDBVolume\n\n# Postgres DB container\ndocker run --name Postgres -d `\n -e POSTGRES_PASSWORD=P@ssw0rd! `\n -e PGDATA=/usr/stiwa/pgdata `\n -v PostgresDBVolume:/usr/stiwa/pgdata `\n postgres\n\n# Compile container\ndocker run --rm `\n -v C:\\temp\\demo-codingdojo\\code:/code `\n -w /code `\n --link=Postgres:db_link `\n microsoft/dotnet /bin/bash -c \"dotnet build && dotnet ef migrations add InitialCreate && dotnet ef database update\"\n\n# Start WebAPI Container\ndocker run -d --name WebAPI1 `\n -v C:\\temp\\demo-codingdojo\\code:/code `\n -w /code `\n --link=Postgres:db_link `\n -e ASPNETCORE_URLS=http://*:49981 `\n microsoft/dotnet dotnet run\n\ndocker run -d --name WebAPI2 `\n -v C:\\temp\\demo-codingdojo\\code:/code `\n -w /code `\n --link=Postgres:db_link `\n -e ASPNETCORE_URLS=http://*:49981 `\n microsoft/dotnet dotnet run\n\n# LoadBalancer\ndocker run -d --name LoadBalancer `\n --link=WebAPI1:WebAPI1 `\n --link=WebAPI2:WebAPI2 `\n -p 8082:80 `\n -v C:\\temp\\demo-codingdojo\\code\\nginx.conf:/etc/nginx/nginx.conf `\n nginx:alpine"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update build script for pushing packages to NuGet.org\n"
},
{
"from": "human",
"value": "param([Parameter(Mandatory=$true)][string]$Version) \n\ncd ..\\.nuget\n.\\NuGet.exe push ..\\artifacts\\Okra.Core.$Version.nupkg\n.\\NuGet.exe push ..\\artifacts\\Okra.MEF.$Version.nupkg\n\n$x = $host.UI.RawUI.ReadKey(\"NoEcho,IncludeKeyDown\")"
},
{
"from": "gpt",
"value": "[CmdletBinding()]\nParam([Parameter(Mandatory=$True)][Version]$versionNumber)\n\n# Move to the project root folder (parent from current script folder)\n\nfunction Get-ScriptDirectory\n{ \n $Invocation = (Get-Variable MyInvocation -Scope 1).Value \n Split-Path $Invocation.MyCommand.Path \n}\n\n$rootFolder = (Get-Item (Get-ScriptDirectory)).Parent.FullName\nSet-Location $rootFolder\n\n# Check NuGet is installed and updated\n\nIf (!(Test-Path .\\.nuget\\nuget.exe))\n{\n New-Item .\\.nuget -type directory -Force | Out-Null\n Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '.\\.nuget\\nuget.exe'\n}\n\n.\\.nuget\\NuGet.exe update -self\n\n# Push packages to NuGet.org\n\n.\\.nuget\\NuGet.exe push .\\artifacts\\Okra.Core.$versionNumber.nupkg\n.\\.nuget\\NuGet.exe push .\\artifacts\\Okra.MEF.$versionNumber.nupkg"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix lib path references to be relative to calling path\nHopefully...\n"
},
{
"from": "human",
"value": "mkdir -Force lib | Out-Null\n\n\"Looking for Hearthstone Deck Tracker install...\"\n$HDTPath = \"$Env:LOCALAPPDATA\\HearthstoneDeckTracker\"\nif(Test-Path $HDTPath)\n{\n $HDTExe = Get-ChildItem \"$Env:LOCALAPPDATA\\HearthstoneDeckTracker\" | Where-Object { $_.PSIsContainer -and $_.Name.StartsWith(\"app-\")} | Sort-Object CreationTime -desc | Select-Object -f 1 | Get-ChildItem | Where-Object { $_.Name.Equals(\"HearthstoneDeckTracker.exe\")}\n if($HDTExe.Exists)\n {\n \"Copying $($HDTExe.Name) v$($HDTExe.VersionInfo.FileVersion)... \"\n Copy-Item $HDTExe.FullName \"lib\\$($HDTExe.Name)\" -Force\n }\n}\n\n function FetchLib($name) {\n\t\"Fetching $name...\"\n\t$url = \"https://libs.hearthsim.net/hdt/$name.dll\"\n\ttry { (New-Object Net.WebClient).DownloadFile($url, \"lib\\$name.dll\") }\n catch { $error[0].Exception.ToString() }\n}\n\nFetchLib \"HearthDb\""
},
{
"from": "gpt",
"value": "mkdir -Force .\\lib | Out-Null\n\n\"Looking for Hearthstone Deck Tracker install...\"\n$HDTPath = \"$Env:LOCALAPPDATA\\HearthstoneDeckTracker\"\nif(Test-Path $HDTPath)\n{\n $HDTExe = Get-ChildItem \"$Env:LOCALAPPDATA\\HearthstoneDeckTracker\" | Where-Object { $_.PSIsContainer -and $_.Name.StartsWith(\"app-\")} | Sort-Object CreationTime -desc | Select-Object -f 1 | Get-ChildItem | Where-Object { $_.Name.Equals(\"HearthstoneDeckTracker.exe\")}\n if($HDTExe.Exists)\n {\n \"Copying $($HDTExe.Name) v$($HDTExe.VersionInfo.FileVersion)... \"\n Copy-Item $HDTExe.FullName \".\\lib\\$($HDTExe.Name)\" -Force\n }\n}\n\n function FetchLib($name) {\n\t\"Fetching $name...\"\n\t$url = \"https://libs.hearthsim.net/hdt/$name.dll\"\n\ttry { (New-Object Net.WebClient).DownloadFile($url, \".\\lib\\$name.dll\") }\n catch { $error[0].Exception.ToString() }\n}\n\nFetchLib \"HearthDb\""
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add Parse TSQL powershell script\n\n"
},
{
"from": "gpt",
"value": "#requires -version 5.0\n#requires -modules dbatools,pester\n\n<#\n.Synopsis\n Ensure that some SQL Scripts in a directory would parse so there was some guarantee that they were valid T-SQL.\n\n.OUTPUTS\n Any unvalid TSQL\n\n.NOTES\n Original link: https://sqldbawithabeard.com/2018/07/25/a-powershell-pester-check-for-parsing-sql-scripts/\n Author: Rob Sewell\n#>\n\nDescribe \"Testing SQL\" {\n Context \"Running Parser\" {\n ## Load assembly\n $Parserdll = (Get-ChildItem 'C:\\Program Files\\WindowsPowerShell\\Modules\\dbatools' -Include Microsoft.SqlServer.Management.SqlParser.dll -Recurse)[0].FullName\n [System.Reflection.Assembly]::LoadFile($Parserdll) | Out-Null\n $TraceDll = (Get-ChildItem 'C:\\Program Files\\WindowsPowerShell\\Modules\\dbatools' -Include Microsoft.SqlServer.Diagnostics.Strace.dll -Recurse)[0].FullName\n [System.Reflection.Assembly]::LoadFile($TraceDll) | Out-Null\n $ParseOptions = New-Object Microsoft.SqlServer.Management.SqlParser.Parser.ParseOptions\n $ParseOptions.BatchSeparator = 'GO'\n $files = Get-ChildItem -Path $Env:Directory -Include *.sql -Recurse ## This variable is set as a Build Process Variable or put your path here\n $files.ForEach{\n It \"$($Psitem.FullName) Should Parse SQL correctly\" {\n $filename = $Psitem.FullName\n $sql = Get-Content -LiteralPath \"$fileName\"\n $Script = [Microsoft.SqlServer.Management.SqlParser.Parser.Parser]::Parse($SQL, $ParseOptions)\n $Script.Errors | Should -BeNullOrEmpty\n }\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "CI: Update build script for Windows\n\nDisable serial and USB backends.\n\nSigned-off-by: Paul Cercueil <a027184a55211cd23e3f3094f1fdc728df5e0500@crapouillou.net>\n"
},
{
"from": "human",
"value": "\n$COMPILER=$Env:COMPILER\n$ARCH=$Env:ARCH\n\n$src_dir=$pwd\n\nmkdir build\ncd build\n\ncmake -G \"$COMPILER\" -A \"$ARCH\" -DPYTHON_BINDINGS=ON -DLIBXML2_LIBRARIES=\"$src_dir\\deps\\lib\\libxml2.dll.a\" ..\ncmake --build . --config Release\n"
},
{
"from": "gpt",
"value": "\n$COMPILER=$Env:COMPILER\n$ARCH=$Env:ARCH\n\n$src_dir=$pwd\n\nmkdir build\ncd build\n\ncmake -G \"$COMPILER\" -A \"$ARCH\" -DENABLE_IPV6=OFF -DWITH_USB_BACKEND=OFF -DWITH_SERIAL_BACKEND=OFF -DPYTHON_BINDINGS=ON -DLIBXML2_LIBRARIES=\"$src_dir\\deps\\lib\\libxml2.dll.a\" ..\ncmake --build . --config Release\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix build script to terminate on errors\n"
},
{
"from": "human",
"value": "# Restore our NuGet packages\nnuget sources Add -Name CitiesSkylines -Source $env:NUGET_CSL_URL -UserName $env:NUGET_CSL_USERNAME -Password $env:NUGET_CSL_PASSWORD -Verbosity quiet -NonInteractive\nnuget restore .\\appveyor\\packages.config -SolutionDirectory .\\ -NonInteractive\n\n[xml]$packages = Get-Content .\\appveyor\\packages.config\n$referencePath = ($packages.packages.package | % {\"..\\packages\\$($_.id).$($_.version)\\lib\\$($_.targetFramework)\\\"}) -Join \";\"\n\n\n# Do the actual build\nmsbuild /logger:\"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll\" /verbosity:minimal /p:ReferencePath=\"$referencePath\"\n\n\n# Copy the files we need to .\\bin\nif (Test-Path bin) {\n Remove-Item bin -recurse -force\n}\nmkdir bin | Out-Null;\nCopy-Item \"CSL Scrollable Toolbar\\bin\\$env:CONFIGURATION\\*\" -Destination bin -Recurse -Force -Exclude @(\"*.pdb\")\n\n\n# Copy the files we need to .\\workshop\nif (Test-Path workshop) {\n Remove-Item workshop -recurse -force\n}\nmkdir workshop | Out-Null;\nmkdir workshop\\Content | Out-Null;\nCopy-Item PreviewImage.png -destination workshop\nCopy-Item \"bin/*\" -destination workshop\\Content -recurse\n"
},
{
"from": "gpt",
"value": "# Restore our NuGet packages\nnuget sources Add -Name CitiesSkylines -Source $env:NUGET_CSL_URL -UserName $env:NUGET_CSL_USERNAME -Password $env:NUGET_CSL_PASSWORD -Verbosity quiet -NonInteractive\nif ($LASTEXITCODE -gt 0) { exit $LASTEXITCODE }\nnuget restore .\\appveyor\\packages.config -SolutionDirectory .\\ -NonInteractive\nif ($LASTEXITCODE -gt 0) { exit $LASTEXITCODE }\n\n[xml]$packages = Get-Content .\\appveyor\\packages.config\n$referencePath = ($packages.packages.package | % {\"..\\packages\\$($_.id).$($_.version)\\lib\\$($_.targetFramework)\\\"}) -Join \";\"\n\n\n# Do the actual build\nmsbuild /logger:\"C:\\Program Files\\AppVeyor\\BuildAgent\\Appveyor.MSBuildLogger.dll\" /verbosity:minimal /p:ReferencePath=\"$referencePath\"\nif ($LASTEXITCODE -gt 0) { exit $LASTEXITCODE }\n\n\n# Copy the files we need to .\\bin\nif (Test-Path bin) {\n Remove-Item bin -recurse -force\n}\nmkdir bin | Out-Null;\nCopy-Item \"CSL Scrollable Toolbar\\bin\\$env:CONFIGURATION\\*\" -Destination bin -Recurse -Force -Exclude @(\"*.pdb\")\n\n\n# Copy the files we need to .\\workshop\nif (Test-Path workshop) {\n Remove-Item workshop -recurse -force\n}\nmkdir workshop | Out-Null;\nmkdir workshop\\Content | Out-Null;\nCopy-Item PreviewImage.png -destination workshop\nCopy-Item \"bin/*\" -destination workshop\\Content -recurse\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add PS script for scheduled tasks\n"
},
{
"from": "gpt",
"value": "<#\n.SYNOPSIS\n Le script permet de modifier l'ensemble des quotas de manière automatique.\n\n.DESCRIPTION\n Liste l'ensemble des tâches planifiées des serveurs sous forme de fichier\n CSV.\n\n.EXAMPLE\n .\\taskScheduled.ps1\n\n.NOTES\n File Name : taskScheduled.ps1\n Author : Nicolas Le Gall - contact <at> nlegall <dot> fr\n#>\n\n# =============================================================================\n# Variables\n# Chemin du fichier de sortie\n$year = Get-Date -UFormat %Y\n$moth = Get-Date -UFormat %m\n$day = Get-Date -UFormat %d\n$path = \"logs\\\" + $year + \"_\" + $moth + \"_\" + $day\n$file_output = \"logs\\\" + $year + \"_\" + $moth + \"_\" + $day + \"\\comptes_locaux.csv\"\n\nNew-Item -ItemType Directory -Path \"logs\" -Name $($year + \"_\" + $moth + \"_\" + $day)\n\nAdd-Content -Path $file_output \"Nom;Tache;Utilisateur\"\n\n$ComputerName = Get-ADComputer -Filter * -SearchBase \"OU=Serveurs,DC=domain,DC=tld\" | Select-Object -Property Name\n\nforeach ($computer in $ComputerName)\n{\n\t$schedule = new-object -ComObject Schedule.Service \n\t\n\ttry\n\t{\n\t\t$schedule.connect($computer.Name)\n\t}\n\tcatch\n\t{\n\t\tAdd-Content -Path $file_output -Value $computer.Name\n\t}\n\tif ($Schedule.connected)\n\t{\n\t\t$tasks = $Schedule.getfolder(\"\\\").gettasks(0) | Select-Object Name, State, Path, LastRunTime, LastTaskResult, Xml\n\t\tforeach($task in $tasks)\n\t\t{\n\t\t\t$xml = [xml]$task.Xml\n\t\t\t$user = $xml.Task.Principals.FirstChild.UserId\n $value = $computer.Name + \";\" + $task.Name + \";\" + $user\n Add-Content -Path $file_output -Value $value\n\t\t}\n\t}\n\t\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use script path to relative paths\n\nThis enables the script to run from anywhere\n"
},
{
"from": "human",
"value": "dotnet --version\n\n$buildExitCode=0\n\nWrite-Output \"*** Restoring packages\"\ndotnet restore\n$buildExitCode = $LASTEXITCODE\nif ($buildExitCode -ne 0){\n Write-Output \"*** Restore failed\"\n exit $buildExitCode\n}\n\n\nWrite-Output \"*** Building projects\"\n$buildExitCode=0\nGet-Content build\\build-order.txt | ForEach-Object { \n Write-Output \"*** dotnet build $_\"\n dotnet build $_\n if ($LASTEXITCODE -ne 0){\n $buildExitCode = $LASTEXITCODE\n }\n}\nif($buildExitCode -ne 0) {\n Write-Output \"*** Build failed\"\n exit $buildExitCode\n}\n\n#$testExitCode = 0\n#Get-Content build\\test-order.txt | ForEach-Object { \n# dotnet test $_\n# if ($LASTEXITCODE -ne 0){\n# $testExitCode = $LASTEXITCODE\n# }\n#}\n#\n#exit $testExitCode\n"
},
{
"from": "gpt",
"value": "$here = Split-Path -Parent $MyInvocation.MyCommand.Path\n\ndotnet --version\n\n$buildExitCode=0\n\nWrite-Output \"*** Restoring packages\"\ndotnet restore\n$buildExitCode = $LASTEXITCODE\nif ($buildExitCode -ne 0){\n Write-Output \"*** Restore failed\"\n exit $buildExitCode\n}\n\n\nWrite-Output \"*** Building projects\"\n$buildExitCode=0\nGet-Content \"$here\\build\\build-order.txt\" | ForEach-Object { \n Write-Output \"*** dotnet build $_\"\n dotnet build $_\n if ($LASTEXITCODE -ne 0){\n $buildExitCode = $LASTEXITCODE\n }\n}\nif($buildExitCode -ne 0) {\n Write-Output \"*** Build failed\"\n exit $buildExitCode\n}\n\n#$testExitCode = 0\n#Get-Content build\\test-order.txt | ForEach-Object { \n# dotnet test $_\n# if ($LASTEXITCODE -ne 0){\n# $testExitCode = $LASTEXITCODE\n# }\n#}\n#\n#exit $testExitCode\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove call to nuget restore in build script"
},
{
"from": "human",
"value": "gci **\\*.sln -recurse -Exclude Master.sln | foreach { nuget restore $_;msbuild $_ /t:Rebuild /p:platform=\"any cpu\" /p:Configuration=\"Debug\" /p:OutDir=$(\"$(PWD)\\Output\\\" + $_.BaseName)}"
},
{
"from": "gpt",
"value": "gci **\\*.sln -recurse -Exclude Master.sln | foreach { msbuild $_ /t:Rebuild /p:platform=\"any cpu\" /p:Configuration=\"Debug\" /p:OutDir=$(\"$(PWD)\\Output\\\" + $_.BaseName)}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Sort runTests.ps1 from newest to oldest in Windows tests too.\n"
},
{
"from": "human",
"value": "# Copyright(c) 2017 Google Inc.\r\n#\r\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\r\n# use this file except in compliance with the License. You may obtain a copy of\r\n# the License at\r\n#\r\n# http://www.apache.org/licenses/LICENSE-2.0\r\n#\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\r\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r\n# License for the specific language governing permissions and limitations under\r\n# the License.\r\n\r\n# Load secrets from the files downloaded from google cloud storage.\r\nGet-ChildItem $env:KOKORO_GFILE_DIR\r\n& \"$env:KOKORO_GFILE_DIR/secrets.ps1\"\r\n$env:GOOGLE_APPLICATION_CREDENTIALS=\"$env:KOKORO_GFILE_DIR/silver-python2-01aab03dac88.json\"\r\n\r\nPush-Location\r\ntry {\r\n # buildAndRunTests\r\n $private:invocation = (Get-Variable MyInvocation -Scope 0).Value\r\n Set-Location (Join-Path (Split-Path $invocation.MyCommand.Path) ..)\r\n .\\buildAndRunTests.ps1 -Skip\r\n} finally {\r\n Pop-Location\r\n}\r\n\r\n"
},
{
"from": "gpt",
"value": "# Copyright(c) 2017 Google Inc.\r\n#\r\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\r\n# use this file except in compliance with the License. You may obtain a copy of\r\n# the License at\r\n#\r\n# http://www.apache.org/licenses/LICENSE-2.0\r\n#\r\n# Unless required by applicable law or agreed to in writing, software\r\n# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\r\n# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\r\n# License for the specific language governing permissions and limitations under\r\n# the License.\r\n\r\n# Load secrets from the files downloaded from google cloud storage.\r\nGet-ChildItem $env:KOKORO_GFILE_DIR\r\n& \"$env:KOKORO_GFILE_DIR/secrets.ps1\"\r\n$env:GOOGLE_APPLICATION_CREDENTIALS=\"$env:KOKORO_GFILE_DIR/silver-python2-01aab03dac88.json\"\r\n\r\nPush-Location\r\ntry {\r\n # Import BuildTools.psm1\r\n $private:invocation = (Get-Variable MyInvocation -Scope 0).Value\r\n Set-Location (Join-Path (Split-Path $invocation.MyCommand.Path) ..)\r\n Import-Module .\\BuildTools.psm1 -DisableNameChecking\r\n\r\n # The list of all subdirectories.\r\n $dirs = Get-ChildItem | Where-Object {$_.PSIsContainer} \r\n\r\n # Find all the runTest scripts.\r\n $scripts = Get-ChildItem -Path $dirs -Filter *runTest*.ps* -Recurse\r\n $scripts.VersionInfo.FileName `\r\n | Sort-Object -Descending -Property {Get-GitTimeStampForScript $_} `\r\n | Run-TestScripts -TimeoutSeconds 600\r\n} finally {\r\n Pop-Location\r\n}\r\n\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Allow pulling from other image category\n"
},
{
"from": "human",
"value": "$BASEPATH_HEADERS = '.\\assets\\headers\\';\n$BASEPATH_POSTS = '.\\_posts\\';\n\nForEach ($post in Get-ChildItem $BASEPATH_POSTS*.md) { \n $safeName = $post.Name.Replace(\".md\",\"\");\n $requiredFile = $BASEPATH_HEADERS + $safeName + \".png\";\n if (!(Test-Path $requiredFile))\n {\n Write-Host \"Post named '$safeName' located without header\"\n \n Write-Host \" > Waiting for two seconds to prevent spamming Unsplash\"\n Start-Sleep -Seconds 2;\n Write-Host \" > Downloading header for post to '$requiredFile'\"\n Invoke-WebRequest https://source.unsplash.com/category/nature/800x400 -OutFile $requiredFile\n Write-Host \" > Royalty-free image downloaded from Unsplash successfully\"\n \n Write-Host \" > Adding image to blog-post\"\n Invoke-Expression \".\\AddMissingImage.ps1 $safeName\"\n\n Write-Host \"Image processing complete for '$safeName'\"\n }\n}\n\n"
},
{
"from": "gpt",
"value": "Param(\n # The path to the post we need to add the image to\n [Parameter(Mandatory=$false)][string]$CategoryName = \"nature\"\n);\n\n\n$BASEPATH_HEADERS = '.\\assets\\headers\\';\n$BASEPATH_POSTS = '.\\_posts\\';\n\nForEach ($post in Get-ChildItem $BASEPATH_POSTS*.md) { \n $safeName = $post.Name.Replace(\".md\",\"\");\n $requiredFile = $BASEPATH_HEADERS + $safeName + \".png\";\n if (!(Test-Path $requiredFile))\n {\n Write-Host \"Post named '$safeName' located without header\"\n \n Write-Host \" > Waiting for two seconds to prevent spamming Unsplash\"\n Start-Sleep -Seconds 2;\n Write-Host \" > Downloading header for post from category '$CategoryName' to '$requiredFile'\"\n Invoke-WebRequest https://source.unsplash.com/category/$CategoryName/800x400 -OutFile $requiredFile\n Write-Host \" > Royalty-free image downloaded from Unsplash successfully\"\n \n Write-Host \" > Adding image to blog-post\"\n Invoke-Expression \".\\AddMissingImage.ps1 $safeName\"\n\n Write-Host \"Image processing complete for '$safeName'\"\n }\n}\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix NugetRestore.ps1 to not look for packages.config\n\nFixes #946\n"
},
{
"from": "human",
"value": "$NuGetExe = \"$PSScriptRoot\\NuGet.exe\"\n\n& $NuGetExe install xunit.runner.console -version 2.0.0 -OutputDirectory \"$PSScriptRoot\\..\\..\\packages\"\n& $NuGetExe restore \"$PSScriptRoot\\packages.config\" -PackagesDirectory \"$PSScriptRoot\\..\\..\\packages\"\n& $NuGetExe restore \"$PSScriptRoot\\..\\Analyzers.sln\" -PackagesDirectory \"$PSScriptRoot\\..\\..\\packages\"\n\n"
},
{
"from": "gpt",
"value": "$NuGetExe = \"$PSScriptRoot\\NuGet.exe\"\n$NuGetConfig = \"$PSScriptRoot\\NuGet.config\"\n\n& $NuGetExe restore \"$PSScriptRoot\\..\\Analyzers.sln\" -configfile \"$NuGetConfig\"\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Switch to freeSSHD instead of Openssh\n"
},
{
"from": "human",
"value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Common Windows Tools\n\n## cinst openssh\n\ncinst f.lux\n\ncinst picasa\n\ncinst googledrive\n\ncinst notepadplusplus\n\ncinst adobereader\n\ncinst libreoffice\n\ncinst baretail\n\ncinst greenshot\n\ncinst AdobeAIR\n\ncinst paint.net\n\ncinst ccleaner\n\ncinst grepwin\n\ncinst 7zip\n\ncinst thunderbird\n\n## Web Browsers\n\ncinst GoogleChrome\n\ncinst Firefox"
},
{
"from": "gpt",
"value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Common Windows Tools\n\n## cinst freeSSHD\n\n## cinst Tunnelier\n\ncinst f.lux\n\ncinst picasa\n\ncinst googledrive\n\ncinst notepadplusplus\n\ncinst adobereader\n\n## cinst libreoffice\n\ncinst baretail\n\ncinst greenshot\n\ncinst AdobeAIR\n\ncinst paint.net\n\ncinst ccleaner\n\ncinst grepwin\n\ncinst 7zip\n\ncinst thunderbird\n\n## Web Browsers\n\ncinst GoogleChrome\n\ncinst Firefox"
}
] |
powershell
|
chosen
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.