conversations
listlengths 2
3
| source
stringclasses 1
value | stack
stringclasses 1
value |
|---|---|---|
[
{
"from": "system",
"value": "Install requirements with pip on appveyor.\n"
},
{
"from": "human",
"value": "# Sample script to install Python and pip under Windows\n# Authors: Olivier Grisel and Kyle Kastner\n# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/\n\n$GET_PIP_URL = \"https://bootstrap.pypa.io/get-pip.py\"\n$GET_PIP_PATH = \"C:\\get-pip.py\"\n\n\nfunction InstallPip ($python_home) {\n $pip_path = $python_home + \"/Scripts/pip.exe\"\n $python_path = $python_home + \"/python.exe\"\n if (-not(Test-Path $pip_path)) {\n Write-Host \"Installing pip...\"\n $webclient = New-Object System.Net.WebClient\n $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)\n Write-Host \"Executing:\" $python_path $GET_PIP_PATH\n Start-Process -FilePath \"$python_path\" -ArgumentList \"$GET_PIP_PATH\" -Wait -Passthru\n } else {\n Write-Host \"pip already installed.\"\n }\n}\n\nfunction InstallPackage ($python_home, $pkg) {\n $pip_path = $python_home + \"/Scripts/pip.exe\"\n & $pip_path install $pkg\n}\n\nfunction main () {\n InstallPip $env:PYTHON\n InstallPackage $env:PYTHON pytest\n}\n\nmain\n"
},
{
"from": "gpt",
"value": "# Sample script to install Python and pip under Windows\n# Authors: Olivier Grisel and Kyle Kastner\n# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/\n\n$GET_PIP_URL = \"https://bootstrap.pypa.io/get-pip.py\"\n$GET_PIP_PATH = \"C:\\get-pip.py\"\n\n\nfunction InstallPip ($python_home) {\n $pip_path = $python_home + \"/Scripts/pip.exe\"\n $python_path = $python_home + \"/python.exe\"\n if (-not(Test-Path $pip_path)) {\n Write-Host \"Installing pip...\"\n $webclient = New-Object System.Net.WebClient\n $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)\n Write-Host \"Executing:\" $python_path $GET_PIP_PATH\n Start-Process -FilePath \"$python_path\" -ArgumentList \"$GET_PIP_PATH\" -Wait -Passthru\n } else {\n Write-Host \"pip already installed.\"\n }\n}\n\nfunction InstallPackage ($python_home, $pkg) {\n $pip_path = $python_home + \"/Scripts/pip.exe\"\n & $pip_path install $pkg\n}\n\nfunction InstallRequirements ($python_home, $reqs) {\n $pip_path = $python_home + \"/Scripts/pip.exe\"\n & $pip_path install -r $reqs\n}\n\nfunction main () {\n InstallPip $env:PYTHON\n InstallReqs $env:PYTHON -r requirements.txt\n InstallPackage $env:PYTHON pytest\n}\n\nmain\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script to configure windows 10"
},
{
"from": "gpt",
"value": "# To use this:\n# 1. Enable running scripts (must be run as an administrator):\n# Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force\n# 2. Unblock this file:\n# Unblock-File -Path ./configure-windows-10.ps1\n# 3. Run the file\n# ./configure-windows-10.ps1\n\n# Disable Cortana\n# Source: https://gallery.technet.microsoft.com/scriptcenter/How-to-disable-Cortana-on-b44924a4\n# License: TechNet terms of use (https://gallery.technet.microsoft.com/scriptcenter/site/How-to-disable-Cortana-on-b44924a4/eulapartial?licenseType=TechNet)\nFunction DisableCortana {\n $path = \"HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\Windows Search\" \n IF (!(Test-Path -Path $path)) { \n New-Item -Path \"HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\" -Name \"Windows Search\"\n } \n Set-ItemProperty -Path $path -Name \"AllowCortana\" -Value 0 \n # Restart Explorer to change it immediately \n Stop-Process -name explorer\n}\nDisableCortana\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove the Unity3D.DLLs PS module if its loaded.\n"
},
{
"from": "human",
"value": "param($installPath, $toolsPath, $package, $project)\n\nImport-Module (Join-Path $toolsPath Unity3D.DLLs.psd1)"
},
{
"from": "gpt",
"value": "# Copyright (c) 2013 Precision Mojo, LLC.\n#\n# This file is part of the Unity3D.DLLs project (< URL >) which is distributed under the MIT License.\n# Refer to the LICENSE.MIT.md document located in the project directory for licensing terms.\n\nparam($installPath, $toolsPath, $package, $project)\n\n# Remove the module if it's loaded\nif (Get-Module | ? { $_.Name -eq \"Unity3D.DLLs\" })\n{\n\tRemove-Module Unity3D.DLLs\n}\n\nImport-Module (Join-Path $toolsPath Unity3D.DLLs.psd1)\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "windows-wix: Add a simple helper script\n"
},
{
"from": "gpt",
"value": "# TODO: This script should be replaced with wixproj and/or CPack.\n# TODO: Add Debug mode to override CompressionLevel with \"none\".\n\n# Sample command:\n# .\\build.ps1 -Arch x64 -Version 0.4.0 -PackagePath \"c:\\tmp\\zeal-0.4.0-windows-x64\" -SignMsi\n\nparam(\n [Parameter(Mandatory=$True)]\n [ValidatePattern(\"[0-9].[0-9].[0-9]\")]\n [string]$Version,\n\n [Parameter(Mandatory=$True)]\n [ValidateSet('x86', 'x64')]\n [string]$Arch,\n\n [Parameter(Mandatory=$True)]\n [string]$PackagePath,\n\n [Switch]$SignMsi\n)\n\n$BaseFilename = \"zeal-$Version-windows-$Arch\"\n$WixobjFilename = \"$BaseFilename.wixobj\"\n$MsiFilename = \"$BaseFilename.msi\"\nfunction CleanUp {\n Remove-Item -Path \"$WixobjFilename\"\n\n # We are not going to build patches for now.\n # More infor about wixpdb: https://www.firegiant.com/wix/tutorial/upgrades-and-modularization/patchwork/\n Remove-Item -Path \"$BaseFilename.wixpdb\"\n}\n\nWrite-Output \"Building $MsiFilename...\"\n\nWrite-Output \"Running candle...\"\n& candle.exe -nologo -pedantic -wx -arch \"$Arch\" -dAppVersion=\"$Version\" -dAppPackageDir=\"$PackagePath\" -o \"$WixobjFilename\" zeal.wxs\nif ($LastExitCode -ne 0) {\n CleanUp\n throw \"candle failed with exit code $LastExitCode.\"\n}\n\n\nWrite-Output \"Running light...\"\n& light.exe -nologo -pedantic -wx -ext WixUIExtension -o \"$MsiFilename\" \"$WixobjFilename\"\nif ($LastExitCode -ne 0) {\n CleanUp\n throw \"light failed with exit code $LastExitCode.\"\n}\n\nif ($SignMsi) {\n $KeyName = \"Open Source Developer, Oleg Shparber\"\n $Description = \"Zeal $Version Installer\"\n $Url = \"https://zealdocs.org\"\n $TimestampServerUrl = \"http://timestamp.comodoca.com/authenticode\"\n\n Write-Output \"Signing $MsiFilename...\"\n & signtool sign /v /n \"$KeyName\" /d \"$Description\" /du \"$Url\" /t \"$TimestampServerUrl\" \"$MsiFilename\"\n if ($LastExitCode -ne 0) {\n CleanUp\n throw \"signtool failed with exit code $LastExitCode.\"\n }\n}\n\nCleanUp\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use unzip instead of .NET\n"
},
{
"from": "human",
"value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\nWrite-Host \"Installing git\"\nchoco install -y git.install\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\n[System.IO.Compression.ZipFile]::ExtractToDirectory('master.zip', 'windows-setup')\ncd windows-setup\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\n# Write-Host \"Rebooting..\"\n# shutdown /r /t 0\n"
},
{
"from": "gpt",
"value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\nWrite-Host \"Installing unzip\"\nchoco install -y unzip\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\nunzip master.zip\ncd windows-setup-master\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\n# Write-Host \"Rebooting..\"\n# shutdown /r /t 0\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Make sure IIS websockets is installed\n"
},
{
"from": "human",
"value": "$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition\n\n& \"$ScriptPath\\PowerShellProfile\\Microsoft.PowerShell_profile.ps1\"\n\n## Development Tools for .NET\n\nchoco install VisualStudioCommunity2013 -packageParameters \"/Features:WebTools\"\n\nchoco install webpi\nchoco install webpicmd\n\nchoco install IIS-WebServerRole -source windowsfeatures\nchoco install IIS-ASPNET45 -source windowsfeatures\n\nchoco install SQLManagementStudio -source webpi\n"
},
{
"from": "gpt",
"value": "$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition\n\n& \"$ScriptPath\\PowerShellProfile\\Microsoft.PowerShell_profile.ps1\"\n\n## Development Tools for .NET\n\nchoco install VisualStudioCommunity2013 -packageParameters \"/Features:WebTools\"\n\nchoco install webpi\nchoco install webpicmd\n\nchoco install IIS-WebServerRole -source windowsfeatures\nchoco install IIS-ASPNET45 -source windowsfeatures\nchoco install IIS-WebSockets -source windowsfeatures\n\nchoco install SQLManagementStudio -source webpi"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update registry 2.5.1, but still does not work inside a container\n"
},
{
"from": "human",
"value": "mkdir -p C:\\registry-v2\ndocker run -d -p 5000:5000 -v \"C:\\registry-v2:C:\\registry\" stefanscherer/registry-windows:2.4.1\n"
},
{
"from": "gpt",
"value": "mkdir -p C:\\registry-v2\ndocker run -d -p 5000:5000 -v \"C:\\registry-v2:C:\\registry\" stefanscherer/registry-windows:2.5.1\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Modify Pester test for New-Object\n"
},
{
"from": "human",
"value": "Describe \"New-Object\" {\n It \"should create an object with 4 fields\" {\n\t$o = New-Object psobject\n\t$val = $o.GetType()\n\n\t$val.IsPublic | Should Not BeNullOrEmpty\n\t$val.Name | Should Not BeNullOrEmpty\n\t$val.IsSerializable | Should Not BeNullOrEmpty\n\t$val.BaseType | Should Not BeNullOrEmpty\n\n\t$val.IsPublic | Should Be $true\n\t$val.IsSerializable | Should Be $false\n\t$val.Name | Should Be 'PSCustomObject'\n\t$val.BaseType | Should Be 'System.Object'\n }\n\n It \"should create an object with using Property switch\" {\n $hash = @{\n FirstVal = 'test1'\n SecondVal = 'test2'\n }\n\t$o = New-Object psobject -Property $hash\n\n\t$o.FirstVal | Should Be 'test1'\n\t$o.SecondVal | Should Be 'test2'\n }\n\n It \"should create a .Net object with using ArgumentList switch\" {\n\t$o = New-Object -TypeName System.Version -ArgumentList \"1.2.3.4\"\n $val = $o.GetType()\n\n\t$o | Should Be \"1.2.3.4\"\n \n $val.IsPublic | Should Be $true\n\t$val.IsSerializable | Should Be $false\n\t$val.Name | Should Be 'Version'\n\t$val.BaseType | Should Be 'System.Object'\n }\n}\n"
},
{
"from": "gpt",
"value": "Describe \"New-Object\" {\n It \"should create an object with 4 fields\" {\n $o = New-Object psobject\n\t $val = $o.GetType()\n\n\t $val.IsPublic | Should Not BeNullOrEmpty\n\t $val.Name | Should Not BeNullOrEmpty\n\t $val.IsSerializable | Should Not BeNullOrEmpty\n\t $val.BaseType | Should Not BeNullOrEmpty\n\n\t $val.IsPublic | Should Be $true\n\t $val.IsSerializable | Should Be $false\n\t $val.Name | Should Be 'PSCustomObject'\n\t $val.BaseType | Should Be 'System.Object'\n }\n\n It \"should create an object with using Property switch\" {\n $hash = @{\n FirstVal = 'test1'\n SecondVal = 'test2'\n }\n\t $o = New-Object psobject -Property $hash\n\n\t $o.FirstVal | Should Be 'test1'\n\t $o.SecondVal | Should Be 'test2'\n }\n\n It \"should create a .Net object with using ArgumentList switch\" {\n\t $o = New-Object -TypeName System.Version -ArgumentList \"1.2.3.4\"\n $o.GetType() | Should Be ([System.Version])\n\n\t $o | Should Be \"1.2.3.4\"\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add a script to install the PowerShell profile\n"
},
{
"from": "gpt",
"value": "# Overwrite the current PowerShell profile, and hardlink that path to the\n# profile in this repo.\nRemove-Item $profile\nNew-Item -ItemType HardLink -Path $profile -Target \"$PSScriptRoot\\Microsoft.PowerShell_profile.ps1\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Correct default config file name for nginx\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = \"stop\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/etc/\", \"$env:PKG_PATH/etc/dcos-adminrouter/\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/etc/dcos-adminrouter/conf/\", \"$env:PKG_PATH/etc/dcos-adminrouter/logs/\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/bin/\", \"$env:PKG_PATH/bin/dcos-adminrouter/\"\nNew-Item -ItemType Directory \"c:\\tmp\"\n\nAdd-Type -AssemblyName System.IO.Compression.FileSystem\nfunction Unzip {\n param([string]$zipfile, [string]$outpath)\n [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)\n}\n\nUnzip \"c:\\pkg\\src\\OpenResty\\openresty-1.15.8.2-win64.zip\" \"c:/tmp/openresty\"\n\nls \"C:\\pkg\\build\\extra\\src\\\"\n\nCopy-Item -Recurse -Path \"c:\\tmp\\openresty\\openresty-1.15.8.2-win64\\*\" \"$env:PKG_PATH\\bin\\dcos-adminrouter\\\"\nCopy-Item -Recurse -Path \"C:\\pkg\\build\\extra\\src\\*\" \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\\"\nCopy-Item \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\nginx.agent.conf\" \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\nginx.conf\"\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = \"stop\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/etc/\", \"$env:PKG_PATH/etc/dcos-adminrouter/\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/etc/dcos-adminrouter/conf/\", \"$env:PKG_PATH/etc/dcos-adminrouter/logs/\"\nNew-Item -ItemType Directory -Path \"$env:PKG_PATH/bin/\", \"$env:PKG_PATH/bin/dcos-adminrouter/\"\nNew-Item -ItemType Directory \"c:\\tmp\"\n\nAdd-Type -AssemblyName System.IO.Compression.FileSystem\nfunction Unzip {\n param([string]$zipfile, [string]$outpath)\n [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)\n}\n\nUnzip \"c:\\pkg\\src\\OpenResty\\openresty-1.15.8.2-win64.zip\" \"c:/tmp/openresty\"\n\nls \"C:\\pkg\\build\\extra\\src\\\"\n\nCopy-Item -Recurse -Path \"c:\\tmp\\openresty\\openresty-1.15.8.2-win64\\*\" \"$env:PKG_PATH\\bin\\dcos-adminrouter\\\"\nCopy-Item -Recurse -Path \"C:\\pkg\\build\\extra\\src\\*\" \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\\"\nCopy-Item \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\nginx.windows.agent.conf\" \"$env:PKG_PATH\\etc\\dcos-adminrouter\\conf\\nginx.conf\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script to update MRTK version across all files\n"
},
{
"from": "gpt",
"value": "<#\r\n.SYNOPSIS\r\n Updates Mixed Reality Toolkit version (i.e. major.minor.patch) across all known files.\r\n#>\r\nparam(\r\n [Parameter(Position=0,mandatory=$true)]\r\n [string]$NewVersion\r\n# [ValidatePattern(\"^\\d+\\.\\d+\\.\\d+$\")]\r\n# [string]$Version,\r\n)\r\n\r\nPush-Location # save current working directory\r\n\r\nSet-Location $PSScriptRoot\r\n$GitRoot = (git rev-parse --show-toplevel) | Out-String\r\n$GitRoot = ($GitRoot -replace \"/\", \"\\\").Trim()\r\n\r\n$FullProductName = \"Microsoft Mixed Reality Toolkit\"\r\n\r\n$Errors = @()\r\n\r\nforeach ($file in (Get-ChildItem -Path $GitRoot -Recurse))\r\n{\r\n if ($file.Name -eq \"version.txt\")\r\n {\r\n $contents = Get-Content -Path $file.FullName\r\n $pattern = \"(?<=Microsoft Mixed Reality Toolkit\\s+)(\\d+\\.\\d+\\.\\d+)\"\r\n $match = [regex]::Match($contents, $pattern)\r\n if ($match.Success)\r\n {\r\n $FromVersion = $match.captures.groups[1].ToString()\r\n if ($FromVersion -eq $NewVersion)\r\n {\r\n Write-Host \"$($file.FullName): version up to date ($NewVersion)\"\r\n }\r\n else\r\n {\r\n Write-Host \"$($file.FullName): updating version from $FromVersion to $NewVersion\"\r\n $contents = $contents -replace $pattern, $NewVersion\r\n $contents | Out-File -FilePath $file.FullName -Encoding UTF8\r\n }\r\n }\r\n else\r\n {\r\n $errors += \"$($file.FullName): pattern not found: $pattern\"\r\n }\r\n }\r\n}\r\n\r\nPop-Location # restore original working directory\r\n\r\nif ($errors)\r\n{\r\n Write-Host -ForegroundColor Red \"Errors:\"\r\n foreach ($line in $errors)\r\n {\r\n Write-Host -ForegroundColor Red \" $line\"\r\n }\r\n exit 1\r\n}\r\nelse\r\n{\r\n Write-Host\r\n Write-Host -ForegroundColor Green \"Version updated to $NewVersion. Please review all changes before submitting.\"\r\n Write-Host\r\n exit 0\r\n}\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update PS script to improve version generation\n\n+semver: minor"
},
{
"from": "human",
"value": "$publishVersion = $Env:GitVersion_MajorMinorPatch+\".\"+$Env:GitVersion_BuildMetaData\n\n# Regular expression pattern to find the version in the build number \n# and then apply it to the assemblies\n$versionRegex = \"\\d+\\.\\d+\\.\\d+\\.\\d+\"\n\n$vsixManifestSearchPattern = \"./source.extension.vsixmanifest\"\n$vsixManifestCollection = (Get-ChildItem $vsixManifestSearchPattern -Recurse)\n\nforeach($file in $vsixManifestCollection)\n{\n $filecontent = Get-Content($file)\n attrib $file -r\n $filecontent -replace $versionRegex, $publishVersion | Out-File $file -Encoding utf8\n \"Update version in VSIX manifest to $publishVersion\"| Write-Host -ForegroundColor White\n}\n"
},
{
"from": "gpt",
"value": "if ($env:APPVEYOR_PULL_REQUEST_NUMBER)\n{\n # version for pull requests\n $publishVersion = $Env:GitVersion_MajorMinorPatch+\".\"+$Env:GitVersion_CommitsSinceVersionSource \n}\nelse \n{\n # version for commits other than PRs\n $publishVersion = $Env:GitVersion_AssemblySemVer \n}\n\n# Regular expression pattern to find the version in the build number \n# and then apply it to the assemblies\n$versionRegex = \"\\d+\\.\\d+\\.\\d+\\.\\d+\"\n\n$vsixManifestSearchPattern = \"./source.extension.vsixmanifest\"\n$vsixManifestCollection = (Get-ChildItem $vsixManifestSearchPattern -Recurse)\n\nforeach($file in $vsixManifestCollection)\n{\n $filecontent = Get-Content($file)\n attrib $file -r\n $filecontent -replace $versionRegex, $publishVersion | Out-File $file -Encoding utf8\n \"Update version in VSIX manifest to $publishVersion\"| Write-Host -ForegroundColor White\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add new PSScriptAnalyzer rule options\n"
},
{
"from": "human",
"value": "@{\n IncludeRules = @('*')\n\n Rules = @{\n # The statement assignment alignment check applies to the hashtable\n # assignment itself and not just its properties.\n PSAlignAssignmentStatement = @{\n Enable = $false\n CheckHashtable = $true\n }\n\n PSPlaceCloseBrace = @{\n Enable = $true\n IgnoreOneLineBlock = $true\n NewLineAfter = $false\n NoEmptyLineBefore = $false\n }\n\n PSPlaceOpenBrace = @{\n Enable = $true\n IgnoreOneLineBlock = $true\n NewLineAfter = $true\n OnSameLine = $true\n }\n\n PSProvideCommentHelp = @{\n Enable = $true\n BlockComment = $true\n ExportedOnly = $true\n Placement = 'begin'\n VSCodeSnippetCorrection = $false\n }\n\n PSUseConsistentIndentation = @{\n Enable = $true\n IndentationSize = 4\n Kind = 'space'\n }\n\n # CheckOperator doesn't work with aligned hashtable assignment\n # statements (GitHub Issue #769).\n PSUseConsistentWhitespace = @{\n Enable = $true\n CheckOpenBrace = $true\n CheckOpenParen = $true\n CheckOperator = $false\n CheckSeparator = $true\n }\n }\n}\n"
},
{
"from": "gpt",
"value": "@{\n IncludeRules = @('*')\n\n Rules = @{\n # The statement assignment alignment check applies to the hashtable\n # assignment itself and not just its properties.\n PSAlignAssignmentStatement = @{\n Enable = $false\n CheckHashtable = $true\n }\n\n PSPlaceCloseBrace = @{\n Enable = $true\n IgnoreOneLineBlock = $true\n NewLineAfter = $false\n NoEmptyLineBefore = $false\n }\n\n PSPlaceOpenBrace = @{\n Enable = $true\n IgnoreOneLineBlock = $true\n NewLineAfter = $true\n OnSameLine = $true\n }\n\n PSProvideCommentHelp = @{\n Enable = $true\n BlockComment = $true\n ExportedOnly = $true\n Placement = 'begin'\n VSCodeSnippetCorrection = $false\n }\n\n PSUseConsistentIndentation = @{\n Enable = $true\n IndentationSize = 4\n Kind = 'space'\n PipelineIndentation = 'IncreaseIndentationForFirstPipeline'\n }\n\n # CheckOperator doesn't work with aligned hashtable assignment\n # statements (GitHub Issue #769).\n PSUseConsistentWhitespace = @{\n Enable = $true\n CheckInnerBrace = $true\n CheckOpenBrace = $true\n CheckOpenParen = $true\n CheckOperator = $false\n CheckPipe = $true\n CheckSeparator = $true\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Extend Vision Test timeout, because it has been timing out lately.\n\nChange-Id: I449f7eb9420d52a6c68e5730eb63df3bfbb44e67\n"
},
{
"from": "human",
"value": "# Copyright(c) 2017 Google Inc.\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\ndotnet restore\ndotnet test --test-adapter-path:. --logger:junit"
},
{
"from": "gpt",
"value": "# Copyright(c) 2017 Google Inc.\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.\nImport-Module ..\\..\\..\\BuildTools.psm1\n\nSet-TestTimeout 600\n\ndotnet restore\ndotnet test --test-adapter-path:. --logger:junit"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix the regex used for detecting the Output Window reference\n"
},
{
"from": "human",
"value": "param($installPath, $toolsPath, $package, $project)\n\nforeach ($reference in $project.Object.References)\n{\n\tswitch -regex ($reference.Name.ToLowerInvariant())\n\t{\n\t\"^tvl\\.visualstudio\\.outputwindow.interfaces$\"\n\t\t{\n\t\t\t$reference.CopyLocal = $false;\n\t\t}\n\tdefault\n\t\t{\n\t\t\t# ignore\n\t\t}\n\t}\n}\n"
},
{
"from": "gpt",
"value": "param($installPath, $toolsPath, $package, $project)\n\nforeach ($reference in $project.Object.References)\n{\n\tswitch -regex ($reference.Name.ToLowerInvariant())\n\t{\n\t\"^tvl\\.visualstudio\\.outputwindow\\.interfaces$\"\n\t\t{\n\t\t\t$reference.CopyLocal = $false;\n\t\t}\n\tdefault\n\t\t{\n\t\t\t# ignore\n\t\t}\n\t}\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove 2016 tag, order in manifest list has been fixed\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = 'Stop'\n$ProgressPreference = 'SilentlyContinue'\n\n$dockerVersion=\"18.02.0-ce\"\n\nWrite-Host \"Installing Docker CLI $dockerVersion\"\ndocker pull stefanscherer/docker-cli-windows:$dockerVersion-2016\ndocker create stefanscherer/docker-cli-windows:$dockerVersion-2016\ndocker cp \"$(docker ps -ql):docker.exe\" $env:TEMP\\docker.exe\ncp $env:TEMP\\docker.exe \"$env:ProgramFiles\\docker\\docker.exe\"\n\nWrite-Host \"Activating experimental features\"\n$configJson = \"$env:USERPROFILE\\.docker\\config.json\"\n$config = @{}\nif (Test-Path $configJson) {\n $config = (Get-Content $configJson) -join \"`n\" | ConvertFrom-Json\n}\n$config = $config | Add-Member(@{ experimental = 'enabled' }) -Force -PassThru\n$config | ConvertTo-Json | Set-Content $configJson -Encoding Ascii\n\ndocker version\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = 'Stop'\n$ProgressPreference = 'SilentlyContinue'\n\n$dockerVersion=\"18.02.0-ce\"\n\nWrite-Host \"Installing Docker CLI $dockerVersion\"\ndocker pull stefanscherer/docker-cli-windows:$dockerVersion\ndocker create stefanscherer/docker-cli-windows:$dockerVersion\ndocker cp \"$(docker ps -ql):docker.exe\" $env:TEMP\\docker.exe\ncp $env:TEMP\\docker.exe \"$env:ProgramFiles\\docker\\docker.exe\"\n\nWrite-Host \"Activating experimental features\"\n$configJson = \"$env:USERPROFILE\\.docker\\config.json\"\n$config = @{}\nif (Test-Path $configJson) {\n $config = (Get-Content $configJson) -join \"`n\" | ConvertFrom-Json\n}\n$config = $config | Add-Member(@{ experimental = 'enabled' }) -Force -PassThru\n$config | ConvertTo-Json | Set-Content $configJson -Encoding Ascii\n\ndocker version\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Create package directory if not exists\n"
},
{
"from": "human",
"value": "Task Default -depends Test\n\nTask Build {\n Exec { msbuild \"NPloy.sln\" }\n Exec { & copy NPloy.Console\\bin\\debug\\NPloy.Console.exe NPloy.Console\\bin\\debug\\NPloy.exe}\n Exec { & .\\packages\\LibZ.Bootstrap.1.0.3.7\\tools\\libz.exe inject-dll --assembly NPloy.Console\\bin\\debug\\NPloy.exe --include NPloy.Console\\bin\\debug\\*.dll --move }\n Exec { & xcopy /y /e NPloy.Console\\bin\\debug\\nploy.exe ..\\install\\}\n}\n\nTask UnitTest {\n Exec { & packages\\NUnit.Runners.2.6.3\\tools\\nunit-console.exe NPloy.Console.UnitTests\\bin\\debug\\NPloy.Console.UnitTests.dll /xml=UnitTestResult.xml } \n}\n\nTask IntegrationTest {\n Exec { & packages\\NUnit.Runners.2.6.3\\tools\\nunit-console.exe NPloy.Console.IntegrationTests\\bin\\debug\\NPloy.Console.IntegrationTests.dll /xml=IntegrationTestResult.xml } \n}\n\nTask Test -depends Build, UnitTest {\n}\n\nTask Pack -depends Test {\n\tExec { & .nuget\\nuget pack NPloy.Console\\NPloy.Console.nuspec -NoPackageAnalysis -OutputDirectory ..\\packages } \n}"
},
{
"from": "gpt",
"value": "Task Default -depends Test\n\nTask Build {\n Exec { msbuild \"NPloy.sln\" }\n Exec { & copy NPloy.Console\\bin\\debug\\NPloy.Console.exe NPloy.Console\\bin\\debug\\NPloy.exe}\n Exec { & .\\packages\\LibZ.Bootstrap.1.0.3.7\\tools\\libz.exe inject-dll --assembly NPloy.Console\\bin\\debug\\NPloy.exe --include NPloy.Console\\bin\\debug\\*.dll --move }\n Exec { & xcopy /y /e NPloy.Console\\bin\\debug\\nploy.exe ..\\install\\}\n}\n\nTask UnitTest {\n Exec { & packages\\NUnit.Runners.2.6.3\\tools\\nunit-console.exe NPloy.Console.UnitTests\\bin\\debug\\NPloy.Console.UnitTests.dll /xml=UnitTestResult.xml } \n}\n\nTask IntegrationTest {\n Exec { & packages\\NUnit.Runners.2.6.3\\tools\\nunit-console.exe NPloy.Console.IntegrationTests\\bin\\debug\\NPloy.Console.IntegrationTests.dll /xml=IntegrationTestResult.xml } \n}\n\nTask Test -depends Build, UnitTest {\n}\n\nTask Pack -depends Test {\n\tExec { \n\t\tNew-Item -ItemType Directory -Force -Path ..\\packages \n\t\t& .nuget\\nuget pack NPloy.Console\\NPloy.Console.nuspec -NoPackageAnalysis -OutputDirectory ..\\packages \n\t\t} \n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Install Insomnia REST API client\n\n"
},
{
"from": "human",
"value": "### Install handy tools and apps for my dev machine\n### Run this script from an administrative shell\n\nSet-ExecutionPolicy RemoteSigned\n\n# Install Chocolatey\nInvoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n# Install some software with Chocolatey\nchoco install -y 7zip\nchoco install -y dotnetcore-sdk\nchoco install -y git\n#choco install -y github-desktop # Github Desktop gets updates so often that it's hard for the Chocolatey package to keep up\nchoco install -y gitkraken\nchoco install -y googlechrome\nchoco install -y hyper\nchoco install -y keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts\nchoco install -y notepadplusplus\nchoco install -y poshgit\nchoco install -y postman\nchoco install -y rdcman\n#choco install -y slack # Slack gets updates so often that it's annoying to have Chocolatey reinstall it each time\nchoco install -y sql-server-management-studio\n#choco install -y toggl # The Toggl Desktop Chocolatey package is significantly behind as of May 2017, so I'll install it manually\n#choco install -y visualstudiocode # VS Code gets updates so often that it's hard for the Chocolatey package to keep up\nRefreshEnv.cmd\n\n# Install some software with npm\nnpm install -g @angular/cli\nnpm install -g typescript\n"
},
{
"from": "gpt",
"value": "### Install handy tools and apps for my dev machine\n### Run this script from an administrative shell\n\nSet-ExecutionPolicy RemoteSigned\n\n# Install Chocolatey\nInvoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n# Install some software with Chocolatey\nchoco install -y 7zip\nchoco install -y dotnetcore-sdk\nchoco install -y git\n#choco install -y github-desktop # Github Desktop gets updates so often that it's hard for the Chocolatey package to keep up\nchoco install -y gitkraken\nchoco install -y googlechrome\nchoco install -y hyper\nchoco install -y insomnia-rest-api-client\nchoco install -y keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts\nchoco install -y notepadplusplus\nchoco install -y poshgit\nchoco install -y postman\nchoco install -y rdcman\n#choco install -y slack # Slack gets updates so often that it's annoying to have Chocolatey reinstall it each time\nchoco install -y sql-server-management-studio\n#choco install -y toggl # The Toggl Desktop Chocolatey package is significantly behind as of May 2017, so I'll install it manually\n#choco install -y visualstudiocode # VS Code gets updates so often that it's hard for the Chocolatey package to keep up\nRefreshEnv.cmd\n\n# Install some software with npm\nnpm install -g @angular/cli\nnpm install -g typescript\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add test for PlaceOpenBrace rule\n"
},
{
"from": "human",
"value": "Import-Module PSScriptAnalyzer\n$ruleName = \"PlaceOpenBrace\"\n\nDescribe \"PlaceOpenBrace\" {\n Context \"\" {\n It \"\" {\n }\n }\n}\n"
},
{
"from": "gpt",
"value": "Import-Module PSScriptAnalyzer\n$ruleName = \"PSPlaceOpenBrace\"\n\nDescribe \"PlaceOpenBrace on same line\" {\n Context \"When a open brace is on a new line\" {\n BeforeAll{\n $def = @'\nfunction foo ($param1)\n{\n\n}\n'@\n $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -IncludeRule $ruleName\n }\n\n It \"Should find a violation\" {\n $violations.Count | Should Be 1\n }\n\n It \"Should mark only the open brace\" {\n $violations[0].Extent.Text | Should Be '{'\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Build script - license file name case fix\n"
},
{
"from": "human",
"value": "param(\n\t[string]$Configuration,\n\t[string]$Version\n)\n\nWrite-Host \"Configuration: $Configuration\"\nWrite-Host \"Version: $Version\"\n\n$ErrorActionPreference = \"Stop\"\n\nWrite-Host \"Building the NuGet package...\"\nStart-Process -FilePath \"$PSScriptRoot\\Nuget.exe\" -WorkingDirectory \"..\\LH.TestObjects\\\" -Wait -NoNewWindow -ArgumentList \"pack -Verbosity Detailed -Prop Configuration=$Configuration\"\n# & \"$PSScriptRoot\\Nuget.exe\" pack -Verbosity Detailed -Prop Configuration=$Configuration\n\nWrite-Host \"Creating the website artifacts...\"\nNew-Item \"..\\_Artifacts\\v$Version\" -ItemType Directory\n\nCopy-Item \"..\\License\" \"..\\_Artifacts\\v$Version\\License.txt\"\nCopy-Item \"..\\Logo_128.png\" \"..\\_Artifacts\\v$Version\\nuget-icon.png\"\nCopy-Item \"..\\LH.TestObjects\\*.nupkg\" \"..\\_Artifacts\\\""
},
{
"from": "gpt",
"value": "param(\n\t[string]$Configuration,\n\t[string]$Version\n)\n\nWrite-Host \"Configuration: $Configuration\"\nWrite-Host \"Version: $Version\"\n\n$ErrorActionPreference = \"Stop\"\n\nWrite-Host \"Building the NuGet package...\"\nStart-Process -FilePath \"$PSScriptRoot\\Nuget.exe\" -WorkingDirectory \"..\\LH.TestObjects\\\" -Wait -NoNewWindow -ArgumentList \"pack -Verbosity Detailed -Prop Configuration=$Configuration\"\n# & \"$PSScriptRoot\\Nuget.exe\" pack -Verbosity Detailed -Prop Configuration=$Configuration\n\nWrite-Host \"Creating the website artifacts...\"\nNew-Item \"..\\_Artifacts\\v$Version\" -ItemType Directory\n\nCopy-Item \"..\\License\" \"..\\_Artifacts\\v$Version\\license.txt\"\nCopy-Item \"..\\Logo_128.png\" \"..\\_Artifacts\\v$Version\\nuget-icon.png\"\nCopy-Item \"..\\LH.TestObjects\\*.nupkg\" \"..\\_Artifacts\\\""
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add setting preset for OTBS 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 = $true\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": "system",
"value": "Use dotnet nuget instead of nuget\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 --configuration Release --nologo /p:ContinuousIntegrationBuild=true;\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 /p:ContinuousIntegrationBuild=true;\n dotnet nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).nupkg\";\n dotnet nuget push \"$($folder.FullName)\\bin\\Release\\$($folder.Name).$($Version).snupkg\";\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add Set-GkeCluster to list of beta cmdlets\n"
},
{
"from": "human",
"value": "# List of beta cmdlets.\n$cmdletsToBeExported = @(\"Get-GcLogEntry\", \"New-GcLogEntry\", \"New-GcLogMonitoredResource\",\n \"Get-GcLog\", \"Remove-GcLog\", \"New-GcLogSink\", \"Get-GcLogSink\",\n \"Update-GcLogSink\", \"Remove-GcLogSink\", \"Get-GcpsTopic\",\n \"New-GcpsTopic\", \"Remove-GcpsTopic\", \"New-GcpsSubscription\",\n \"Get-GcpsSubscription\", \"Set-GcpsSubscriptionConfig\",\n \"Remove-GcpsSubscription\", \"New-GcpsMessage\", \"Publish-GcpsMessage\",\n \"Get-GcpsMessage\", \"Set-GcpsAckDeadline\", \"Send-GcpsAck\"\n \"Get-GcIamPolicyBinding\", \"Add-GcIamPolicyBinding\",\n \"Get-BqDataset\", \"Set-BqDataset\", \"New-BqDataset\", \"Remove-BqDataset\",\n \"Get-BqTable\", \"Set-BqTable\", \"New-BqTable\", \"Remove-BqTable\",\n \"New-BqSchema\", \"Set-BqSchema\", \"Add-BqTableRows\", \"Get-BqTableRows\",\n \"Get-BqJob\", \"Start-BqJob\", \"Receive-BqJob\", \"Stop-BqJob\",\n \"Get-GkeCluster\", \"New-GkeNodeConfig\", \"Add-GkeCluster\",\n \"Remove-GkeCluster\", \"Add-GkeNodePool\", \"Get-GkeNodePool\",\n \"New-GkeNodePool\")\n$cmdletsToBeExported\n"
},
{
"from": "gpt",
"value": "# List of beta cmdlets.\n$cmdletsToBeExported = @(\"Get-GcLogEntry\", \"New-GcLogEntry\", \"New-GcLogMonitoredResource\",\n \"Get-GcLog\", \"Remove-GcLog\", \"New-GcLogSink\", \"Get-GcLogSink\",\n \"Update-GcLogSink\", \"Remove-GcLogSink\", \"Get-GcpsTopic\",\n \"New-GcpsTopic\", \"Remove-GcpsTopic\", \"New-GcpsSubscription\",\n \"Get-GcpsSubscription\", \"Set-GcpsSubscriptionConfig\",\n \"Remove-GcpsSubscription\", \"New-GcpsMessage\", \"Publish-GcpsMessage\",\n \"Get-GcpsMessage\", \"Set-GcpsAckDeadline\", \"Send-GcpsAck\"\n \"Get-GcIamPolicyBinding\", \"Add-GcIamPolicyBinding\",\n \"Get-BqDataset\", \"Set-BqDataset\", \"New-BqDataset\", \"Remove-BqDataset\",\n \"Get-BqTable\", \"Set-BqTable\", \"New-BqTable\", \"Remove-BqTable\",\n \"New-BqSchema\", \"Set-BqSchema\", \"Add-BqTableRows\", \"Get-BqTableRows\",\n \"Get-BqJob\", \"Start-BqJob\", \"Receive-BqJob\", \"Stop-BqJob\",\n \"Get-GkeCluster\", \"New-GkeNodeConfig\", \"Add-GkeCluster\",\n \"Set-GkeCluster\", \"Remove-GkeCluster\", \"Add-GkeNodePool\",\n \"Get-GkeNodePool\", \"New-GkeNodePool\")\n$cmdletsToBeExported\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "tests(Compute): Increase the overall timeout for the full test run.\n- If several instances of tests are running in parallel, the usage export bucket tests will need to retry some, and that will consume time.\n"
},
{
"from": "human",
"value": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# https://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,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\ndotnet restore --force\ndotnet test --no-restore --test-adapter-path:. --logger:junit 2>&1 | %{ \"$_\" }"
},
{
"from": "gpt",
"value": "# Copyright 2021 Google LLC\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# https://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,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport-module -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\nSet-TestTimeout 600\n\ndotnet restore --force\ndotnet test --no-restore --test-adapter-path:. --logger:junit 2>&1 | %{ \"$_\" }"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Make sure to convert the whole object back to the JSON file\n"
},
{
"from": "human",
"value": "param (\n[string] $filePath,\n[string] $major,\n[string] $minor,\n[string] $patch\n)\n\n# Get the task.json as a powershell object\n$task = Get-Content -Raw -Path $filePath | ConvertFrom-Json\n\n$task.version.Major = $major\n$task.version.Minor = $minor\n$task.version.Patch = $patch\n\n# get this as a string again\n\nConvertTo-Json $task | Set-Content -Path $filePath"
},
{
"from": "gpt",
"value": "param (\n[string] $filePath,\n[string] $major,\n[string] $minor,\n[string] $patch\n)\n\n# Get the task.json as a powershell object\n$task = Get-Content -Raw -Path $filePath | ConvertFrom-Json\n\n$task.version.Major = $major\n$task.version.Minor = $minor\n$task.version.Patch = $patch\n\n# get this as a string again\n\nConvertTo-Json $task -Depth 999 | Set-Content -Path $filePath"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add f.lux because it was killing my eyes\n"
},
{
"from": "human",
"value": "## This configuration file uses BoxStarter to configure the system\n## and Chocolatey to install necessary packages\n\nWrite-Output \"Starting Common Configuration and Installs\"\n\nchoco feature enable --name=allowGlobalConfirmation\n\n## System Configuration\n\n# Set-ExplorerOptions -showFileExtensions\n\nWrite-Output \"Enabling Remote Desktop\"\n\nEnable-RemoteDesktop\nSet-NetFirewallRule -Name RemoteDesktop-UserMode-In-TCP -Enabled True\n\nDisable-InternetExplorerESC # Turns off Internet Explorer Enhanced Security Configuration that is on by default on Server OS versions.\n\nDisable-BingSearch # Disables the Bing Internet Search when searching from the search field in the taskbar or Start Menu\n\nWrite-Host \"Hiding Taskbar Search box / button...\"\nSet-ItemProperty -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Search\" -Name \"SearchboxTaskbarMode\" -Type DWord -Value 0\n\nWrite-Host \"Hiding Task View button...\"\nSet-ItemProperty -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\" -Name \"ShowTaskViewButton\" -Type DWord -Value 0\n\nWrite-Output \"Enabling and Running Windows Update\"\n\nEnable-MicrosoftUpdate\n\nWrite-Output \"Beginning Chocolatey installs\"\n\n## Web Browsers\n\nchoco install GoogleChrome\nchoco install Firefox\n\n## Common System Tools\n\nchoco install 7zip.install \nchoco install vscode\n\n# choco install rdcman\n\n# choco install google-backup-and-sync\n\nchoco install adobereader\n\nchoco install greenshot"
},
{
"from": "gpt",
"value": "## This configuration file uses BoxStarter to configure the system\n## and Chocolatey to install necessary packages\n\nWrite-Output \"Starting Common Configuration and Installs\"\n\nchoco feature enable --name=allowGlobalConfirmation\n\n## System Configuration\n\n# Set-ExplorerOptions -showFileExtensions\n\nWrite-Output \"Enabling Remote Desktop\"\n\nEnable-RemoteDesktop\nSet-NetFirewallRule -Name RemoteDesktop-UserMode-In-TCP -Enabled True\n\nDisable-InternetExplorerESC # Turns off Internet Explorer Enhanced Security Configuration that is on by default on Server OS versions.\n\nDisable-BingSearch # Disables the Bing Internet Search when searching from the search field in the taskbar or Start Menu\n\nWrite-Host \"Hiding Taskbar Search box / button...\"\nSet-ItemProperty -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Search\" -Name \"SearchboxTaskbarMode\" -Type DWord -Value 0\n\nWrite-Host \"Hiding Task View button...\"\nSet-ItemProperty -Path \"HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\" -Name \"ShowTaskViewButton\" -Type DWord -Value 0\n\nWrite-Output \"Enabling and Running Windows Update\"\n\nEnable-MicrosoftUpdate\n\nWrite-Output \"Beginning Chocolatey installs\"\n\n## Web Browsers\n\nchoco install GoogleChrome\nchoco install Firefox\n\n## Common System Tools\n\nchoco install 7zip.install \nchoco install vscode\n\n# choco install rdcman\n\n# choco install google-backup-and-sync\n\nchoco install adobereader\n\nchoco install greenshot\n\nchoco install f.lux"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Call bootstrap.ps1 when installing Mesos on Windows\n"
},
{
"from": "human",
"value": "param (\n [string]$path_to_packages = \"c:\\d2iq\\dcos\\packages\",\n [string]$path_to_dcos_bin = \"c:\\d2iq\\dcos\\bin\",\n [string]$path_to_dcos_conf = \"c:\\d2iq\\dcos\\etc\\mesos\"\n )\n\n$domain = & $path_to_dcos_bin\\fault-domain-detect-win.ps1\nSet-Content $path_to_dcos_conf\\domain.json $domain -Force\n\n$packagebootsrapname = [string[]](Get-ChildItem $path_to_packages -Recurse -Filter bootstrap--*)\n$pathtobootstrap = \"$path_to_packages\\$packagebootsrapname\"\n\n$Env:PYTHONPATH = \"$pathtobootstrap\\lib\\python36\\site-packages;$pathtobootstrap\"\n\n& python \"$pathtobootstrap\\bin\\bootstrap\" dcos-mesos-slave\n"
},
{
"from": "gpt",
"value": "param (\n [string]$path_to_dcos_bin = \"c:\\d2iq\\dcos\\bin\",\n [string]$path_to_dcos_conf = \"c:\\d2iq\\dcos\\etc\\mesos\"\n )\n\n$domain = & $path_to_dcos_bin\\fault-domain-detect-win.ps1\nSet-Content $path_to_dcos_conf\\domain.json $domain -Force\n\n& $path_to_dcos_bin\\bootstrap.ps1 dcos-mesos-slave\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add Pester test for Remove-Module\n"
},
{
"from": "gpt",
"value": "Describe \"Remove-Module\" {\n $moduleName = \"Microsoft.PowerShell.Platform\"\n \n BeforeEach {\n Import-Module -Name $moduleName -Force\n (Get-Module -Name $moduleName).Name | Should be $moduleName \n }\n\n It \"should be able to remove a module with using Name switch\" {\n { Remove-Module -Name $moduleName } | Should Not Throw \n (Get-Module -Name $moduleName).Name | Should BeNullOrEmpty\n }\n\n It \"should be able to remove a module with using ModuleInfo switch\" {\n $a = Get-Module -Name $moduleName\n { Remove-Module -ModuleInfo $a } | Should Not Throw\n (Get-Module -Name $moduleName).Name | Should BeNullOrEmpty\n }\n\t\n\tAfterEach {\n Import-Module -Name $moduleName -Force\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Test for invoke-dbacycelerrorlog\nLocally this test fails will see if Appveyor gets same result\n"
},
{
"from": "gpt",
"value": "$CommandName = $MyInvocation.MyCommand.Name.Replace(\".ps1\", \"\")\nWrite-Host -Object \"Running $PSCommandPath\" -ForegroundColor Cyan\n. \"$PSScriptRoot\\constants.ps1\"\nDescribe \"Invoke-DbaCycleErrorLog Unit Tests\" -Tag \"UnitTests\" {\n\tContext \"Validate parameters\" {\n\t\t$paramCount = 4\n\t\t$defaultParamCount = 13\n\t\t[object[]]$params = (Get-ChildItem function:\\Invoke-DbaCycleErrorLog).Parameters.Keys\n\t\t$knownParameters = 'SqlInstance', 'SqlCredential', 'Type', 'Silent'\n\t\tit \"Should contian our parameters\" {\n\t\t\t( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq \"==\").Count ) | Should Be $paramCount\n\t\t}\n\t\tit \"Should only contain our parameters\" {\n\t\t\t$params.Count - $defaultParamCount | Should Be $paramCount\n\t\t}\n\t}\n}\nDescribe \"Invoke-DbaCycleErrorLog Integration Test\" -Tag \"IntegrationTests\" {\n\t$results = Invoke-DbaCycleErrorLog -SqlInstance sql2008 -Type instance\n\n\tContext \"Validate output\" {\n\t\tit \"Should have correct properties\" {\n\t\t\t$ExpectedProps = 'ComputerName,InstanceName,SqlInstance,LogType,IsSuccessful,Notes'.Split(',')\n\t\t\t($results.PsObject.Properties.Name | Sort-Object) | Should Be ($ExpectedProps | Sort-Object)\n\t\t}\n\t\tit \"Should cycle instance error log\" {\n\t\t\t$results.LogType | Should Be \"instance\"\n\t\t}\n\t}\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix bug if cascade root path didn't exist\n"
},
{
"from": "human",
"value": ". .\\System\\Invoke-Pipeline.ps1\n\n# Invokes a \"Cascade\" of pipelines. All pipelines contained in $pipelinePath are executed in order\n# Then, after each root pipeline exists, all pipelines of the same name in any of the cascade paths are also executed (eg 'extending' the base pipeline)\n# Finally, any pipelines in the cascade paths that are NOT present in $pipelinePath are executed (eg 'custom' pipelines)\nfunction Invoke-Pipeline-Cascade([string]$pipelinePath, [string[]]$cascadePaths) {\n # get all pipelines in primary\n $pipelines = Get-ChildItem $pipelinePath -Directory\n\n # execute pipelines in order, and if pipeline exists in any cascades execute that immediately afterwards\n foreach($pipeline in $pipelines) {\n Invoke-Pipeline $pipeline.FullName\n\n foreach($cascade in $cascadePaths) {\n $cascadePath = Join-Path $cascade $pipeline.Name\n if(Test-Path $cascadePath) {\n Invoke-Pipeline $cascadePath\n }\n }\n }\n\n # now we execute any custom pipelines in the cascades that are NOT defined in the primary\n foreach($cascade in $cascadePaths)\n {\n $cascadePipelines = Get-ChildItem $cascade -Directory\n foreach($cascadePipeline in $cascadePipelines) {\n $primaryPath = Join-Path $pipelinePath $cascadePipeline.Name\n\n if(!(Test-Path $primaryPath)) {\n Invoke-Pipeline $cascadePipeline.FullName\n }\n }\n }\n}"
},
{
"from": "gpt",
"value": ". .\\System\\Invoke-Pipeline.ps1\n\n# Invokes a \"Cascade\" of pipelines. All pipelines contained in $pipelinePath are executed in order\n# Then, after each root pipeline exists, all pipelines of the same name in any of the cascade paths are also executed (eg 'extending' the base pipeline)\n# Finally, any pipelines in the cascade paths that are NOT present in $pipelinePath are executed (eg 'custom' pipelines)\nfunction Invoke-Pipeline-Cascade([string]$pipelinePath, [string[]]$cascadePaths) {\n # get all pipelines in primary\n $pipelines = Get-ChildItem $pipelinePath -Directory\n\n # execute pipelines in order, and if pipeline exists in any cascades execute that immediately afterwards\n foreach($pipeline in $pipelines) {\n Invoke-Pipeline $pipeline.FullName\n\n foreach($cascade in $cascadePaths) {\n $cascadePath = Join-Path $cascade $pipeline.Name\n if(Test-Path $cascadePath) {\n Invoke-Pipeline $cascadePath\n }\n }\n }\n\n # now we execute any custom pipelines in the cascades that are NOT defined in the primary\n foreach($cascade in $cascadePaths)\n {\n $cascadePipelines = Get-ChildItem $cascade -Directory -ErrorAction SilentlyContinue\n\n if($? -eq $true) {\n foreach($cascadePipeline in $cascadePipelines) {\n $primaryPath = Join-Path $pipelinePath $cascadePipeline.Name\n\n if(!(Test-Path $primaryPath)) {\n Invoke-Pipeline $cascadePipeline.FullName\n }\n }\n }\n }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix: Remove carriage return from digest file\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = \"Stop\"\n\n$VersionOutput = $(cargo run --release --target=x86_64-pc-windows-msvc -- -V)\nCopy-Item ..\\..\\target\\x86_64-pc-windows-msvc\\release\\indentex.exe .\n\nif (!($VersionOutput -match \"indentex (\\S+)\")) {\n Throw \"Could not parse indentex version\"\n}\n$PackageVersion = $Matches[1]\n\n(Get-Content .\\indentex_template.wxs) `\n -replace '{{{version}}}', \"$PackageVersion\" `\n | Set-Content .\\indentex.wxs\n\npandoc -f markdown -t rtf ..\\..\\LICENSE.md -s -o LICENSE.rtf\n\n$TargetFile = \"indentex_${PackageVersion}_amd64.msi\"\n\n& \"$env:WIX\\bin\\candle\" indentex.wxs\n& \"$env:WIX\\bin\\light\" indentex.wixobj -ext WixUIExtension -sice:ICE91 -o $TargetFile\n\n$FileHash = (Get-FileHash $TargetFile -Algorithm SHA512).Hash.ToLower()\nSet-Content \".\\$TargetFile.DIGEST\" \"$FileHash $TargetFile\"\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = \"Stop\"\n\n$VersionOutput = $(cargo run --release --target=x86_64-pc-windows-msvc -- -V)\nCopy-Item ..\\..\\target\\x86_64-pc-windows-msvc\\release\\indentex.exe .\n\nif (!($VersionOutput -match \"indentex (\\S+)\")) {\n Throw \"Could not parse indentex version\"\n}\n$PackageVersion = $Matches[1]\n\n(Get-Content .\\indentex_template.wxs) `\n -replace '{{{version}}}', \"$PackageVersion\" `\n | Set-Content .\\indentex.wxs\n\npandoc -f markdown -t rtf ..\\..\\LICENSE.md -s -o LICENSE.rtf\n\n$TargetFile = \"indentex_${PackageVersion}_amd64.msi\"\n\n& \"$env:WIX\\bin\\candle\" indentex.wxs\n& \"$env:WIX\\bin\\light\" indentex.wixobj -ext WixUIExtension -sice:ICE91 -o $TargetFile\n\n$FileHash = (Get-FileHash $TargetFile -Algorithm SHA512).Hash.ToLower()\nSet-Content -Path \".\\$TargetFile.DIGEST\" -Value \"$FileHash $TargetFile`n\" -NoNewline\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script to import enron data.\n"
},
{
"from": "gpt",
"value": "# Extract the ZIP if not already extracted\n$BackupPath = Join-Path $PSScriptRoot \"..\\enron.zip\"\n$Destination = Join-Path $PSScriptRoot \"..\\_enron\"\n\nif ((Test-Path $BackupPath) -eq $false)\n{\n throw \"$BackupPath was not found.\"\n}\n\nif ((Test-Path $Destination) -eq $false)\n{\n Write-Host \"Extracting '$BackupPath' to '$Destination'...\"\n Add-Type -Assembly \"System.IO.Compression.FileSystem\"\n [IO.Compression.ZipFile]::ExtractToDirectory($BackupPath, $Destination)\n}\n\n$cmd = 'db.dropDatabase()'\n\n$cmd | mongo enron\nmongorestore (Join-Path $Destination \"dump\")\n\n$cmd = 'use enron\ndb.messages.count();'\n\n$cmd | mongo\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Set network connection type to private.\n"
},
{
"from": "human",
"value": "Enable-PSRemoting -Force\nwinrm quickconfig -q\nwinrm quickconfig -transport:http\nwinrm set winrm/config '@{MaxTimeoutms=\"1800000\"}'\nwinrm set winrm/config/winrs '@{MaxMemoryPerShellMB=\"800\"}'\nwinrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'\nwinrm set winrm/config/service/auth '@{Basic=\"true\"}'\nwinrm set winrm/config/client/auth '@{Basic=\"true\"}'\nwinrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port=\"5985\"}'\nnetsh advfirewall firewall set rule group=\"Windows Remote Administration\" new enable=yes\nnetsh advfirewall firewall set rule name=\"Windows Remote Management (HTTP-In)\" new enable=yes action=allow\nSet-Service winrm -startuptype \"auto\"\nRestart-Service winrm\n"
},
{
"from": "gpt",
"value": "$NetworkListManager = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]\"{DCB00C01-570F-4A9B-8D69-199FDBA5723B}\"))\n$Connections = $NetworkListManager.GetNetworkConnections()\n$Connections | ForEach-Object { $_.GetNetwork().SetCategory(1) }\n\nEnable-PSRemoting -Force\nwinrm quickconfig -q\nwinrm quickconfig -transport:http\nwinrm set winrm/config '@{MaxTimeoutms=\"1800000\"}'\nwinrm set winrm/config/winrs '@{MaxMemoryPerShellMB=\"800\"}'\nwinrm set winrm/config/service '@{AllowUnencrypted=\"true\"}'\nwinrm set winrm/config/service/auth '@{Basic=\"true\"}'\nwinrm set winrm/config/client/auth '@{Basic=\"true\"}'\nwinrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port=\"5985\"}'\nnetsh advfirewall firewall set rule group=\"Windows Remote Administration\" new enable=yes\nnetsh advfirewall firewall set rule name=\"Windows Remote Management (HTTP-In)\" new enable=yes action=allow\nSet-Service winrm -startuptype \"auto\"\nRestart-Service winrm\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update default parameters for PSWinVitals v0.5.0\n"
},
{
"from": "human",
"value": "if ($DotFilesShowScriptEntry) {\n Write-Verbose -Message (Get-DotFilesMessage -Message $PSCommandPath)\n}\n\nif (!(Test-IsWindows)) {\n return\n}\n\ntry {\n if (!$DotFilesFastLoad) {\n Test-ModuleAvailable -Name PSWinVitals\n }\n} catch {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping PSWinVitals settings as module not found.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading PSWinVitals settings ...')\n\n# Invoke-VitalMaintenance: Exclude Silverlight updates\n$PSDefaultParameterValues['Invoke-VitalMaintenance:WUTitleExclude'] = 'Silverlight'\n"
},
{
"from": "gpt",
"value": "if ($DotFilesShowScriptEntry) {\n Write-Verbose -Message (Get-DotFilesMessage -Message $PSCommandPath)\n}\n\nif (!(Test-IsWindows)) {\n return\n}\n\ntry {\n if (!$DotFilesFastLoad) {\n Test-ModuleAvailable -Name PSWinVitals\n }\n} catch {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping PSWinVitals settings as module not found.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading PSWinVitals settings ...')\n\n# Get-VitalInformation: Exclude Silverlight updates\n$PSDefaultParameterValues['Get-VitalInformation:WUParameters'] = @{ NotTitle = 'Silverlight' }\n\n# Invoke-VitalMaintenance: Exclude Silverlight updates\n$PSDefaultParameterValues['Invoke-VitalMaintenance:WUParameters'] = @{ NotTitle = 'Silverlight' }\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Create script to build Windows solutions\n\nBased on the script we were using on TeamCity, this script creates the Windows solutions so on the server we can make a simple call to it.\n"
},
{
"from": "gpt",
"value": "## Parameters\n# platform: WindowsStore | WindowsPhone | WindowsUniversal\n# projectPath: in relation to the script path\n# outputPath: in relation to the project path\n# unityPath: absolute path to Unity.exe\n\n[string]$platform=$args[0]\n[string]$projectPath=\"$PSScriptRoot\\\"+$args[1]\n[string]$outputPath=$args[2]\n[string]$unityPath=$args[3]\n\n\nif(Test-Path $projectPath\\logs)\n{\n rmdir $projectPath\\logs -Force -Recurse | Out-Null\n}\nmkdir $projectPath\\logs | Out-Null\n\nTry \n{\n\nif(!(Test-Path \"$unityPath\"))\n{\n throw \"Unity executable was not found at $unityPath\"\n}\n\n$methodName = \"Assets.Editor.MarkerMetro.MarkerMetroBuilder.\"\n\nSwitch ($platform)\n{\n\t\"WindowsStore\" \n\t{\n\t\t$methodName += \"BuildMetro\"\n\t\t$displayName = \"Windows Store\"\n\t\t$buildTarget = \"Metro\"\n\t}\n\t\n\t\"WindowsPhone\"\n\t{\n\t\t$methodName += \"BuildWP8\"\n\t\t$displayName = \"Windows Phone\"\n\t\t$buildTarget = \"WP8\"\n\t}\n\t\n\t\"WindowsUniversal\"\n\t{\n\t\t$methodName += \"BuildUniversal\"\n\t\t$displayName = \"Windows Universal 8.1\"\t\n\t\t$buildTarget = \"Metro\"\t\t\t\n\t}\n}\n\n& \"$unityPath\" -buildTarget $buildTarget -projectPath $projectPath -batchmode -quit -logFile $projectPath\\logs\\$methodName.log -executeMethod $methodName -CustomArgs:outputPath=$outputPath | Out-Null\n\n$result = $?\n\nGet-Content $projectPath\\logs\\$methodName.log | Out-Default\n\nif(!((Get-Content $projectPath\\logs\\$methodName.log -Tail 10).Contains(\"Exiting batchmode successfully now!\"))){\n\tthrow \"Batch Mode did not complete successfully\"\n}\n\nif(!$result){\n Write-Host \"##teamcity[message text='$displayName Player build failed' errorDetails='The process exited with a non-zero exit code. Check the logs for details' status='FAILURE']\"\n}\n\nif(!$result){\n throw \"$displayName Player Build Failed\"\n}\n}\nFinally {\nWrite-Host \"##teamcity[blockClosed name='Building $displayName Player Build']\"\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script for enabling autocomplete in PowerShell v3\n"
},
{
"from": "gpt",
"value": "$Completion_clc = {\n \n param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)\n\n (invoke-expression \"$parameterName --generate-bash-completion\").Split(\" \") |\n ForEach-Object {\n New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', ('{0} ({1})' -f $_, $_)\n }\n}\n\n# Register the handler.\nif (-not $global:options) {\n $global:options = @{CustomArgumentCompleters = @{};NativeArgumentCompleters = @{}}\n}\n$global:options['NativeArgumentCompleters']['clc.exe'] = $Completion_clc\n\n# Override tabexpansion2. \n$function:tabexpansion2 = $function:tabexpansion2 -replace\n 'End\\r\\n{',\n 'End { if ($null -ne $options) { $options += $global:options} else {$options = $global:options}'\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Increase the default number of array elements to enumerate in PoSh\n"
},
{
"from": "human",
"value": "# Default to UTF-8 encoding with Out-File\n$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'\n\n# Our custom prompt with various integrations\nFunction Prompt {\n $prompt = ''\n\n # posh-git\n if ($GitPromptScriptBlock) {\n $prompt += & $GitPromptScriptBlock\n }\n\n # Default\n if (-not $prompt) {\n $prompt = 'PS {0}{1} ' -f $ExecutionContext.SessionState.Path.CurrentLocation, '>' * ($NestedPromptLevel + 1)\n }\n\n # ConEmu\n if ($ConEmuPrompt) {\n $prompt += & $ConEmuPrompt\n }\n\n return $prompt\n}\n"
},
{
"from": "gpt",
"value": "# Default to UTF-8 encoding with Out-File\n$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'\n\n# Number of elements to enumerate when displaying arrays\n$FormatEnumerationLimit = 5\n\n# Our custom prompt with various integrations\nFunction Prompt {\n $prompt = ''\n\n # posh-git\n if ($GitPromptScriptBlock) {\n $prompt += & $GitPromptScriptBlock\n }\n\n # Default\n if (-not $prompt) {\n $prompt = 'PS {0}{1} ' -f $ExecutionContext.SessionState.Path.CurrentLocation, '>' * ($NestedPromptLevel + 1)\n }\n\n # ConEmu\n if ($ConEmuPrompt) {\n $prompt += & $ConEmuPrompt\n }\n\n return $prompt\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Replace with unicode copyright symbol.\n"
},
{
"from": "human",
"value": "function Set-Project-Properties($version) {\n write-host \"$version\"\n\n set-regenerated-file \"$pwd/Directory.Build.props\" @\"\n<Project>\n <PropertyGroup>\n <Version>$version</Version>\n <Copyright>$(get-copyright)</Copyright>\n </PropertyGroup>\n</Project>\n\"@\n}\n\nfunction Get-Copyright {\n $date = Get-Date\n $year = $date.Year\n $copyrightSpan = if ($year -eq $yearInitiated) { $year } else { \"$yearInitiated-$year\" }\n return \" $copyrightSpan $owner\"\n}\n\nfunction Set-Regenerated-File($path, $newContent) {\n if (-not (test-path $path -PathType Leaf)) {\n $oldContent = $null\n } else {\n $oldContent = [IO.File]::ReadAllText($path)\n }\n\n if ($newContent -ne $oldContent) {\n write-host \"Generating $path\"\n [System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)\n }\n}\n\nfunction Remove-Directory-Silently($path) {\n if (test-path $path) {\n write-host \"Deleting $path\"\n Remove-Item $path -recurse -force -ErrorAction SilentlyContinue | out-null\n }\n}"
},
{
"from": "gpt",
"value": "function Set-Project-Properties($version) {\n write-host \"$version\"\n\n set-regenerated-file \"$pwd/Directory.Build.props\" @\"\n<Project>\n <PropertyGroup>\n <Version>$version</Version>\n <Copyright>$(get-copyright)</Copyright>\n </PropertyGroup>\n</Project>\n\"@\n}\n\nfunction Get-Copyright {\n $date = Get-Date\n $year = $date.Year\n $copyrightSpan = if ($year -eq $yearInitiated) { $year } else { \"$yearInitiated-$year\" }\n return [char]0x00A9 + \" $copyrightSpan $owner\"\n}\n\nfunction Set-Regenerated-File($path, $newContent) {\n if (-not (test-path $path -PathType Leaf)) {\n $oldContent = $null\n } else {\n $oldContent = [IO.File]::ReadAllText($path)\n }\n\n if ($newContent -ne $oldContent) {\n write-host \"Generating $path\"\n [System.IO.File]::WriteAllText($path, $newContent, [System.Text.Encoding]::UTF8)\n }\n}\n\nfunction Remove-Directory-Silently($path) {\n if (test-path $path) {\n write-host \"Deleting $path\"\n Remove-Item $path -recurse -force -ErrorAction SilentlyContinue | out-null\n }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Correct exe name in powershell installer.\n"
},
{
"from": "human",
"value": "$fullpath = (Get-Item -Path \".\\\" -Verbose).FullName\r\n$cred = Get-Credential -Message \"This service requires domain privledges.\"\r\nNew-Service -Name \"SqlAlertService\" -DisplayName \"SqlAlertService\" -Credential $cred -StartupType Automatic -BinaryPathName $fullpath\\DataCollector.exe -Description \"Runs SQL queries and sends an email if the results don't match the expected value.\"\r\n\r\n"
},
{
"from": "gpt",
"value": "$fullpath = (Get-Item -Path \".\\\" -Verbose).FullName\r\n$cred = Get-Credential -Message \"This service requires domain privledges.\"\r\nNew-Service -Name \"SqlAlertService\" -DisplayName \"SqlAlertService\" -Credential $cred -StartupType Automatic -BinaryPathName $fullpath\\SqlAlertService.exe -Description \"Runs SQL queries and sends an email if the results don't match the expected value.\"\r\n\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update source parameter for nuget\n"
},
{
"from": "human",
"value": "param([String]$key)\n\n$span = New-TimeSpan -Start 2010/1/1 -End (Get-Date)\n$version = \"beta-\" + $span.Days.ToString() + ($span.Hours * 60 + $span.Minutes).ToString(\"0000\")\n& dotnet restore\ncd .\\src\\Folke.Identity.Elm\n& dotnet pack --version-suffix $version\n$file = Get-Item \"bin\\Debug\\*-$version.nupkg\"\nnuget push $file.FullName $key\ncd ..\\..\n"
},
{
"from": "gpt",
"value": "param([String]$key)\n\n$span = New-TimeSpan -Start 2010/1/1 -End (Get-Date)\n$version = \"beta-\" + $span.Days.ToString() + ($span.Hours * 60 + $span.Minutes).ToString(\"0000\")\n& dotnet restore\ncd .\\src\\Folke.Identity.Elm\n& dotnet pack --version-suffix $version\n$file = Get-Item \"bin\\Debug\\*-$version.nupkg\"\nnuget push $file.FullName $key -Source https://api.nuget.org/v3/index.json\ncd ..\\..\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add ps module for appveyor integration\n"
},
{
"from": "gpt",
"value": "function Edit-ReplaceByFormat {\r\n param(\r\n [string] $fileToReplace,\r\n [string] $contentToReplace,\r\n [string] $replaceTo\r\n )\r\n\r\n Write-Output \"Start replace content at source: '$fileToReplace'\"\r\n Write-Output \"Replace: '$contentToReplace' to the '$replaceTo'\"\r\n\r\n if (!([System.IO.File]::Exists($fileToReplace)))\r\n {\r\n Write-Error \"Error: File '$fileToReplace' does not exists\"\r\n Exit\r\n }\r\n\r\n $reader = New-Object System.IO.StreamReader($fileToReplace)\r\n $content = $reader.ReadToEnd()\r\n\r\n $content = $content.Replace($contentToReplace, $replaceTo)\r\n $reader.Close()\r\n\r\n $projectFileStream = New-Object System.IO.StreamWriter($fileToReplace, $false)\r\n $projectFileStream.WriteLine($content)\r\n $projectFileStream.Close()\r\n}\r\n\r\nfunction Invoke-DownloadFile {\r\n param (\r\n [string] $fileUrl,\r\n [string] $outFile,\r\n [bool] $unzip,\r\n [string] $unzipFolder\r\n )\r\n \r\n Invoke-WebRequest -Uri \"$fileUrl\" -OutFile $outFile\r\n\r\n if (!(Test-Path -Path $outFile)) {\r\n Write-Error \"Error: File '$paramValue' was not found\"\r\n Exit\r\n }\r\n}\r\n\r\nfunction Invoke-ExtractFile {\r\n param (\r\n [string] $inputFile,\r\n [string] $outputPath\r\n )\r\n\r\n Add-Type -AssemblyName System.IO.Compression.FileSystem\r\n Write-Host \"Extracting archive '$outFile' to the folder '$unzipFolder'\"\r\n [System.IO.Compression.ZipFile]::ExtractToDirectory(\"$outFile\", \"$unzipFolder\")\r\n}\r\n\r\nfunction Start-SonarAnalysis {\r\n param(\r\n [string] $projectKey,\r\n [string] $projectPath,\r\n [string] $version,\r\n [string] $solutionFile,\r\n [string] $toolsPath = (Get-Item -Path \".\\\" -Verbose).FullName,\r\n [string] $branch = \"develop\"\r\n )\r\n\r\n Write-Output \"Start SonarQube analize for $solutionFile\"\r\n $sonarMsbuildPath = Join-Path $toolsPath $Sonar_MsBuildToolExe\r\n & $sonarMsbuildPath begin /k:\"$projectKey\" /n:\"$solutionFile\" /v:\"$version\" /d:sonar.branch=\"$branch\" /d:sonar.verbose=false\r\n}\r\n\r\nfunction Stop-SonarAnalysis {\r\n param (\r\n [string] $toolsPath = (Get-Item -Path \".\\\" -Verbose).FullName\r\n )\r\n\r\n Write-Output \"End SonarQube analize\"\r\n $sonarMsbuildPath = Join-Path $toolsPath $Sonar_MsBuildToolExe\r\n Write-Output \"$sonarMsbuildPath\"\r\n\t& $sonarMsbuildPath end > null\r\n}\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove Preview 4 specific hack\n"
},
{
"from": "human",
"value": "set-variable -name LastExitCode 0\nset-strictmode -version 2.0\n$ErrorActionPreference=\"Stop\"\n\n$CPCLocation=\"C:/CPC\"\n\n./build/scripts/cleanup_perf.ps1 $CPCLocation\n\nif ( -not $? )\n{\n echo \"cleanup failed\"\n exit 1\n}\n\nInvoke-WebRequest -Uri http://dotnetci.blob.core.windows.net/roslyn-perf/cpc.zip -OutFile cpc.zip\n[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null\n[IO.Compression.ZipFile]::ExtractToDirectory('cpc.zip', $CPCLocation)\n\n# Preview 4 specific\n[Environment]::SetEnvironmentVariable(\"VS150COMNTOOLS\", \"C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\VS15Preview\\\\Common7\\\\Tools\", \"Process\")\n\n./cibuild.cmd /testPerfRun /release\nif ($LASTEXITCODE -ne 0)\n{\n exit $LASTEXITCODE\n}\n"
},
{
"from": "gpt",
"value": "set-variable -name LastExitCode 0\nset-strictmode -version 2.0\n$ErrorActionPreference=\"Stop\"\n\n$CPCLocation=\"C:/CPC\"\n\n./build/scripts/cleanup_perf.ps1 $CPCLocation\n\nif ( -not $? )\n{\n echo \"cleanup failed\"\n exit 1\n}\n\nInvoke-WebRequest -Uri http://dotnetci.blob.core.windows.net/roslyn-perf/cpc.zip -OutFile cpc.zip\n[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null\n[IO.Compression.ZipFile]::ExtractToDirectory('cpc.zip', $CPCLocation)\n\n./cibuild.cmd /testPerfRun /release\nif ($LASTEXITCODE -ne 0)\n{\n exit $LASTEXITCODE\n}\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 | % {(Get-Location).ToString() + \"\\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 Ambient Sounds Tuner\\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 | % {(Get-Location).ToString() + \"\\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 Ambient Sounds Tuner\\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 a file that contains helper functions for tests\n"
},
{
"from": "gpt",
"value": "Function Get-ExtentText\n{\n\tParam(\n\t[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.CorrectionExtent] $violation,\n\t[string] $scriptPath\n\t)\n\t$scriptContent = Get-Content -Path $scriptPath\n\t$start = [System.Management.Automation.Language.ScriptPosition]::new($scriptPath, $violation.StartLineNumber, $violation.StartColumnNumber, $scriptContent[$violation.StartLineNumber - 1])\n\t$end = [System.Management.Automation.Language.ScriptPosition]::new($scriptPath, $violation.EndLineNumber, $violation.EndColumnNumber, $scriptContent[$violation.EndLineNumber - 1])\t\n\t$extent = [System.Management.Automation.Language.ScriptExtent]::new($start, $end)\n\treturn($extent.Text)\n}\n\nExport-ModuleMember -Function Get-ExtentText"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "tests: Add importable tests for Buckets\n\n"
},
{
"from": "gpt",
"value": "if([String]::IsNullOrEmpty($MyInvocation.PSScriptRoot)) {\n Write-Error 'This script should not be called directly! It has to be imported from a buckets test file!'\n exit 1\n}\n\n. \"$psscriptroot\\Scoop-TestLib.ps1\"\n. \"$psscriptroot\\..\\lib\\core.ps1\"\n. \"$psscriptroot\\..\\lib\\manifest.ps1\"\n. \"$psscriptroot\\..\\lib\\unix.ps1\"\n\n$repo_dir = (Get-Item $MyInvocation.PSScriptRoot).FullName\n\n$repo_files = @(Get-ChildItem $repo_dir -file -recurse)\n\n$project_file_exclusions = @(\n $([regex]::Escape($repo_dir)+'(\\\\|/).git(\\\\|/).*$'),\n '.sublime-workspace$',\n '.DS_Store$',\n 'supporting(\\\\|/)validator(\\\\|/)packages(\\\\|/)*'\n)\n\n. \"$psscriptroot\\Import-File-Tests.ps1\"\n. \"$psscriptroot\\Scoop-Manifest.Tests.ps1\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add dump $env:Configuration for appveyor troubleshooting\n"
},
{
"from": "human",
"value": "# Dump info for https://github.com/xunit/xunit/issues/1345#issuecomment-335274948\n dir -r -fi *.deps.json | select FullName\n\n$testProjects = ( \"LogJam.UnitTests\", \"LogJam.Internal.UnitTests\", \"LogJam.XUnit2.UnitTests\" )\nforeach ( $testProject in $testProjects) {\n pushd \".\\test\\$testProject\"\n dotnet xunit -nobuild -internaldiagnostics $testProject.csproj\n popd\n}\n"
},
{
"from": "gpt",
"value": "# Dump info for https://github.com/xunit/xunit/issues/1345#issuecomment-335274948\n dir -r -fi *.deps.json | select FullName\n\"Configuration: $env:Configuration\" \n\" \"\n\n$testProjects = ( \"LogJam.UnitTests\", \"LogJam.Internal.UnitTests\", \"LogJam.XUnit2.UnitTests\" )\nforeach ( $testProject in $testProjects) {\n pushd \".\\test\\$testProject\"\n dotnet xunit -nobuild -internaldiagnostics $testProject.csproj\n popd\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add Unit Test for Export-FormatData\n"
},
{
"from": "human",
"value": "Describe \"Export-FormatData\" {\n\n Context \"Check Export-FormatData can be called validly.\" {\n\tIt \"Should be able to be called without error\" {\n\t { Get-FormatData | Export-FormatData -Path \"outputfile\" } | Should Not Throw\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n }\n\n Context \"Check that the output is in the correct format\" {\n\tIt \"Should not return an empty xml file\" {\n\t Get-FormatData | Export-FormatData -Path \"outputfile\"\n\t $piped = Get-Content \"outputfile\"\n\t $piped | Should Not Be \"\"\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n\n\tIt \"Should have a valid xml tag at the start of the file\" {\n\t Get-FormatData | Export-FormatData -Path \"outputfile\"\n\t $piped = Get-Content \"outputfile\"\n\t $piped[0] | Should Be \"<\"\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n }\n}\n"
},
{
"from": "gpt",
"value": "Describe \"Export-FormatData DRT Unit Tests\" -Tags DRT{\n It \"Test basic functionality\" {\n $fd = Get-FormatData\n $tempFile = [io.path]::GetTempFileName()\n $results = Export-FormatData -InputObject $fd[0] -Path $tempFile\n $content = Get-Content $tempFile\n $formatViewDefinition = $fd[0].FormatViewDefinition\n $typeName = $fd[0].TypeName\n $content.Contains($typeName) | Should Be $true\n for ($i = 0; $i -lt $formatViewDefinition.Count;$i++)\n {\n $content.Contains($formatViewDefinition[$i].Name) | Should Be $true\n }\n }\n}\n\nDescribe \"Export-FormatData\" {\n\n Context \"Check Export-FormatData can be called validly.\" {\n\tIt \"Should be able to be called without error\" {\n\t { Get-FormatData | Export-FormatData -Path \"outputfile\" } | Should Not Throw\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n }\n\n Context \"Check that the output is in the correct format\" {\n\tIt \"Should not return an empty xml file\" {\n\t Get-FormatData | Export-FormatData -Path \"outputfile\"\n\t $piped = Get-Content \"outputfile\"\n\t $piped | Should Not Be \"\"\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n\n\tIt \"Should have a valid xml tag at the start of the file\" {\n\t Get-FormatData | Export-FormatData -Path \"outputfile\"\n\t $piped = Get-Content \"outputfile\"\n\t $piped[0] | Should Be \"<\"\n\t Remove-Item \"outputfile\" -Force -ErrorAction SilentlyContinue\n\t}\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add Join-XmlFiles and Add-VersionToNuspec script\n"
},
{
"from": "gpt",
"value": "function Join-XmlElements([System.Xml.XmlElement]$Template, [System.Xml.XmlElement]$Source, [System.Xml.XmlDocument]$TemplateDocument, [System.Xml.XmlDocument]$SourceDocument)\n{\n $namespaceManager = New-Object System.Xml.XmlNamespaceManager $TemplateDocument.NameTable\n $namespaceManager.AddNamespace(\"nuspec\", $Template.NamespaceURI)\n\n if (!$Template.HasChildNodes -and !$Source.HasChildNodes)\n {\n return;\n }\n elseif ($Template.FirstChild.LocalName -eq '#text')\n {\n $Source.FirstChild.Value = $Template.FirstChild.Value\n return;\n }\n\n foreach ($child in $Template.ChildNodes)\n {\n $xname = \"nuspec:$($child.Name)\"\n $matchingNode = $Source.SelectSingleNode($xname, $namespaceManager)\n \n if ($matchingNode -eq $null)\n {\n $copiedNode = $SourceDocument.ImportNode($child, $true)\n $Source.AppendChild($copiedNode)\n }\n else \n {\n Join-XmlElements $([System.Xml.XmlElement]$child) $([System.Xml.XmlElement]$matchingNode) $TemplateDocument $SourceDocument\n }\n }\n}\n\nfunction Join-XmlFiles([string]$Template, [string]$Source, [string]$Result)\n{\n $templateDocument = [xml](Get-Content $Template)\n $sourceDocument = [xml](Get-Content $Source)\n \n $templateXmlElement = $templateDocument.DocumentElement\n $sourceXmlElement = $sourceDocument.DocumentElement\n\n Join-XmlElements $templateXmlElement $sourceXmlElement $templateDocument $sourceDocument\n \n $sourceDocument.Save($Result)\n}\n\nfunction Add-VersionToNuspec([string]$Source, [string]$Version)\n{\n $xml = [xml](Get-Content $Source)\n\n $namespaceManager = New-Object System.Xml.XmlNamespaceManager $xml.NameTable\n $namespaceManager.AddNamespace(\"nuspec\", $xml.DocumentElement.NamespaceURI)\n\n $node = $xml.DocumentElement.SelectSingleNode(\"descendant::nuspec:version\", $namespaceManager)\n if ($node -eq $null)\n {\n return;\n }\n \n $formatted = \"{0}-{1}\" -f $node.FirstChild.Value, $Version\n $node.FirstChild.Value = $formatted\n\n $xml.Save($Source)\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Check HKEY_CURRENT_USER in addition to HKEY_LOCAL_MACHINE\n"
},
{
"from": "human",
"value": "function FindInstalledApplication\n{\n param($appName, $appVersion)\n \n if ((Get-WmiObject win32_operatingsystem).OSArchitecture -notmatch '64') \n { \n $keys= (Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*') \n } \n else \n { \n $keys = (Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*','HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*') \n } \n\n if ($appVersion -eq $null) { \n @($keys | Where-Object {$_.DisplayName -like $appName -or $_.PSChildName -like $appName}).Length -gt 0\n }\n else{\n @($keys | Where-Object {$_.DisplayName -like $appName -or $_.PSChildName -like $appName } | Where-Object {$_.DisplayVersion -eq $appVersion} ).Length -gt 0\n }\n\n}\n\n"
},
{
"from": "gpt",
"value": "function FindInstalledApplication\n{\n param($appName, $appVersion)\n \n if ((Get-WmiObject win32_operatingsystem).OSArchitecture -notmatch '64') \n { \n $keys= (Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*')\n $possible_path= 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n if (Test-Path $possible_path)\n {\n $keys+= (Get-ItemProperty $possible_path)\n }\n } \n else \n { \n $keys = (Get-ItemProperty 'HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*','HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*')\n $possible_path= 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n if (Test-Path $possible_path)\n {\n $keys+= (Get-ItemProperty $possible_path)\n }\n $possible_path= 'HKCU:\\Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\*'\n if (Test-Path $possible_path)\n {\n $keys+= (Get-ItemProperty $possible_path)\n }\n }\n\n if ($appVersion -eq $null) { \n @($keys | Where-Object {$_.DisplayName -like $appName -or $_.PSChildName -like $appName}).Length -gt 0\n }\n else{\n @($keys | Where-Object {$_.DisplayName -like $appName -or $_.PSChildName -like $appName } | Where-Object {$_.DisplayVersion -eq $appVersion} ).Length -gt 0\n }\n\n}\n\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script for windows requirements\n"
},
{
"from": "gpt",
"value": "# =============================================================================\n# Install the basic requirements for Windows software\n# =============================================================================\n\n# Url and path for each executable\n\n$url_dx = \"http://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe\"\n$path_dx = \"C:\\temp\\directx.exe\"\n \n$url_net4 = \"http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe\"\n$path_net4 = \"C:\\temp\\dotNetFx40.exe\"\n\n$url_net45 = \"http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe\"\n$path_net45 = \"C:\\temp\\dotNetFx45.exe\"\n\n$WebClient = New-Object System.Net.WebClient\n\n# Download each file\n\n$WebClient.DownloadFile($url_dx, $path_dx)\n$WebClient.DownloadFile($url_net4, $path_net4)\n$WebClient.DownloadFile($url_net45, $path_net45)\n\n# Launch each installation in silent mode\n\nStart-Process $path_dx \"/q\" -Wait\nStart-Process $path_net4 \"/q\" -Wait\nStart-Process $path_net45 \"/q\" -Wait"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Stop .Net Core SDK installation on failure\n"
},
{
"from": "human",
"value": "$installerName = \"installer.exe\"\n\nWrite-Host \"Downloading .Net Core SDK\"\nInvoke-WebRequest -Uri \"https://go.microsoft.com/fwlink/?LinkID=809122\" -OutFile $installerName\n\nWrite-Host \"Installing .Net Core SDK\"\nStart-Process $installerName -ArgumentList \"/quiet\" -Wait\n\nWrite-Host \".Net Core installation finished\"\nRemove-Item $installerName"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = \"Stop\"\n$installerName = \"installer.exe\"\n\nWrite-Host \"Downloading .Net Core SDK\"\nInvoke-WebRequest -Uri \"https://go.microsoft.com/fwlink/?LinkID=809122\" -OutFile $installerName\n\nWrite-Host \"Installing .Net Core SDK\"\nStart-Process $installerName -ArgumentList \"/quiet\" -Wait\n\nWrite-Host \".Net Core installation finished\"\nRemove-Item $installerName"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Increment patch version on unstable builds.\n"
},
{
"from": "human",
"value": "\n# figure out the correct nuget package version (depends on whether this is a release or not)\n$version = \"$env:NUGET_RELEASE_VERSION\"\nif (\"$env:APPVEYOR_REPO_TAG\" -ne \"true\") # non-tagged (pre-release build)\n{\n\t$version += \"-unstable$env:APPVEYOR_BUILD_NUMBER\"\n}\n\n# grab .nuspec file contents\n$file = \"$PSScriptRoot\\..\\$env:NUGET_FILE\"\n$contents = (Get-Content $file) | Out-String\n\n# make sure there is exactly one occurance of <version>$version$</version> in the file\n$pattern = '<version>\\$version\\$</version>'\n$matches = [Regex]::Matches(\"$contents\", \"$pattern\")\nif ($matches.Count -ne 1)\n{\n\t$count = $matches.Count\n\tWrite-Error \"<version>`$version`$</version> was found $count times in the nuspec file. If should have been found exactly once.\"\n\tExit 1\n}\n\n# set the NUGET_VERSION env variable\n[Environment]::SetEnvironmentVariable(\"NUGET_VERSION\", \"$version\", \"Process\")\nWrite-Host \"NUGET_VERSION set as $version\"\n"
},
{
"from": "gpt",
"value": "# get current release version\n$version = \"$env:NUGET_RELEASE_VERSION\"\n\n# make sure version follows the 0.0.0 format\nif (![Regex]::IsMatch($version, '^\\d\\.\\d\\.\\d$'))\n{\n\tWrite-Error \"Invalid NUGET_RELEASE_VERSION: $version\"\n\tExit 1\n}\n\n# set the correct nuget package version (depends on whether this is a release or not)\nif (\"$env:APPVEYOR_REPO_TAG\" -ne \"true\") # non-tagged (pre-release build)\n{\n\t# we want to increment the patch number for unstable builds\n\t$version = [Regex]::Replace($version, '^(\\d\\.\\d\\.)(\\d)$', {\n\t\tparam([System.Text.RegularExpressions.Match] $match)\n\t\t$val = [int]::Parse($match.Groups[2].Value)\n\t\t$val++\n\t\t$match.Groups[1].Value + $val\n\t})\n\n\t$version += \"-unstable$env:APPVEYOR_BUILD_NUMBER\"\n}\n\n# grab .nuspec file contents\n$file = \"$PSScriptRoot\\..\\$env:NUGET_FILE\"\n$contents = (Get-Content $file) | Out-String\n\n# make sure there is exactly one occurance of <version>$version$</version> in the file\n$pattern = '<version>\\$version\\$</version>'\n$matches = [Regex]::Matches(\"$contents\", \"$pattern\")\nif ($matches.Count -ne 1)\n{\n\t$count = $matches.Count\n\tWrite-Error \"<version>`$version`$</version> was found $count times in the nuspec file. If should have been found exactly once.\"\n\tExit 1\n}\n\n# set the NUGET_VERSION env variable\n[Environment]::SetEnvironmentVariable(\"NUGET_VERSION\", \"$version\", \"Process\")\nWrite-Host \"NUGET_VERSION set as $version\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix issue with using variable in 7z\n"
},
{
"from": "human",
"value": "Write-Output \"---Creating Artifacts---\"\n\n# Build web application\nSet-Location .\\KenticoInspector.WebApplication\ndotnet publish KenticoInspector.WebApplication.csproj /p:PublishDir=..\\publish -c Release -r win-x64 --self-contained true\n\n# Copy compiled front-end to publish folder\nSet-Location .\\ClientApp\nmkdir \"..\\..\\publish\\dist\"\nCopy-Item \".\\dist\\*\" -Recurse -Destination \"..\\..\\publish\\dist\\\"\n\n# Go back to root\nSet-Location ..\\..\\\n\n# Create archive & push to Appveyor\n$ filename = \"Kentico Inspector $Env:SEMVER_VERSION.zip\"\n7z a $filename .\\publish\\*\nappveyor PushArtifact $filename"
},
{
"from": "gpt",
"value": "Write-Output \"---Creating Artifacts---\"\n\n# Build web application\nSet-Location .\\KenticoInspector.WebApplication\ndotnet publish KenticoInspector.WebApplication.csproj /p:PublishDir=..\\publish -c Release -r win-x64 --self-contained true\n\n# Copy compiled front-end to publish folder\nSet-Location .\\ClientApp\nmkdir \"..\\..\\publish\\dist\"\nCopy-Item \".\\dist\\*\" -Recurse -Destination \"..\\..\\publish\\dist\\\"\n\n# Go back to root\nSet-Location ..\\..\\\n\n# Create archive & push to Appveyor\n7z a \"Kentico Inspector $Env:SEMVER_VERSION.zip\" .\\publish\\*\nappveyor PushArtifact \"Kentico Inspector $Env:SEMVER_VERSION.zip\""
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Replace the double quotes in the source code too.\n"
},
{
"from": "human",
"value": "# Copyright(c) 2018 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\nImport-Module -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\n$getBucketNameClause = 'Environment.GetEnvironmentVariable(\"AssetBucketName\")'\nBackupAndEdit-TextFile @(\"..\\ExportAssets\\ExportAssets.cs\") @{\n \"YOUR-GOOGLE-PROJECT-ID\" = $env:GOOGLE_PROJECT_ID;\n \"YOUR-BUCKET-NAME\" = $getBucketNameClause\n} {\n dotnet restore\n\tdotnet test --test-adapter-path:. --logger:junit\n}\n"
},
{
"from": "gpt",
"value": "# Copyright(c) 2018 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\nImport-Module -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\n$getBucketNameClause = 'Environment.GetEnvironmentVariable(\"AssetBucketName\")'\nBackupAndEdit-TextFile @(\"..\\ExportAssets\\ExportAssets.cs\") @{\n \"YOUR-GOOGLE-PROJECT-ID\" = $env:GOOGLE_PROJECT_ID;\n '\"YOUR-BUCKET-NAME\"' = $getBucketNameClause\n} {\n dotnet restore\n\tdotnet test --test-adapter-path:. --logger:junit\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add a helpful powershell script\n"
},
{
"from": "gpt",
"value": "#Set-AdUserPwd -user \"user\" -oldpwd (ConvertTo-SecureString -AsPlainText \"P@ssw0rd\" -Force) -newpwd (ConvertTo-SecureString -AsPlainText \"P@ssw0rd\" -Force)\n\nFunction Set-AdUserPwd\n{\n Param(\n [string]$user,\n [securestring]$oldpwd,\n [securestring]$newpwd\n ) #end param\n\n $user = (Get-ADUser $user).DistinguishedName\n Set-ADAccountPassword -Identity $user -NewPassword $newpwd -OldPassword $oldpwd -WhatIf\n} # end function Set-AdUserPwd\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Move script to msgpack repo\n"
},
{
"from": "gpt",
"value": "$globalJson = Get-Content -Raw -Path global.json | ConvertFrom-Json\n$version = $globalJson.Sdk.Version\n\nWrite-Host \"##teamcity[setParameter name='DotnetCoreVersion' value='$version']\""
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use Invoke-Expression instead of iex\n"
},
{
"from": "human",
"value": "if (Test-Path $PROFILE) {\n $file = Get-Item $PROFILE -Force -ea 0\n $symlink = $file.Attributes -band [IO.FileAttributes]::ReparsePoint\n if (-Not $symlink) {\n Remove-Item $PROFILE\n cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n }\n} else {\n $profilePath = Split-Path $PROFILE\n if (!(Test-Path -Path $profilePath)) {\n New-Item -ItemType directory -Path $profilePath | Out-Null\n }\n cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n}\n\n. $PROFILE\n\niex (new-object net.webclient).downloadstring('https://get.scoop.sh')\nscoop update\nscoop install concfg curl wget 7zip\nscoop update concfg curl wget 7zip\nconcfg import -n solarized-light small concfg\\source-code-pro.json\nconcfg clean\n\nInstall-Module PSReadline\n"
},
{
"from": "gpt",
"value": "if (Test-Path $PROFILE) {\n $file = Get-Item $PROFILE -Force -ea 0\n $symlink = $file.Attributes -band [IO.FileAttributes]::ReparsePoint\n if (-Not $symlink) {\n Remove-Item $PROFILE\n cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n }\n} else {\n $profilePath = Split-Path $PROFILE\n if (!(Test-Path -Path $profilePath)) {\n New-Item -ItemType directory -Path $profilePath | Out-Null\n }\n cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n}\n\n. $PROFILE\n\nInvoke-Expression (new-object net.webclient).downloadstring('https://get.scoop.sh')\nscoop update\nscoop install concfg curl wget 7zip\nscoop update concfg curl wget 7zip\nconcfg import -n solarized-light small concfg\\source-code-pro.json\nconcfg clean\n\nInstall-Module PSReadline\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update SymbolSource duplicate package error\n"
},
{
"from": "human",
"value": "param(\r\n\t$prereleaseVersion = (property prereleaseVersion \"beta-1\"),\r\n\t$ignoreNugetPushErrors = (property ignoreNugetPushErrors \"exists in compilation with different binary hash\") #SymbolSource duplicate package error\r\n)\r\n\r\nInclude-PluginScripts\r\n\r\ntask . Clean, Version, Compile, Test, Pack, Push"
},
{
"from": "gpt",
"value": "param(\r\n\t$prereleaseVersion = (property prereleaseVersion \"beta-1\"),\r\n\t$ignoreNugetPushErrors = (property ignoreNugetPushErrors \"The underlying connection was closed: An unexpected error occurred on a receive.;exists in compilation with different binary hash\") #SymbolSource duplicate package error\r\n)\r\n\r\nInclude-PluginScripts\r\n\r\ntask . Clean, Version, Compile, Test, Pack, Push"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix package location in build script\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 /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 Ambient Sounds Tuner\\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\nnuget restore .\\appveyor\\packages.config -SolutionDirectory .\\ -NonInteractive\n\n[xml]$packages = Get-Content .\\appveyor\\packages.config\n$referencePath = ($packages.packages.package | % {(Get-Location).ToString() + \"\\packages\\$($_.id).$($_.version)\\lib\\$($_.targetFramework)\\\"}) -Join \";\"\n\n\n# Do the actual build\nmsbuild /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 Ambient Sounds Tuner\\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 script to get Android package name of a unity project\n"
},
{
"from": "gpt",
"value": "c\u0000a\u0000t\u0000 \u0000.\u0000\\\u0000P\u0000r\u0000o\u0000j\u0000e\u0000c\u0000t\u0000S\u0000e\u0000t\u0000t\u0000i\u0000n\u0000g\u0000s\u0000\\\u0000P\u0000r\u0000o\u0000j\u0000e\u0000c\u0000t\u0000S\u0000e\u0000t\u0000t\u0000i\u0000n\u0000g\u0000s\u0000.\u0000a\u0000s\u0000s\u0000e\u0000t\u0000 \u0000|\u0000 \u0000s\u0000l\u0000s\u0000 \u0000A\u0000n\u0000d\u0000r\u0000o\u0000i\u0000d\u0000:\u0000 \u0000|\u0000 \u0000s\u0000e\u0000l\u0000e\u0000c\u0000t\u0000 \u0000-\u0000F\u0000i\u0000r\u0000s\u0000t\u0000 \u00001\u0000 \u0000|\u0000 \u0000f\u0000o\u0000r\u0000e\u0000a\u0000c\u0000h\u0000 \u0000{\u0000 \u0000$\u0000_\u0000 \u0000-\u0000s\u0000p\u0000l\u0000i\u0000t\u0000 \u0000'\u0000 \u0000'\u0000 \u0000}\u0000 \u0000|\u0000 \u0000s\u0000e\u0000l\u0000e\u0000c\u0000t\u0000 \u0000-\u0000L\u0000a\u0000s\u0000t\u0000 \u00001\u0000\r\u0000\n\u0000"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add script for cleaning up dead (orphaned) containers\n"
},
{
"from": "gpt",
"value": "\nImport-Module WebAdministration\n\n$sites = Get-ChildItem IIS:\\Sites\n$appPools = Get-ChildItem IIS:\\AppPools\n\n$sites |\n\tWhere-Object { $_.Name -ne 'Containerizer' } |\n\tRemove-Website\n\n$appPools |\n\tWhere-Object { $_.Name -ne 'Containerizer' } |\n\tRemove-WebAppPool\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add Powershell script to update external ID from AD\n"
},
{
"from": "gpt",
"value": "# For all nodes in UpGuard, update the external id by pulling the LDAP DN from AD\n# You will be prompted for credentials to query AD\n\nparam (\n [string]$ApiKey = '',\n [string]$SecretKey = '',\n [string]$Url = 'https://',\n [string]$DomainController = '',\n [switch]$Insecure,\n [switch]$DryRun\n)\n\n# Ignore SSL certificate if `-insecure` is used\nif ($Insecure)\n{\n add-type @\"\n using System.Net;\n using System.Security.Cryptography.X509Certificates;\n public class TrustAllCertsPolicy : ICertificatePolicy {\n public bool CheckValidationResult(\n ServicePoint srvPoint, X509Certificate certificate,\n WebRequest request, int certificateProblem) {\n return true;\n }\n }\n\"@\n [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy\n}\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::SSL3 -bor [System.Net.SecurityProtocolType]::TLS;\n\n$creds = (Get-Credential)\n\n$headers = @{'Authorization' = \"Token token=\"\"$($ApiKey)$($SecretKey)\"\"\";\n 'Accept' = 'application/json'; 'Content-Type' = 'application/json'}\n\n$nodes = Invoke-WebRequest -Uri \"https://$($Url)/api/v2/nodes.json?page=1&per_page=50000\" -Headers $headers -Method \"GET\"\n\nif ($nodes.StatusCode > 400)\n{\n throw [System.Exception] \"$($nodes.StatusCode.ToString()) $($nodes.StatusDescription)\"\n}\nelse\n{\n $nodes = ConvertFrom-Json -InputObject $nodes\n\n ForEach ($node in $nodes)\n {\n # Need to perform an additional lookup to get detailed node information.\n $node_details = Invoke-WebRequest -Uri \"https://$($Url)/api/v2/nodes/$($node.id).json -Headers $headers -Method \"GET\"\n $node_details = ConvertFrom-Json -InputObject $node_details\n\n $dn = Get-ADComputer -Identity \"$($node_details.name)\" -Credential $creds -Server $DomainController\n $external_id = \"LDAP://$($dn.DistinguishedName)\"\n\n if ($DryRun -eq $false)\n {\n \"Updating node $($node_details.name) external id to $($external_id)\"\n $body = @{\"node\" = @{\"external_id\" = $external_id}}\n $body = ConvertTo-Json -InputObject $body\n $response = Invoke-WebRequest -Uri \"https://$($Url)/api/v2/nodes/$($node.id).json\" -Body $body -Headers $headers -Method \"PUT\"\n if ($response.StatusCode > 400)\n {\n throw [System.Exception] \"$($response.StatusCode.ToString()) $($response.StatusDescription)\"\n }\n } else {\n \"Would update node $($node_details.name) external id to $($external_id)\"\n }\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add test to verify correction for negative whitespace\n"
},
{
"from": "human",
"value": "$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$testRootDirectory = Split-Path -Parent $directory\n\nImport-Module PSScriptAnalyzer\nImport-Module (Join-Path $testRootDirectory \"PSScriptAnalyzerTestHelper.psm1\")\n\n$ruleConfiguration = @{\n Enable = $true\n CheckHashtable = $true\n CheckDSCConfiguration = $true\n}\n\n$settings = @{\n IncludeRules = @(\"PSAlignAssignmentStatement\")\n Rules = @{\n PSAlignAssignmentStatement = $ruleConfiguration\n }\n}\n\nDescribe \"AlignAssignmentStatement\" {\n Context \"Hashtable\" {\n It \"Should align assignment statements in a hashtable\" {\n $def = @'\n$hashtable = @{\n property1 = \"value\"\n anotherProperty = \"another value\"\n}\n'@\n\n# Expected output should be the following\n# $hashtable = @{\n# property1 = \"value\"\n# anotherProperty = \"another value\"\n# }\n\n $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings\n $violations.Count | Should Be 1\n Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '\n }\n }\n}\n"
},
{
"from": "gpt",
"value": "$directory = Split-Path -Parent $MyInvocation.MyCommand.Path\n$testRootDirectory = Split-Path -Parent $directory\n\nImport-Module PSScriptAnalyzer\nImport-Module (Join-Path $testRootDirectory \"PSScriptAnalyzerTestHelper.psm1\")\n\n$ruleConfiguration = @{\n Enable = $true\n CheckHashtable = $true\n CheckDSCConfiguration = $true\n}\n\n$settings = @{\n IncludeRules = @(\"PSAlignAssignmentStatement\")\n Rules = @{\n PSAlignAssignmentStatement = $ruleConfiguration\n }\n}\n\nDescribe \"AlignAssignmentStatement\" {\n Context \"Hashtable\" {\n It \"Should align assignment statements in a hashtable when need to add whitespace\" {\n $def = @'\n$hashtable = @{\n property1 = \"value\"\n anotherProperty = \"another value\"\n}\n'@\n\n# Expected output after correction should be the following\n# $hashtable = @{\n# property1 = \"value\"\n# anotherProperty = \"another value\"\n# }\n\n $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings\n $violations.Count | Should Be 1\n Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '\n }\n\n It \"Should align assignment statements in a hashtable when need to remove whitespace\" {\n $def = @'\n$hashtable = @{\n property1 = \"value\"\n anotherProperty = \"another value\"\n}\n'@\n\n# Expected output should be the following\n# $hashtable = @{\n# property1 = \"value\"\n# anotherProperty = \"another value\"\n# }\n\n $violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings\n $violations.Count | Should Be 1\n Test-CorrectionExtentFromContent $def $violations 1 ' ' ' '\n }\n}\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use native powershell way to create dir if it doesn't exist"
},
{
"from": "human",
"value": "$packageName = '{{PackageName}}'\n$url = '{{DownloadUrl}}'\n$checksum = '{{Checksum}}'\n$checksumType = 'sha1'\n$toolsDir = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$installFile = Join-Path $toolsDir \"$($packageName).exe\"\n\n$chocTempDir = Join-Path $Env:Temp \"chocolatey\"\n$tempDir = Join-Path $chocTempDir \"$packageName\"\nif (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)}\n$zipFile = Join-Path $tempDir \"$($packageName).zip\"\n\n$referer = \"http://launcher.nirsoft.net/download.html\"\n$wc = New-Object System.Net.WebClient\n$wc.Headers.Add(\"Referer\", $referer)\n$wc.DownloadFile($url, $zipFile)\n\nGet-ChecksumValid -File \"$zipFile\" `\n -Checksum \"$checksum\" `\n -ChecksumType \"$checksumType\"\n\nGet-ChocolateyUnzip -FileFullPath \"$zipFile\" `\n -Destination \"$toolsDir\" `\n -PackageName \"$packageName\"\n\nSet-Content -Path (\"$installFile.gui\") `\n -Value $null"
},
{
"from": "gpt",
"value": "$packageName = '{{PackageName}}'\n$url = '{{DownloadUrl}}'\n$checksum = '{{Checksum}}'\n$checksumType = 'sha1'\n$toolsDir = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$installFile = Join-Path $toolsDir \"$($packageName).exe\"\n\n$chocTempDir = Join-Path $Env:Temp \"chocolatey\"\n$tempDir = Join-Path $chocTempDir \"$packageName\"\nmkdir -f $tempDir | out-null\n$zipFile = Join-Path $tempDir \"$($packageName).zip\"\n\n$referer = \"http://launcher.nirsoft.net/download.html\"\n$wc = New-Object System.Net.WebClient\n$wc.Headers.Add(\"Referer\", $referer)\n$wc.DownloadFile($url, $zipFile)\n\nGet-ChecksumValid -File \"$zipFile\" `\n -Checksum \"$checksum\" `\n -ChecksumType \"$checksumType\"\n\nGet-ChocolateyUnzip -FileFullPath \"$zipFile\" `\n -Destination \"$toolsDir\" `\n -PackageName \"$packageName\"\n\nSet-Content -Path (\"$installFile.gui\") `\n -Value $null\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add missing comment to Invoke-GitChildDir\n"
},
{
"from": "human",
"value": "Function Invoke-GitChildDir {\n [CmdletBinding()]\n Param(\n [Parameter(Mandatory)]\n [String]$Command,\n\n [ValidateNotNullOrEmpty()]\n [String]$Path\n )\n\n $GitArgs = $Command.Split()\n\n if (!$Path) {\n $Path = Get-Location -PSProvider FileSystem\n }\n\n $OrigLocation = Get-Location\n Set-Location -Path $Path\n\n $Dirs = Get-ChildItem -Directory\n foreach ($Dir in $Dirs) {\n $GitDir = Join-Path -Path $Dir -ChildPath '.git'\n if (-not (Test-Path -Path $GitDir -PathType Container)) {\n Write-Verbose -Message ('Skipping directory: {0}' -f $Dir.Name)\n continue\n }\n\n Write-Host -ForegroundColor Green -Object ('Running in: {0}' -f $Dir.Name)\n Set-Location -Path $Dir\n & git @GitArgs\n Set-Location -Path $Path\n Write-Host\n }\n\n Set-Location -Path $OrigLocation\n}\n"
},
{
"from": "gpt",
"value": "# Invoke a Git command in all Git repositories\nFunction Invoke-GitChildDir {\n [CmdletBinding()]\n Param(\n [Parameter(Mandatory)]\n [String]$Command,\n\n [ValidateNotNullOrEmpty()]\n [String]$Path\n )\n\n $GitArgs = $Command.Split()\n\n if (!$Path) {\n $Path = Get-Location -PSProvider FileSystem\n }\n\n $OrigLocation = Get-Location\n Set-Location -Path $Path\n\n $Dirs = Get-ChildItem -Directory\n foreach ($Dir in $Dirs) {\n $GitDir = Join-Path -Path $Dir -ChildPath '.git'\n if (-not (Test-Path -Path $GitDir -PathType Container)) {\n Write-Verbose -Message ('Skipping directory: {0}' -f $Dir.Name)\n continue\n }\n\n Write-Host -ForegroundColor Green -Object ('Running in: {0}' -f $Dir.Name)\n Set-Location -Path $Dir\n & git @GitArgs\n Set-Location -Path $Path\n Write-Host\n }\n\n Set-Location -Path $OrigLocation\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add addtional logging to make it clear it's a polyfill\n"
},
{
"from": "human",
"value": "Write-Host \"Ensconce - Powershell4Polyfill Loading\"\n\nfunction Clear-DnsClientCache()\n{\n\t$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo\n\t$ProcessInfo.FileName = \"ipconfig.exe\"\n\t$ProcessInfo.RedirectStandardError = $true\n\t$ProcessInfo.RedirectStandardOutput = $true\n\t$ProcessInfo.UseShellExecute = $false\n\t$ProcessInfo.Arguments = \"/flushdns\"\n\n\t$Process = New-Object System.Diagnostics.Process\n\t$Process.StartInfo = $ProcessInfo\n\t$Process.Start() | Out-Null\n\t$Process.WaitForExit()\n\n\t$output = $Process.StandardOutput.ReadToEnd()\n\twrite-host $output\n}\n\nWrite-Host \"Ensconce - Powershell4Polyfill Loaded\"\n"
},
{
"from": "gpt",
"value": "Write-Host \"Ensconce - Powershell4Polyfill Loading\"\n\nfunction Clear-DnsClientCache()\n{\n\tWrite-Host \"Calling IPConfig /flushdns to simulate Powershell 5 function\"\n\n\t$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo\n\t$ProcessInfo.FileName = \"ipconfig.exe\"\n\t$ProcessInfo.RedirectStandardError = $true\n\t$ProcessInfo.RedirectStandardOutput = $true\n\t$ProcessInfo.UseShellExecute = $false\n\t$ProcessInfo.Arguments = \"/flushdns\"\n\n\t$Process = New-Object System.Diagnostics.Process\n\t$Process.StartInfo = $ProcessInfo\n\t$Process.Start() | Out-Null\n\t$Process.WaitForExit()\n\n\t$output = $Process.StandardOutput.ReadToEnd()\n\twrite-host $output\n}\n\nWrite-Host \"Ensconce - Powershell4Polyfill Loaded\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add comment RE: redis-desktop-manager install\n"
},
{
"from": "human",
"value": "$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition\n\n& \"$ScriptPath\\PowerShellProfile\\Microsoft.PowerShell_profile.ps1\"\n\n## Developer Tools\n\nchoco install grepwin\nchoco install greenshot\nchoco install baretail\n\n## choco install redis-64\n\n## choco install virtualbox\n## choco install vagrant\n\n## choco install freeSSHD\n## choco install Tunnelier\n\n## choco install jenkins\n\n## choco install rabbitmq\n\n## choco install nginx\n\n## choco install sqlite\n\n## choco install mysql\n## choco install postgresql\n\n## choco install grails\n## choco install scala\n\n## choco install mongodb\n## choco install mongovue"
},
{
"from": "gpt",
"value": "$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Definition\n\n& \"$ScriptPath\\PowerShellProfile\\Microsoft.PowerShell_profile.ps1\"\n\n## Developer Tools\n\nchoco install grepwin\nchoco install greenshot\nchoco install baretail\n\n## choco install redis-64\n## choco install redis-desktop-manager\n\n## choco install virtualbox\n## choco install vagrant\n\n## choco install freeSSHD\n## choco install Tunnelier\n\n## choco install jenkins\n\n## choco install rabbitmq\n\n## choco install nginx\n\n## choco install sqlite\n\n## choco install mysql\n## choco install postgresql\n\n## choco install grails\n## choco install scala\n\n## choco install mongodb\n## choco install mongovue"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Allow specifying the version number\n"
},
{
"from": "human",
"value": "get-childitem -recurse bin -Directory | remove-item -recurse\nget-childitem -recurse obj -Directory | remove-item -recurse\n\n$packages = join-path (get-location) \"packages\"\nif (test-path $packages) { remove-item packages -recurse }\n\n$version = get-content VERSION\n$branch = git rev-parse --abbrev-ref HEAD\n$hash = git log --pretty=format:%h -1\n$suffix = \"$branch.$hash\"\n\ndotnet publish -c Release -v m --version-suffix $suffix /p:versionprefix=$version /p:packageversion=$version\ndotnet pack -o $packages -c release --no-build --version-suffix $suffix /p:versionprefix=$version /p:packageversion=$version\n"
},
{
"from": "gpt",
"value": "param ( [string] $Version, [string] $Configuration = \"Release\" )\n\nget-childitem -recurse bin -Directory | remove-item -recurse\nget-childitem -recurse obj -Directory | remove-item -recurse\n\n$packages = join-path (get-location) \"packages\"\nif (test-path $packages) { remove-item packages -recurse }\n\nif ([String]::IsNullOrWhiteSpace($version)) { $version = get-content VERSION }\n\n$branch = git rev-parse --abbrev-ref HEAD\n$hash = git log --pretty=format:%h -1\n$suffix = \"$branch.$hash\"\n\ndotnet publish -c $Configuration -v n --version-suffix $suffix /p:versionprefix=$version /p:packageversion=$version\ndotnet pack -c $Configuration -v n --version-suffix $suffix /p:versionprefix=$version /p:packageversion=$version -o $packages --no-build \n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add test for case insensitive query dictionary assembly\n"
},
{
"from": "gpt",
"value": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License.\n\nDescribe \".NET type with members with names differing only by name\" {\n BeforeAll {\n Add-Type -TypeDefinition @'\nnamespace PSScriptAnalyzerTests\n{\n public class QueryApiTestObject\n {\n public string JobId { get; set; }\n\n public object JOBID { get; set; }\n }\n}\n'@\n }\n\n It \"Does not crash the query API\" {\n $typeData = [Microsoft.PowerShell.CrossCompatibility.Utility.TypeDataConversion]::AssembleType([PSScriptAnalyzerTests.QueryApiTestObject])\n\n $typeQueryObject = New-Object 'Microsoft.PowerShell.CrossCompatibility.Query.TypeData' ('QueryApiTestObject', $typeData)\n\n $typeData.Instance.Properties.Count | Should -Be 1\n $typeData.Instance.Properties.Keys | Should -Contain 'jobid'\n }\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Verify the coverage artifact exists before attempting to delete it.\n"
},
{
"from": "human",
"value": ". $PSScriptRoot\\variables.ps1\n\n$openCover = \"c:\\OpenCover\\OpenCover.Console.exe\"\n\n$filter = '-filter:\"+[GravatarHelper*]*'\n\nRemove-Item $artifactDirectory\\opencoverCoverage.xml\n\nForEach ($project in (Get-ChildItem -Path $testDirectory -File -Recurse -Filter *.csproj)) { \n $targetArgs = \"-targetargs: test \" + $project.FullName \n & $openCover -register:user -mergeoutput -output:$artifactDirectory\\opencoverCoverage.xml -returntargetcode -target:\"dotnet.exe\" $targetArgs $filter\n}"
},
{
"from": "gpt",
"value": ". $PSScriptRoot\\variables.ps1\n\n$openCover = \"c:\\OpenCover\\OpenCover.Console.exe\"\n\n$filter = '-filter:\"+[GravatarHelper*]*'\n\nIf (Test-Path $artifactDirectory\\opencoverCoverage.xml) {\n Remove-Item $artifactDirectory\\opencoverCoverage.xml\n}\n\nForEach ($project in (Get-ChildItem -Path $testDirectory -File -Recurse -Filter *.csproj)) { \n $targetArgs = \"-targetargs: test \" + $project.FullName \n & $openCover -register:user -mergeoutput -output:$artifactDirectory\\opencoverCoverage.xml -returntargetcode -target:\"dotnet.exe\" $targetArgs $filter\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use native powershell for unzipping\n"
},
{
"from": "human",
"value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\nWrite-Host \"Installing unzip\"\nchoco install -y unzip\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\nunzip master.zip\ncd windows-setup-master\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\nWrite-Host \"Rebooting..\"\nshutdown /r /t 0\n"
},
{
"from": "gpt",
"value": "Write-Host \"Installing chocolatey\"\nSet-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n((New-Object System.Net.WebClient).DownloadFile('https://github.com/ctfhacker/windows-setup/archive/master.zip', 'C:\\Windows\\Temp\\master.zip'))\n\ncd C:\\Windows\\Temp\\\nmkdir master\n$shell = new-object -com shell.application\n$zip = $shell.NameSpace(\"master.zip\")\nforeach($item in $zip.items())\n{\n $shell.Namespace(\".\\master\").copyhere($item)\n}\n\ncd master\\windows-setup-master\n\nGet-ChildItem | ForEach-Object {\n Write-Host \"Executing \" + $_.FullName\n & $_.FullName\n}\n\nWrite-Host \"Rebooting..\"\nshutdown /r /t 0\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update fix based on comments for Select-XML Pester Test\n"
},
{
"from": "human",
"value": "\nDescribe \"Select-XML DRT Unit Tests\" -Tags DRT{\n\t$tmpDirectory = $TestDrive\n\t$testfilename = \"testfile.xml\"\n\t$testfile = Join-Path -Path $tmpDirectory -ChildPath $testfilename\n\t\n\tIt \"Select-XML should work\"{\n\t\t$xmlContent = @\"\n<?xml version =\"1.0\" encoding=\"ISO-8859-1\"?>\n<bookstore>\n\t<book category=\"CHILDREN\">\n\t\t<title lang=\"english\">Harry Potter</title>\n\t\t<price>30.00</price>\n\t</book>\n\t<book category=\"WEB\">\n\t\t<title lang=\"english\">Learning XML</title>\n\t\t<price>25.00</price>\n\t</book>\n</bookstore>\n\"@\n\t\t$xmlContent >$testfile\n\t\ttry\n\t\t{\n\t\t\t$results=Select-XML -Path $testfile -XPath \"/bookstore/book/title\"\n\t\t\t$results.Count | Should Be 2\n\t\t\t$results[0].Node.\"#text\" | Should Be \"Harry Potter\"\n\t\t\t$results[1].Node.\"#text\" | Should Be \"Learning XML\"\n\t\t}\n\t\tfinally \n\t\t{ \n\t\t\trm $testfile \n\t\t}\n\t}\n}\n"
},
{
"from": "gpt",
"value": "\nDescribe \"Select-XML DRT Unit Tests\" -Tags DRT{\n\t\n\tBeforeAll {\n\t\t$testfile = Join-Path -Path $TestDrive -ChildPath \"testfile.xml\"\n\t\t$xmlContent = @\"\n<?xml version =\"1.0\" encoding=\"ISO-8859-1\"?>\n<bookstore>\n\t<book category=\"CHILDREN\">\n\t\t<title lang=\"english\">Harry Potter</title>\n\t\t<price>30.00</price>\n\t</book>\n\t<book category=\"WEB\">\n\t\t<title lang=\"english\">Learning XML</title>\n\t\t<price>25.00</price>\n\t</book>\n</bookstore>\n\"@\n\t\t$xmlContent >$testfile\n\t}\n\tAfterAll {\n\t\trm $testfile\n\t}\n\t\n\tIt \"Select-XML should work\"{\n\t\t$results = Select-XML -Path $testfile -XPath \"/bookstore/book/title\"\n\t\t$results.Count | Should Be 2\n\t\t$results[0].Node.\"#text\" | Should Be \"Harry Potter\"\n\t\t$results[1].Node.\"#text\" | Should Be \"Learning XML\"\n\t}\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Remove any already existing coverage exports\n\n"
},
{
"from": "human",
"value": "$rootPath = (Get-Item -Path \".\\\" -Verbose).FullName\n\ndotnet restore\n\nSet-Location 'src\\Stranne.VasttrafikNET.Tests'\n\n$resultsFile = $rootPath + '\\artifacts\\Stranne.VasttrafikNET_coverage.xml'\n$openCoverConsole = $ENV:USERPROFILE + '\\.nuget\\packages\\OpenCover\\4.6.690\\tools\\OpenCover.Console.exe'\n$target = '-target:C:\\Program Files\\dotnet\\dotnet.exe'\n$targetArgs = '-targetargs: test -c Release'\n$filter = '-filter:+[Stranne.VasttrafikNET]* -[Stranne.VasttrafikNET.Tests]*'\n$output = '-output:' + $resultsFile\n\n& $openCoverConsole $target $targetArgs '-register:user' $filter '-hideskipped:Filter' '-returntargetcode' '-mergeoutput' $output '-oldStyle'\n\nSet-Location $rootPath\n\n$reportGenerator = $ENV:USERPROFILE + '\\.nuget\\packages\\reportgenerator\\2.5.6\\tools\\ReportGenerator.exe'\n$reportOutput = $rootPath + '\\artifacts\\CoverageReport\\'\n$reports = '-reports:' + $resultsFile\n$targetdir = '-targetdir:' + $reportOutput\n\nIf (Test-Path $reportOutput){\n\tRemove-Item $reportOutput -recurse\n}\n\n& $reportGenerator $reports $targetdir\n\nInvoke-Item ($reportOutput + 'index.htm')"
},
{
"from": "gpt",
"value": "$rootPath = (Get-Item -Path \".\\\" -Verbose).FullName\n\ndotnet restore\n\nSet-Location 'src\\Stranne.VasttrafikNET.Tests'\n\n$resultsFile = $rootPath + '\\artifacts\\Stranne.VasttrafikNET_coverage.xml'\nIf (Test-Path $resultsFile){\n\tRemove-Item $resultsFile\n}\n\n$openCoverConsole = $ENV:USERPROFILE + '\\.nuget\\packages\\OpenCover\\4.6.690\\tools\\OpenCover.Console.exe'\n$target = '-target:C:\\Program Files\\dotnet\\dotnet.exe'\n$targetArgs = '-targetargs: test -c Release'\n$filter = '-filter:+[Stranne.VasttrafikNET]* -[Stranne.VasttrafikNET.Tests]*'\n$output = '-output:' + $resultsFile\n\n& $openCoverConsole $target $targetArgs '-register:user' $filter '-hideskipped:Filter' '-returntargetcode' '-mergeoutput' $output '-oldStyle'\n\nSet-Location $rootPath\n\n$reportGenerator = $ENV:USERPROFILE + '\\.nuget\\packages\\reportgenerator\\2.5.6\\tools\\ReportGenerator.exe'\n$reportOutput = $rootPath + '\\artifacts\\CoverageReport\\'\n$reports = '-reports:' + $resultsFile\n$targetdir = '-targetdir:' + $reportOutput\n\nIf (Test-Path $reportOutput){\n\tRemove-Item $reportOutput -recurse\n}\n\n& $reportGenerator $reports $targetdir\n\nInvoke-Item ($reportOutput + 'index.htm')"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add TEPP for Agent Alerts\n"
},
{
"from": "gpt",
"value": "#region Initialize Cache\nif (-not [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"]) {\n\t[Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"] = @{ }\n}\n#endregion Initialize Cache\n\n#region Tepp Data return\n$ScriptBlock = {\n param (\n $commandName,\n \n $parameterName,\n \n $wordToComplete,\n \n $commandAst,\n \n $fakeBoundParameter\n )\n \n $start = Get-Date\n [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts[\"alert\"].LastExecution = $start\n\t\n\t$server = $fakeBoundParameter['SqlInstance']\n\t\n\tif (-not $server) {\n\t\t$server = $fakeBoundParameter['Source']\n\t}\n\t\n\tif (-not $server) {\n\t\t$server = $fakeBoundParameter['ComputerName']\n\t}\n\t\n\tif (-not $server) { return }\n\t\n try\n {\n [DbaInstanceParameter]$parServer = $server | Select-Object -First 1\n }\n catch\n {\n [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts[\"alert\"].LastDuration = (Get-Date) - $start\n return\n }\n \n if ([Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"][$parServer.FullSmoName.ToLower()])\n {\n foreach ($name in ([Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"][$parServer.FullSmoName.ToLower()] | Where-DbaObject -Like \"$wordToComplete*\"))\n {\n New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name\n }\n [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts[\"alert\"].LastDuration = (Get-Date) - $start\n return\n }\n \n try\n {\n $serverObject = Connect-SqlInstance -SqlInstance $parServer -SqlCredential $fakeBoundParameter['SqlCredential'] -ErrorAction Stop\n foreach ($name in ([Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"][$parServer.FullSmoName.ToLower()] | Where-DbaObject -Like \"$wordToComplete*\"))\n {\n New-DbaTeppCompletionResult -CompletionText $name -ToolTip $name\n }\n [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts[\"alert\"].LastDuration = (Get-Date) - $start\n return\n }\n catch\n {\n [Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Scripts[\"alert\"].LastDuration = (Get-Date) - $start\n return\n }\n}\n\nRegister-DbaTeppScriptblock -ScriptBlock $ScriptBlock -Name alert\n#endregion Tepp Data return\n\n#region Update Cache\n$ScriptBlock = {\n\n\t[Sqlcollaborative.Dbatools.TabExpansion.TabExpansionHost]::Cache[\"alert\"][$FullSmoName] = $server.JobServer.Alerts.Name\n}\nRegister-DbaTeppInstanceCacheBuilder -ScriptBlock $ScriptBlock\n#endregion Update Cache\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update golang to 1.9.3 in windows gqts\n\n[#154592362]\n\nSigned-off-by: Tom Godkin <891065477085d2c72591451bb326b2b4358b6dfb@pivotal.io>\n"
},
{
"from": "human",
"value": "$ErrorActionPreference = \"Stop\";\ntrap { $host.SetShouldExit(1) }\n\ncd gr-release-develop\n\n$env:GOPATH = $PWD\n$env:PATH = $env:GOPATH + \"/bin;C:/go/bin;\" + $env:PATH\n\nif ((Get-Command \"go.exe\" -ErrorAction SilentlyContinue) -eq $null) {\n Write-Host \"Installing Go 1.9!\"\n Invoke-WebRequest https://storage.googleapis.com/golang/go1.9.2.windows-amd64.msi -OutFile go.msi\n\n $p = Start-Process -FilePath \"msiexec\" -ArgumentList \"/passive /norestart /i go.msi\" -Wait -PassThru\n\n if($p.ExitCode -ne 0) {\n throw \"Golang MSI installation process returned error code: $($p.ExitCode)\"\n }\n\n Write-Host \"Go is installed!\"\n}\n\ngo.exe build -o binary/gdn code.cloudfoundry.org/guardian/cmd/gdn\nif ($LASTEXITCODE -ne 0) {\n Write-Error \"Error compiling: gdn\"\n}\n"
},
{
"from": "gpt",
"value": "$ErrorActionPreference = \"Stop\";\ntrap { $host.SetShouldExit(1) }\n\ncd gr-release-develop\n\n$env:GOPATH = $PWD\n$env:PATH = $env:GOPATH + \"/bin;C:/go/bin;\" + $env:PATH\n\nif ((Get-Command \"go.exe\" -ErrorAction SilentlyContinue) -eq $null) {\n Write-Host \"Installing Go 1.9!\"\n Invoke-WebRequest https://storage.googleapis.com/golang/go1.9.3.windows-amd64.msi -OutFile go.msi\n\n $p = Start-Process -FilePath \"msiexec\" -ArgumentList \"/passive /norestart /i go.msi\" -Wait -PassThru\n\n if($p.ExitCode -ne 0) {\n throw \"Golang MSI installation process returned error code: $($p.ExitCode)\"\n }\n\n Write-Host \"Go is installed!\"\n}\n\ngo.exe build -o binary/gdn code.cloudfoundry.org/guardian/cmd/gdn\nif ($LASTEXITCODE -ne 0) {\n Write-Error \"Error compiling: gdn\"\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add PS command to add transformation config to csproj\n"
},
{
"from": "human",
"value": "function Add-Transformation($pattern, $values, $output){\n$project = Get-Project\n$buildProject = @([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName))[0]\n$afterBuildTarget= $buildProject.Xml.Targets | Where-Object {$_.Name -eq \"AfterBuild\"}\nif($afterBuildTarget -eq $null)\n{\n\t$afterBuildTarget = $buildProject.Xml.AddTarget(\"AfterBuild\")\n\tWrite-Host \"Build target 'AfterBuild' has been created successfully.\"\n}\n$task = $afterBuildTarget.AddTask(\"VanillaTransformerTask\")\n$task.SetParameter(\"PatternFile\", $pattern)\n$task.SetParameter(\"ValuesSource\", $values)\n$task.SetParameter(\"OutputPath\",$output)\n$buildProject.Save()\n$project.Save()\nWrite-Host \"Transformation has been added successfully.\"\n}"
},
{
"from": "gpt",
"value": "function Add-Transformation($pattern, $values, $output){\n\t$project = Get-Project\n\t$buildProject = @([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName))[0]\n\t$afterBuildTarget= $buildProject.Xml.Targets | Where-Object {$_.Name -eq \"AfterBuild\"}\n\tif($afterBuildTarget -eq $null)\n\t{\n\t\t$afterBuildTarget = $buildProject.Xml.AddTarget(\"AfterBuild\")\n\t\tWrite-Host \"Build target 'AfterBuild' has been created successfully.\"\n\t}\n\t$task = $afterBuildTarget.AddTask(\"VanillaTransformerTask\")\n\t$task.SetParameter(\"PatternFile\", $pattern)\n\t$task.SetParameter(\"ValuesSource\", $values)\n\t$task.SetParameter(\"OutputPath\",$output)\n\t$buildProject.Save()\n\t$project.Save()\n\tWrite-Host \"Transformation has been added successfully.\"\n}\n\nfunction Add-TransformationConfig($configFilePath){\n\t$project = Get-Project\n\t$buildProject = @([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName))[0]\n\t$afterBuildTarget= $buildProject.Xml.Targets | Where-Object {$_.Name -eq \"AfterBuild\"}\n\tif($afterBuildTarget -eq $null)\n\t{\n\t\t$afterBuildTarget = $buildProject.Xml.AddTarget(\"AfterBuild\")\n\t\tWrite-Host \"Build target 'AfterBuild' has been created successfully.\"\n\t}\n\t$task = $afterBuildTarget.AddTask(\"VanillaTransformerTask\")\n\t$task.SetParameter(\"TransformConfiguration\", $configFilePath)\t\n\t$buildProject.Save()\n\t$project.Save()\n\tWrite-Host \"Transformation configuration has been added successfully.\"\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Load a module if it is not present.\n"
},
{
"from": "gpt",
"value": "<#\n.DESCRIPTION\n Swirch the physal director of an IIS Website.\n#>\n$WebAdministrationModule = 'WebAdministration'\n\nIf ( ! (Get-module $WebAdministrationModule )) {\n Write-Host \"Loading module $WebAdministrationModule\"\n Import-Module $WebAdministrationModule\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Hide non-zero exit code from dnu build.\n"
},
{
"from": "human",
"value": "Param(\n [switch] $Verbose\n)\n\nIf (!$Verbose) {\n $quietFlag = '--quiet'\n}\nElse {\n $quietFlag = ''\n}\n\n$dnu = Get-Command dnu\n\n& $dnu build 'src\\HTTPlease*' 'test\\HTTPlease*' $quietFlag\n"
},
{
"from": "gpt",
"value": "Param(\n [switch] $Verbose\n)\n\nIf (!$Verbose) {\n $quietFlag = '--quiet'\n}\nElse {\n $quietFlag = ''\n}\n\n$dnu = Get-Command dnu\n\n& $dnu build 'src\\HTTPlease*' 'test\\HTTPlease*' $quietFlag\n\n# Ugh - dnu build returns a non-zero exit code when building multiple projects, even if they all succeed.\n\nReturn 0\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add distributive files to ZIP archive.\n"
},
{
"from": "human",
"value": "#requires -Version 3.0\n\n$outputPath = \"$PSScriptRoot\\Distr\"\n\nImport-Module \"$PSScriptRoot\\Scripts\\BuildHelpers.psm1\"\n\nInitialize-BuildVariables\nInvoke-NugetRestore \"$PSScriptRoot\\DBVer.sln\"\n\nInvoke-SolutionBuild \"$PSScriptRoot\\DBVer.sln\" 'Release'\n\nif (Test-Path $outputPath)\n{\n Remove-Item -recurse -force $outputPath\n}\n\nNew-Item $outputPath -ItemType directory\n\n$nugetExePath = \"$PSScriptRoot\\Scripts\\nuget.exe\"\n$packagesPath = \"$PSScriptRoot\\packages\"\n&$nugetExePath install ILMerge -Version '2.14.1208' -OutputDirectory $packagesPath\n\n$releasePath = \"$PSScriptRoot\\bin\\Release\"\n$ilMergePath = $packagesPath + '\\ilmerge.2.14.1208\\tools\\ILMerge.exe'\n\n&$ilMergePath \"/out:${outputPath}\\DBVer.exe\" \"$releasePath\\DBVer.exe\" \"$releasePath\\*.dll\" '/wildcards'\n\nCopy-Item \"$releasePath\\DBVer.exe.config\" $outputPath\n"
},
{
"from": "gpt",
"value": "#requires -Version 3.0\n\n$outputPath = \"$PSScriptRoot\\Distr\"\n\nImport-Module \"$PSScriptRoot\\Scripts\\BuildHelpers.psm1\"\n\nInitialize-BuildVariables\nInvoke-NugetRestore \"$PSScriptRoot\\DBVer.sln\"\n\nInvoke-SolutionBuild \"$PSScriptRoot\\DBVer.sln\" 'Release'\n\nif (Test-Path $outputPath)\n{\n Remove-Item -recurse -force $outputPath\n}\n\nNew-Item $outputPath -ItemType directory\n\n$nugetExePath = \"$PSScriptRoot\\Scripts\\nuget.exe\"\n$packagesPath = \"$PSScriptRoot\\packages\"\n&$nugetExePath install ILMerge -Version '2.14.1208' -OutputDirectory $packagesPath\n\n$releasePath = \"$PSScriptRoot\\bin\\Release\"\n$ilMergePath = $packagesPath + '\\ilmerge.2.14.1208\\tools\\ILMerge.exe'\n\n&$ilMergePath \"/out:${outputPath}\\DBVer.exe\" \"$releasePath\\DBVer.exe\" \"$releasePath\\*.dll\" '/wildcards'\n\nCopy-Item \"$releasePath\\DBVer.exe.config\" $outputPath\n\n&\"${env:ProgramFiles}\\7-Zip\\7z.exe\" a \"$outputPath\\DBVer0.0.0.zip\" \"$outputPath\\*\"\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Allow local people and not all"
},
{
"from": "human",
"value": "Set-Item -Path WSMan:\\localhost\\Client\\TrustedHosts -Value '*'\n$url = \"https://raw.githubusercontent.com/MaxDistructo/ShellScripts/master/Comic%20Sans%20MS.reg\"\n$output = \"c:\\ComicSansMS.reg\"\n$wc = New-Object System.Net.WebClient\n$wc.DownloadFile($url, $output)\nreg.exe import C:\\ComicSansMS.reg\nRestart-Computer -Force\n"
},
{
"from": "gpt",
"value": "Set-Item -Path WSMan:\\localhost\\Client\\TrustedHosts -Value '172.18.*.*'\n$url = \"https://raw.githubusercontent.com/MaxDistructo/ShellScripts/master/Comic%20Sans%20MS.reg\"\n$output = \"c:\\ComicSansMS.reg\"\n$wc = New-Object System.Net.WebClient\n$wc.DownloadFile($url, $output)\nreg.exe import C:\\ComicSansMS.reg\nRestart-Computer -Force\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Make VSTS responsible for padding the build number\n"
},
{
"from": "human",
"value": "#\n# Set-UmbracoContinuousVersion\n# Sets the Umbraco version for continuous integration\n#\n# -Version <version>\n# where <version> is a Semver valid version\n# eg 1.2.3, 1.2.3-alpha, 1.2.3-alpha+456\n#\n# -BuildNumber <buildNumber>\n# where <buildNumber> is an integer coming from the build server\n#\nfunction Set-UmbracoContinuousVersion\n{\n param (\n [Parameter(Mandatory=$true)]\n [string]\n $version,\n [Parameter(Mandatory=$true)]\n [int]\n $buildNumber\n )\n \n $uenv = Get-UmbracoBuildEnv\n \n Write-Host \"Version is currently set to $version\"\n \n $versionComment = $buildNumber\n $versionComment = $versionComment.ToString().PadLeft(4,\"0\")\n $umbracoVersion = \"$($version.Trim())-alpha$versionComment\"\n \n Write-Host \"Setting Umbraco Version to $umbracoVersion\"\n Set-UmbracoVersion $umbracoVersion\n}"
},
{
"from": "gpt",
"value": "#\n# Set-UmbracoContinuousVersion\n# Sets the Umbraco version for continuous integration\n#\n# -Version <version>\n# where <version> is a Semver valid version\n# eg 1.2.3, 1.2.3-alpha, 1.2.3-alpha+456\n#\n# -BuildNumber <buildNumber>\n# where <buildNumber> is a string coming from the build server\n# eg 34, 126, 1\n#\nfunction Set-UmbracoContinuousVersion\n{\n param (\n [Parameter(Mandatory=$true)]\n [string]\n $version,\n [Parameter(Mandatory=$true)]\n [string]\n $buildNumber\n )\n \n Write-Host \"Version is currently set to $version\"\n\n $umbracoVersion = \"$($version.Trim())-alpha$($buildNumber)\"\n Write-Host \"Setting Umbraco Version to $umbracoVersion\"\n\n Set-UmbracoVersion $umbracoVersion\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add nssm stop signal if terminating\n"
},
{
"from": "human",
"value": "# Stop script execution when a non-terminating error occurs\n$ErrorActionPreference = \"Stop\"\n\nWrite-Output \"terminate-instance: waiting for 10 seconds to allow agent logs to drain to Cloudwatch...\"\nStart-Sleep -Seconds 10\n\n$InstanceId = (Invoke-WebRequest -UseBasicParsing http://169.254.169.254/latest/meta-data/instance-id).content\n$Region = (Invoke-WebRequest -UseBasicParsing http://169.254.169.254/latest/meta-data/placement/availability-zone).content -replace \".$\"\n\nWrite-Output \"terminate-instance: requesting instance termination...\"\naws autoscaling terminate-instance-in-auto-scaling-group --region \"$Region\" --instance-id \"$InstanceId\" \"--should-decrement-desired-capacity\"\n"
},
{
"from": "gpt",
"value": "# Stop script execution when a non-terminating error occurs\n$ErrorActionPreference = \"Stop\"\n\nWrite-Output \"terminate-instance: waiting for 10 seconds to allow agent logs to drain to Cloudwatch...\"\nStart-Sleep -Seconds 10\n\n$InstanceId = (Invoke-WebRequest -UseBasicParsing http://169.254.169.254/latest/meta-data/instance-id).content\n$Region = (Invoke-WebRequest -UseBasicParsing http://169.254.169.254/latest/meta-data/placement/availability-zone).content -replace \".$\"\n\nWrite-Output \"terminate-instance: requesting instance termination...\"\naws autoscaling terminate-instance-in-auto-scaling-group --region \"$Region\" --instance-id \"$InstanceId\" \"--should-decrement-desired-capacity\"\n\nif ($lastexitcode -eq 0) { # If autoscaling request was successful, we will terminate\n Write-Output \"terminate-instance: disabling buildkite-agent service\"\n nssm stop buildkite-agent\n}\nelse {\n Write-Output \"terminate-instance: ASG could not decrement (we're already at minSize)\"\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix .NET Core completion support in PowerShell\n"
},
{
"from": "human",
"value": "if (!(Get-Command -Name dotnet -ErrorAction Ignore)) {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping .NET Core settings as unable to locate dotnet.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading .NET Core settings ...')\n\n# Opt-out of telemetry\nSet-Item -Path Env:\\DOTNET_CLI_TELEMETRY_OPTOUT -Value 'true'\n\n# Command completion for the dotnet CLI\n# https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete\nRegister-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {\n Param($CommandName, $WordToComplete, $CursorPosition)\n dotnet complete --position $CursorPosition, \"$WordToComplete\" | ForEach-Object {\n [Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n}\n"
},
{
"from": "gpt",
"value": "if (!(Get-Command -Name dotnet -ErrorAction Ignore)) {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping .NET Core settings as unable to locate dotnet.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading .NET Core settings ...')\n\n# Opt-out of telemetry\nSet-Item -Path Env:\\DOTNET_CLI_TELEMETRY_OPTOUT -Value 'true'\n\n# How to enable TAB completion for the .NET Core CLI\n# https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete\nRegister-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {\n Param($wordToComplete, $commandAst, $cursorPosition)\n dotnet complete --position $cursorPosition \"$commandAst\" | ForEach-Object {\n [Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Install Git Credential Manager for Windows\n\n"
},
{
"from": "human",
"value": "### Install handy tools and apps for my dev machine\n### Run this script from an administrative shell\n\nSet-ExecutionPolicy RemoteSigned\n\n# Install Chocolatey\nInvoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n# Install some software with Chocolatey\nchoco install -y 7zip\nchoco install -y dotnetcore-sdk\nchoco install -y firacode\nchoco install -y git\nchoco install -y keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts # Remove if you plan to use Node Version Manager (see 2_download.ps1)\nchoco install -y notepadplusplus\nchoco install -y poshgit\nchoco install -y powershell-core --install-arguments='\"ADDEXPLORERCONTEXTMENUOPENPOWERSHELL=1\"'\nchoco install -y rdcman\nchoco install -y sql-server-management-studio\nRefreshEnv.cmd\n\n# Install some software with npm\nnpm install -g @angular/cli\nnpm install -g typescript\n"
},
{
"from": "gpt",
"value": "### Install handy tools and apps for my dev machine\n### Run this script from an administrative shell\n\nSet-ExecutionPolicy RemoteSigned\n\n# Install Chocolatey\nInvoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n\n# Install some software with Chocolatey\nchoco install -y 7zip\nchoco install -y dotnetcore-sdk\nchoco install -y firacode\nchoco install -y git\nchoco install -y git-credential-manager-for-windows\nchoco install -y keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts # Remove if you plan to use Node Version Manager (see 2_download.ps1)\nchoco install -y notepadplusplus\nchoco install -y poshgit\nchoco install -y powershell-core --install-arguments='\"ADDEXPLORERCONTEXTMENUOPENPOWERSHELL=1\"'\nchoco install -y rdcman\nchoco install -y sql-server-management-studio\nRefreshEnv.cmd\n\n# Install some software with npm\nnpm install -g @angular/cli\nnpm install -g typescript\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Add ability to have script in subfolder\n"
},
{
"from": "human",
"value": "$excel = new-object -comobject excel.application\n\n$workbook = $excel.workbooks.open(\"Dinosaur.xlsm\")\n$worksheet = $workbook.worksheets.item(1)\n$excel.Run(\"SortAndExport\")\n$workbook.save()\n$workbook.close()\n\npython \"git version.py\"\n\n$excel.quit\npause\n"
},
{
"from": "gpt",
"value": "$location = Get-Location\n# Gets the path of the parent directory\n$parent = (get-item $location ).parent.FullName\n$file = \"$parent\\ExcelDino.xlsm\"\n$excel = new-object -comobject excel.application\n\n$workbook = $excel.workbooks.open($file)\n$worksheet = $workbook.worksheets.item(1)\n# Runs the macro that sorts and exports the excel file to .csv\n$excel.Run(\"DinoSortExport\")\n$workbook.save()\n$workbook.close()\n\npython \"../tiki-toki.py\"\n\n$excel.quit\npause"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Revert script to generic format\n"
},
{
"from": "human",
"value": "PowerShell -NoProfile -Command {\n $folder = 'C:\\sources\\serviceable-objects\\Examples\\TestHttpCompositionConsoleApp\\bin\\Debug\\netcoreapp1.0';\n Set-Location -Path $folder;\n Import-Module \"$folder\\TestHttpCompositionConsoleApp.dll\" -Verbose;\n\n #Get-Help Write-Message;\n Write-Message -Message \"hey\" -PipeName \"container-X.service-X.testpipe\" -NodeId \"log-context\";\n\n # Target examples:\n # Run-InstrumentationCommandOnCustomPipe -Pipe XXX -Data \"hey\" -OtherData \"lo\"\n # Run-InstrumentationCommandOnNode -Service XXX -ServiceContainer YYY -NodeId log-context -Data \"hey\" -OtherData \"lo\"\n # Do-SomethingOnServiceProcess -Service XXX -ServiceContainer YYY (add-node? merge-template? pause-service?, etc)\n # Do-SomethingOnServiceContainerProcess -ServiceContainer YYY (copy-service?, move-service?, update-service?, etc)\n\n Write-Host \"Done.\";\n}"
},
{
"from": "gpt",
"value": "$location = Split-Path $MyInvocation.MyCommand.Path;\n\nPowerShell -NoProfile -Command {\n param (\n [String] $location\n )\n\n $folder = \"$location\\bin\\Debug\\netcoreapp1.0\";\n Set-Location -Path $folder;\n Import-Module \"$folder\\TestHttpCompositionConsoleApp.dll\" -Verbose;\n\n #Get-Help Write-Message;\n Write-Message -Message \"hey\" -PipeName \"container-X.service-X.testpipe\" -NodeId \"log-context\";\n\n # Target examples:\n # Run-InstrumentationCommandOnCustomPipe -Pipe XXX -Data \"hey\" -OtherData \"lo\"\n # Run-InstrumentationCommandOnNode -Service XXX -ServiceContainer YYY -NodeId log-context -Data \"hey\" -OtherData \"lo\"\n # Do-SomethingOnServiceProcess -Service XXX -ServiceContainer YYY (add-node? merge-template? pause-service?, etc)\n # Do-SomethingOnServiceContainerProcess -ServiceContainer YYY (copy-service?, move-service?, update-service?, etc)\n\n Write-Host \"Done.\";\n} -args $location"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Revert the docker command trap\n"
},
{
"from": "human",
"value": "if ($null -eq (Get-Command \"docker.exe\" -ErrorAction SilentlyContinue)) {\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 build -t nunit-console-build .\ndocker run --rm -it -v ${PSScriptRoot}:/nunit-console -w=/nunit-console nunit-console-build 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 build -t nunit-console-build .\ndocker run --rm -it -v ${PSScriptRoot}:/nunit-console -w=/nunit-console nunit-console-build bash build.sh $args"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update module, load helper functions\n"
},
{
"from": "human",
"value": "\n# Get and dot source all helper functions (private)\n# Split-Path -Path $PSCommandPath |\n# Join-Path -ChildPath 'Helpers' |\n# Get-ChildItem -Include '*.ps1' -Exclude '*.Tests.*' -Recurse |\n# ForEach-Object { . $_.FullName }\n\n# Get and dot source all external functions (public)\nSplit-Path -Path $PSCommandPath |\n Join-Path -ChildPath 'Functions' |\n Get-ChildItem -Include '*.ps1' -Exclude '*.Tests.*' -Recurse |\n ForEach-Object { . $_.FullName }\n"
},
{
"from": "gpt",
"value": "\n# Get and dot source all helper functions (private)\nSplit-Path -Path $PSCommandPath |\n Join-Path -ChildPath 'Helpers' |\n Get-ChildItem -Include '*.ps1' -Exclude '*.Tests.*' -Recurse |\n ForEach-Object { . $_.FullName }\n\n# Get and dot source all external functions (public)\nSplit-Path -Path $PSCommandPath |\n Join-Path -ChildPath 'Functions' |\n Get-ChildItem -Include '*.ps1' -Exclude '*.Tests.*' -Recurse |\n ForEach-Object { . $_.FullName }\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Exit Code 3010 is ok as a exit code\n"
},
{
"from": "human",
"value": "$packageName = \"dotnet\"\r\n$installerType = \"EXE\"\r\n$installerArgs = \"/passive /norestart\"\r\n$url = \"http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe\"\r\n\r\nif ($psISE) {\r\n Import-Module -name \"$env:ChocolateyInstall\\chocolateyinstall\\helpers\\chocolateyInstaller.psm1\"\r\n $ErrorActionPreference = \"Stop\"\r\n}\r\n\r\ntry\r\n{\r\n Install-ChocolateyPackage $packageName $installerType $installerArgs $url $url\r\n\r\n Write-ChocolateySuccess $packageName\r\n}\r\ncatch\r\n{\r\n Write-ChocolateyFailure $packageName $($_.Exception.Message)\r\n throw\r\n}\r\n"
},
{
"from": "gpt",
"value": "$packageName = \"dotnet\"\r\n$installerType = \"EXE\"\r\n$installerArgs = \"/passive /norestart\"\r\n$url = \"http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe\"\r\n$errorCode = @(0, 3010)\r\n\r\nif ($psISE) {\r\n Import-Module -name \"$env:ChocolateyInstall\\chocolateyinstall\\helpers\\chocolateyInstaller.psm1\"\r\n $ErrorActionPreference = \"Stop\"\r\n}\r\n\r\ntry\r\n{\r\n Install-ChocolateyPackage $packageName $installerType $installerArgs $url `\r\n -ValidExitCodes $errorCode\r\n\r\n Write-ChocolateySuccess $packageName\r\n}\r\ncatch\r\n{\r\n Write-ChocolateyFailure $packageName $($_.Exception.Message)\r\n throw\r\n}\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add install android sdk script\n"
},
{
"from": "gpt",
"value": "$AndroidToolPath = \"${env:ProgramFiles(x86)}\\Android\\android-sdk\\tools\\android\" \n#$AndroidToolPath = \"$env:localappdata\\Android\\android-sdk\\tools\\android\"\n\nFunction Get-AndroidSDKs() { \n $output = & $AndroidToolPath list sdk --all \n $sdks = $output |% { \n if ($_ -match '(?<index>\\d+)- (?<sdk>.+), revision (?<revision>[\\d\\.]+)') { \n $sdk = New-Object PSObject \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk \n Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision \n $sdk \n } \n } \n $sdks \n}\n\nFunction Install-AndroidSDK() { \n [CmdletBinding()] \n Param( \n [Parameter(Mandatory=$true, Position=0)] \n [PSObject[]]$sdks \n )\n\n $sdkIndexes = $sdks |% { $_.Index } \n $sdkIndexArgument = [string]::Join(',', $sdkIndexes) \n Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument \n}\n\n$sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 15*' -or $_.name -like 'google apis*api 15' } \nInstall-AndroidSDK -sdks $sdks"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use 7z to zip contents\n"
},
{
"from": "human",
"value": "$temp_directory = \"$env:APPVEYOR_BUILD_FOLDER\\Deploy\\Portable\\~TEMP\"\nNew-Item \"$temp_directory\" -type directory\n\n$zip_archive = \"$env:APPVEYOR_BUILD_FOLDER\\Deploy\\Portable\\Tabster $env:APPVEYOR_BUILD_VERSION Portable.exe\"\n\n& msbuild.exe \"$env:APPVEYOR_BUILD_FOLDER\\Tabster.sln\" /p:Configuration=Portable\n\n$output_directory = \"$env:APPVEYOR_BUILD_FOLDER\\Tabster\\bin\\Portable\"\n\nCopy-Item \"$output_directory\\*.exe\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.dll\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.config\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.config\" \"$temp_directory\"\n\n# copy subfolders recursively\nGet-ChildItem -Path \"$output_directory\" -Recurse | ?{ $_.PSIsContainer } | copy-item -Destination \"$temp_directory\" -Force -Container\n\n# move executable to project directory for clean AppVeyor artifact name\nMove-Item \"$zip_archive\" \"$env:APPVEYOR_BUILD_FOLDER\""
},
{
"from": "gpt",
"value": "$temp_directory = \"$env:APPVEYOR_BUILD_FOLDER\\Deploy\\Portable\\~TEMP\"\nNew-Item \"$temp_directory\" -type directory\n\n$zip_archive = \"$env:APPVEYOR_BUILD_FOLDER\\Deploy\\Portable\\Tabster $env:APPVEYOR_BUILD_VERSION Portable.exe\"\n\n& msbuild.exe \"$env:APPVEYOR_BUILD_FOLDER\\Tabster.sln\" /p:Configuration=Portable\n\n$output_directory = \"$env:APPVEYOR_BUILD_FOLDER\\Tabster\\bin\\Portable\"\n\nCopy-Item \"$output_directory\\*.exe\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.dll\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.config\" \"$temp_directory\"\nCopy-Item \"$output_directory\\*.config\" \"$temp_directory\"\n\n# copy subfolders recursively\nGet-ChildItem -Path \"$output_directory\" -Recurse | ?{ $_.PSIsContainer } | copy-item -Destination \"$temp_directory\" -Force -Container\n\n& 7z a -r \"$zip_archive\" -mmt -mx5 -sfx7z.sfx \"$temp_directory\\*.*\"\n\n# move executable to project directory for clean AppVeyor artifact name\nMove-Item \"$zip_archive\" \"$env:APPVEYOR_BUILD_FOLDER\""
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add verify and bundle script.\n"
},
{
"from": "gpt",
"value": "Write-Host \"mvn clean verify -DskipTests=true -P sonatype-oss-release\"\nmvn clean verify -DskipTests=true -P sonatype-oss-release\n\nWrite-Host \"Packaging into bundle.jar...\"\ncd ./target\njar -cvf bundle.jar *.pom *.jar *.asc\nWrite-Host \"Packaging into bundle.jar...DONE\"\n\nRead-Host \"Press any key to exit...\""
}
] |
powershell
|
chosen
|
[
{
"from": "human",
"value": "Add NuGet pkgs publish script\n"
},
{
"from": "gpt",
"value": "param (\n [Parameter(Mandatory=$true)][string]$apiKey\n)\n\n$branch = invoke-expression \"git branch --show-current\"\n\nif ($branch -ne 'master') {\n Write-Error \"Publishing only allowed from master branch\"\n exit\n}\n\n$projPaths = @(\n \"./AMT.Extensions.Logging\",\n \"./AMT.Extensions.System\"\n)\n\n# Ensure everything is built\nWrite-Verbose \"Pack projects\"\n$projPaths | %{\n write-host \"\" # separator\n dotnet pack -c Release $_\n}\n\n# Publish to NuGet\nWrite-Verbose \"Publish projects\"\n$projPaths | %{\n write-host \"\" # separator\n $pkg = gci $_/bin/Release *.nupkg\n dotnet nuget push -k $apiKey $pkg.FullName -s https://api.nuget.org/v3/index.json\n}\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix incorrect variable to track exit code\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 $testExitCode = $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": "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"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Update hugo docker powershell script for 0.18.1"
},
{
"from": "human",
"value": "# You will need to make sure you have your C drive (or whatever drive you have the devopsdays code on) shared in Docker\n\n$MyPath = $PSScriptRoot\n\ndocker stop hugo-server\ndocker rm hugo-server \ndocker run -p 1313:1313 -v ${MyPath}:/site --name hugo-server devopsdays/docker-hugo-server:v0.16\n"
},
{
"from": "gpt",
"value": "# You will need to make sure you have your C drive (or whatever drive you have the devopsdays code on) shared in Docker\n\n$MyPath = $PSScriptRoot\n\ndocker stop hugo-server\ndocker rm hugo-server \ndocker run -p 1313:1313 -v ${MyPath}:/site --name hugo-server devopsdays/docker-hugo-server:v0.18.1\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Use conference simple on statistics\n"
},
{
"from": "human",
"value": "$scenes = 'cornell-move-cone', 'sponza-hole', 'conference';\n$ilpsolver = '..\\x64\\Debug\\ILPSolver.exe';\n$triesPerScene = 10;\n\nforeach ($scene in $scenes) {\n\tfor($i=1; $i -le $triesPerScene; $i++){\n\t\t$outLogFile = \".\\examples\\$scene-$i-log.txt\";\n\n\t\tif(Test-Path $outLogFile){\n\t\t\tWrite-Host $scene $i \"Omitted\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tWrite-Host $scene $i;\n\t\tInvoke-Expression \"& $ilpsolver .\\examples\\$scene.xml\";\n\t\tMove-Item \".\\examples\\log.txt\" $outLogFile;\n\t\tWrite-Host \"Cooling down\";\n\t\tStart-Sleep -s 10;\n\t}\n}"
},
{
"from": "gpt",
"value": "$scenes = 'cornell-move-cone', 'sponza-hole', 'conference-simple';\n$ilpsolver = '..\\x64\\Debug\\ILPSolver.exe';\n$triesPerScene = 10;\n\nforeach ($scene in $scenes) {\n\tfor($i=1; $i -le $triesPerScene; $i++){\n\t\t$outLogFile = \".\\examples\\$scene-$i-log.txt\";\n\n\t\tif(Test-Path $outLogFile){\n\t\t\tWrite-Host $scene $i \"Omitted\";\n\t\t\tcontinue;\n\t\t}\n\n\t\tWrite-Host $scene $i;\n\t\tInvoke-Expression \"& $ilpsolver .\\examples\\$scene.xml\";\n\t\tMove-Item \".\\examples\\log.txt\" $outLogFile;\n\t\tWrite-Host \"Cooling down\";\n\t\tStart-Sleep -s 10;\n\t}\n}"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix handling of -h and -v parameter\n\n"
},
{
"from": "human",
"value": "#requires -v 3\nparam($cmd)\n\nset-strictmode -off\n\n. \"$psscriptroot\\..\\lib\\core.ps1\"\n. \"$psscriptroot\\..\\lib\\git.ps1\"\n. \"$psscriptroot\\..\\lib\\buckets.ps1\"\n. (relpath '..\\lib\\commands')\n\nreset_aliases\n\n$commands = commands\nif (@('-v', '--version') -contains $args) {\n pushd $(versiondir 'scoop' 'current')\n write-host \"Current Scoop version:\"\n git_log --oneline HEAD -n 1\n write-host \"\"\n popd\n\n buckets | % {\n pushd $(bucketdir $_)\n if(test-path '.git') {\n write-host \"'$_' bucket:\"\n git_log --oneline HEAD -n 1\n write-host \"\"\n }\n popd\n }\n}\nelseif (@($null, '-h', '--help', '/?') -contains $cmd) { exec 'help' $args }\nelseif ($commands -contains $cmd) { exec $cmd $args }\nelse { \"scoop: '$cmd' isn't a scoop command. See 'scoop help'.\"; exit 1 }\n"
},
{
"from": "gpt",
"value": "#requires -v 3\nparam($cmd)\n\nset-strictmode -off\n\n. \"$psscriptroot\\..\\lib\\core.ps1\"\n. \"$psscriptroot\\..\\lib\\git.ps1\"\n. \"$psscriptroot\\..\\lib\\buckets.ps1\"\n. (relpath '..\\lib\\commands')\n\nreset_aliases\n\n$commands = commands\nif ('--version' -contains $cmd -or '-v' -contains $args ) {\n pushd $(versiondir 'scoop' 'current')\n write-host \"Current Scoop version:\"\n git_log --oneline HEAD -n 1\n write-host \"\"\n popd\n\n buckets | % {\n pushd $(bucketdir $_)\n if(test-path '.git') {\n write-host \"'$_' bucket:\"\n git_log --oneline HEAD -n 1\n write-host \"\"\n }\n popd\n }\n}\nelseif (@($null, '--help', '/?') -contains $cmd -or $args -contains '-h') { exec 'help' $args }\nelseif ($commands -contains $cmd) { exec $cmd $args }\nelse { \"scoop: '$cmd' isn't a scoop command. See 'scoop help'.\"; exit 1 }\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Tag base images if latest tag is lost\n"
},
{
"from": "human",
"value": "\"Updating docker engine\"\ndocker version\n\"Stopping docker service\"\nstop-service docker\nif (!(Test-Path C:\\windows\\system32\\docker-orig.exe)) {\n \"Saving docker original docker engine\"\n copy-item C:\\windows\\system32\\docker.exe C:\\windows\\system32\\docker-orig.exe\n}\n\"Downloading nightly build of docker engine\"\nwget https://master.dockerproject.org/windows/amd64/docker.exe -outfile C:\\windows\\system32\\docker.exe\n\"Starting docker service\"\nstart-service docker\ndocker version\n"
},
{
"from": "gpt",
"value": "\"Updating docker engine\"\ndocker version\n\"Stopping docker service\"\nstop-service docker\nif (!(Test-Path C:\\windows\\system32\\docker-orig.exe)) {\n \"Saving docker original docker engine\"\n copy-item C:\\windows\\system32\\docker.exe C:\\windows\\system32\\docker-orig.exe\n}\n\"Downloading nightly build of docker engine\"\nwget https://master.dockerproject.org/windows/amd64/docker.exe -outfile C:\\windows\\system32\\docker.exe\n\"Starting docker service\"\nstart-service docker\nif (\"$(docker images windowsservercore:latest | wc -l)\" -eq \"1\") {\n docker tag windowsservercore:10.0.10586.0 windowsservercore:latest\n}\nif (\"$(docker images nanoserver:latest | wc -l)\" -eq \"1\") {\n docker tag nanoserver:10.0.10586.0 nanoserver:latest\n}\ndocker version\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Fix support for multi-tenant DSM\n"
},
{
"from": "human",
"value": "\r\nparam (\r\n [Parameter(Mandatory=$true)][string]$manager,\r\n [Parameter(Mandatory=$true)][string]$user,\r\n [Parameter(Mandatory=$false)][string]$tenant\r\n)\r\n\r\n$passwordinput = Read-host \"Password for Deep Security Manager\" -AsSecureString\r\n$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($passwordinput))\r\n\r\n\r\n[System.Net.ServicePointManager]::ServerCertificateValidationCallback={$true}\r\n\r\n\r\n$managerUri=\"https://$manager/rest/\"\r\n$Global:SID\r\n$authUri\r\n\r\n$headers=@{'Content-Type'='application/json'}\r\n\r\ntry {\r\n if (!$tenant) {\r\n $authUri = $managerUri + \"authentication/login/primary\"\r\n }\r\n else {\r\n $authUri = $managerUri + \"authentication/login\"\r\n }\r\n\r\n $data = @{\r\n dsCredentials = @{\r\n password=$password\r\n userName=$user\r\n }\r\n }\r\n $requestbody = $data | ConvertTo-Json \r\n $requestbody\r\n $Global:SID=Invoke-RestMethod -Headers $headers -Method POST -Uri $authUri -Body $requestbody\r\n}\r\ncatch {\r\n echo \"An error occurred during authentication. Verify username and password and try again. `nError returned was: $($_.Exception.Message)\"\r\n exit\r\n}\r\n\r\n\r\n\r\n"
},
{
"from": "gpt",
"value": "param (\r\n [Parameter(Mandatory=$true)][string]$manager,\r\n [Parameter(Mandatory=$true)][string]$user,\r\n [Parameter(Mandatory=$false)][string]$tenant\r\n)\r\n\r\n$passwordinput = Read-host \"Password for Deep Security Manager\" -AsSecureString\r\n$password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($passwordinput))\r\n\r\n\r\n[System.Net.ServicePointManager]::ServerCertificateValidationCallback={$true}\r\n\r\n\r\n$managerUri=\"https://$manager/rest/\"\r\n$Global:SID\r\n$authUri\r\n\r\n$headers=@{'Content-Type'='application/json'}\r\n\r\ntry {\r\n $data = @{\r\n dsCredentials = @{\r\n password=$password\r\n userName=$user\r\n }\r\n }\r\n if (!$tenant) {\r\n $authUri = $managerUri + \"authentication/login/primary\"\r\n }\r\n else {\r\n $authUri = $managerUri + \"authentication/login\"\r\n $data.dsCredentials.Add(\"tenantName\", $tenant)\r\n }\r\n\r\n \r\n $requestbody = $data | ConvertTo-Json \r\n $requestbody\r\n $Global:SID=Invoke-RestMethod -Headers $headers -Method POST -Uri $authUri -Body $requestbody\r\n}\r\ncatch {\r\n echo \"An error occurred during authentication. Verify username and password and try again. `nError returned was: $($_.Exception.Message)\"\r\n exit\r\n}\r\n\r\n\r\n\r\n"
}
] |
powershell
|
chosen
|
[
{
"from": "system",
"value": "Allow numbers in flag names\n"
},
{
"from": "human",
"value": "<#\n.SYNOPSIS\n Parses parameters of the package\n\n.EXAMPLE\n Get-PackageParameters \"/Shortcut /InstallDir:'c:\\program files\\xyz' /NoStartup\" | set r\n if ($r.Shortcut) {... }\n Write-Host $r.InstallDir\n\n.OUTPUTS\n [HashTable]\n#>\nfunction Get-PackageParameters([string] $Parameters = $Env:ChocolateyPackageParameters) {\n $res = @{}\n $re = \"\\/([a-zA-Z]+)(:([`\"'])?([a-zA-Z0-9- _\\\\:\\.]+)([`\"'])?)?\"\n $results = $Parameters | Select-String $re -AllMatches | select -Expand Matches\n foreach ($m in $results) {\n if (!$m) { continue } # must because of posh 2.0 bug: https://github.com/chocolatey/chocolatey-coreteampackages/issues/465\n\n $a = $m.Value -split ':'\n $opt = $a[0].Substring(1); $val = $a[1..100] -join ':'\n if ($val -match '^(\".+\")|(''.+'')$') {$val = $val -replace '^.|.$'}\n $res[ $opt ] = if ($val) { $val } else { $true }\n }\n $res\n}\n"
},
{
"from": "gpt",
"value": "<#\n.SYNOPSIS\n Parses parameters of the package\n\n.EXAMPLE\n Get-PackageParameters \"/Shortcut /InstallDir:'c:\\program files\\xyz' /NoStartup\" | set r\n if ($r.Shortcut) {... }\n Write-Host $r.InstallDir\n\n.OUTPUTS\n [HashTable]\n#>\nfunction Get-PackageParameters([string] $Parameters = $Env:ChocolateyPackageParameters) {\n $res = @{}\n write-host \"p: $Parameters\"\n\n $re = \"\\/([a-zA-Z0-9]+)(:([`\"'])?([a-zA-Z0-9- _\\\\:\\.]+)([`\"'])?)?\"\n $results = $Parameters | Select-String $re -AllMatches | select -Expand Matches\n foreach ($m in $results) {\n if (!$m) { continue } # must because of posh 2.0 bug: https://github.com/chocolatey/chocolatey-coreteampackages/issues/465\n\n $a = $m.Value -split ':'\n $opt = $a[0].Substring(1); $val = $a[1..100] -join ':'\n if ($val -match '^(\".+\")|(''.+'')$') {$val = $val -replace '^.|.$'}\n $res[ $opt ] = if ($val) { $val } else { $true }\n }\n write-host $res\n $res\n}\n"
}
] |
powershell
|
chosen
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.