conversations
listlengths
2
3
source
stringclasses
1 value
stack
stringclasses
1 value
[ { "from": "system", "value": "Update windows_feature.ps1 fact to run on x64\n" }, { "from": "human", "value": "$features = @()\n\ntry\n{\n $features = Get-WindowsFeature |\n ? { $_.Installed } |\n Select -ExpandProperty Name\n}\ncatch {}\n\n\"windows_features=$($features -join ',')\"\n" }, { "from": "gpt", "value": "$command = {\n $features = @()\n\n try\n {\n $features = Get-WindowsFeature |\n ? { $_.Installed } |\n Select -ExpandProperty Name\n }\n catch {}\n\n \"windows_features=$($features -join ',')\"\n}\n\nif ([IntPtr]::Size -eq 8)\n{\n &$command\n return\n}\n\n$ps = @(\n \"${Env:SystemRoot}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe\",\n 'powershell.exe') |\n ? { (Test-Path $_) -or (Get-Command $_ -ErrorAction SilentlyContinue) } |\n Select -First 1\n\n&$ps -Command $command\n" } ]
powershell
chosen
[ { "from": "system", "value": "Whitelist netcat in e2e tests\n" }, { "from": "human", "value": "# Windows updates cause the node to reboot at arbitrary times.\n& sc.exe config wuauserv start=disabled\n& sc.exe stop wuauserv\n\ncurl.exe -sLO https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/PrepareNode.ps1\n.\\PrepareNode.ps1 -KubernetesVersion VERSION\n\n$kubeadmJoinCommand=$(curl.exe -s http://metadata.google.internal/computeMetadata/v1/instance/attributes/join_cmd -H \"Metadata-Flavor: Google\")\n\nInvoke-Expression $kubeadmJoinCommand\n\n" }, { "from": "gpt", "value": "# Windows updates cause the node to reboot at arbitrary times.\n& sc.exe config wuauserv start=disabled\n& sc.exe stop wuauserv\n\n# tell windows defender to allow netcat, which is needed by the e2e tests\n# https://www.microsoft.com/en-us/wdsi/threats/malware-encyclopedia-description?Name=HackTool:Win32/NetCat&ThreatID=2147593673\nAdd-MpPreference -ThreadIDDefaultAction_Ids 2147593673 -ThreadIDDefaultAction_Actions 6\n\ncurl.exe -sLO https://github.com/kubernetes-sigs/sig-windows-tools/releases/latest/download/PrepareNode.ps1\n.\\PrepareNode.ps1 -KubernetesVersion VERSION\n\n$kubeadmJoinCommand=$(curl.exe -s http://metadata.google.internal/computeMetadata/v1/instance/attributes/join_cmd -H \"Metadata-Flavor: Google\")\n\nInvoke-Expression $kubeadmJoinCommand\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix choco uninstall package name\n" }, { "from": "human", "value": "$packageName = 'cmder.portable'\n$toolsPath = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$unPath = Join-Path $toolsPath 'Uninstall-ChocolateyPath.psm1'\n$installPath = \"$env:ChocolateyInstall\\bin\\grib-tools\"\n# remove from path\nImport-Module $unPath\nUninstall-ChocolateyPath $installPath\n\nif (Test-Path $installPath) {\n Remove-Item -Path $installPath -Recurse -Force\n}" }, { "from": "gpt", "value": "$packageName = 'grib-tools'\n$toolsPath = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n$unPath = Join-Path $toolsPath 'Uninstall-ChocolateyPath.psm1'\n$installPath = \"$env:ChocolateyInstall\\bin\\grib-tools\"\n# remove from path\nImport-Module $unPath\nUninstall-ChocolateyPath $installPath\n\nif (Test-Path $installPath) {\n Remove-Item -Path $installPath -Recurse -Force\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Fix for WFCORE-3789, CLI, powershell option handling\n" }, { "from": "human", "value": "#############################################################################\n# ##\n# WildFly CLI Script for interacting with the server ##\n# ##\n#############################################################################\n$PROGNAME=$MyInvocation.MyCommand.Name\n$scripts = (Get-ChildItem $MyInvocation.MyCommand.Path).Directory.FullName;\n. $scripts'\\common.ps1'\n\n$SERVER_OPTS = Process-Script-Parameters -Params $ARGS\n\n# Override ibm JRE behavior\n$SERVER_OPTS += \"-Dcom.ibm.jsse2.overrideDefaultTLS=true\"\n\n$PROG_ARGS = Get-Java-Arguments -entryModule \"org.jboss.as.cli\" -serverOpts $SERVER_OPTS -logFileProperties \"$JBOSS_HOME/bin/jboss-cli-logging.properties\"\n\n& $JAVA $PROG_ARGS\n\nEnv-Clean-Up" }, { "from": "gpt", "value": "#############################################################################\n# ##\n# WildFly CLI Script for interacting with the server ##\n# ##\n#############################################################################\n$PROGNAME=$MyInvocation.MyCommand.Name\n$scripts = (Get-ChildItem $MyInvocation.MyCommand.Path).Directory.FullName;\n. $scripts'\\common.ps1'\n\n$SERVER_OPTS = Process-Script-Parameters -Params $ARGS\n\n# Override ibm JRE behavior\n$IBM_TLS_OPT = \"-Dcom.ibm.jsse2.overrideDefaultTLS=true\"\n\n$PROG_ARGS = Get-Java-Arguments -entryModule \"org.jboss.as.cli\" -serverOpts $SERVER_OPTS -logFileProperties \"$JBOSS_HOME/bin/jboss-cli-logging.properties\"\n\n& $JAVA $IBM_TLS_OPT $PROG_ARGS\n\nEnv-Clean-Up" } ]
powershell
chosen
[ { "from": "human", "value": "Add build local powershell to build on windows client\n" }, { "from": "gpt", "value": "# Look for config.json file\n$FILE=\".docker/build/config.json\"\nif ((Test-Path $FILE) -eq $false) {\n Write-Error \"File $FILE does not exist.\"\n}\n\n# In case you want to build windows, change agentOS here to windows-nt if OSTYPE is not working\n$agentOS = \"linux\"\nif ([environment]::OSVersion.Platform -eq \"Win32NT\") {\n $agentOS=\"windows-nt\"\n}\n\n$DOCKERFILE=(cat \".docker/build/config.json\" | ConvertFrom-Json).DockerFile\n$DOCKERFILE=$DOCKERFILE.Replace(\"{agentOS}\", $agentOS);\n\n# Copy dockerfile to root\ncp $DOCKERFILE ./Dockerfile\n\n# Copy dependencies\n$DEPFILES=(cat \".docker/build/config.json\" | ConvertFrom-Json).DependencyFiles\ncp -r $DEPFILES .\n\n$PROJECTNAME=((cat \".docker/build/config.json\" | ConvertFrom-Json).ProjectName).ToLower()\n$BUILDTARGET=(cat \".docker/build/config.json\" | ConvertFrom-Json).CIBuildTarget\n$LOCALBRANCHNAME = (git branch | Select-String -Pattern \\*).ToString() | % { $_.Replace(\"* \", \"\") }\n\n#Find commit id.\n$REQUESTEDBRANCHNAME=(cat \".docker/build/config.json\" | ConvertFrom-Json).BranchName\n$REQUESTEDCOMMITID=(cat \".docker/build/config.json\" | ConvertFrom-Json).BaseContainerImageTagOrCommitId\n$COMMITURL=(cat \".docker/build/config.json\" | ConvertFrom-Json).GithubCommitUrl\n\nif ((cat \".docker/build/config.json\" | ConvertFrom-Json).GithubCommitUrl -ne \"latest\") {\n $COMMITURL=(cat \".docker/build/config.json\" | ConvertFrom-Json).GithubCommitUrl\n}\n\n$CONTENT=(Invoke-WebRequest $COMMITURL).Content\n$FULLCOMMITID=($CONTENT | % { [regex]::match($_, '/.*commit\\/([^\"]*).*/') }).Groups[1].Captures[0].Value\n$COMMITID= $FULLCOMMITID.SubString(0, 12)\n\n# create fake files ssh key, commitinfofilename.json, etc\necho \"fake\" > id_rsa\necho \"fake\" > commitinfofilename.json\n\n# build container\ndocker build --file Dockerfile --build-arg BUILDLOGFILE=\"buildlogfile.txt\" --build-arg MAXTHREADS=\"8\" --build-arg TARGET=\"$BUILDTARGET\" --build-arg BRANCHNAME=\"$LOCALBRANCHNAME\" --build-arg COMMITID=\"$COMMITID\" --build-arg DOCKERHUBPROJECT=\"projecteverest/\" --tag \"$($PROJECTNAME):local\" .\n\n# delete fake files\nrm id_rsa\nrm commitinfofilename.json\n\n# Remove dep files.\n$DEPFILES | % { rm (split-path $_ -leaf) }\n\n# delete dockerfile\nrm Dockerfile" } ]
powershell
chosen
[ { "from": "system", "value": "Fix a bug in a test helper function\n" }, { "from": "human", "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\nFunction Test-CorrectionExtent\n{\n\tParam(\n\t\t[string] $violationFilepath,\n\t\t[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord] $diagnosticRecord, \n\t\t[int] $correctionsCount, \n\t\t[string] $violationText, \n\t\t[string] $correctionText\n\t)\n\t$corrections = $diagnosticRecord.SuggestedCorrections\n\t$corrections.Count | Should Be 1\n\t$corrections[0].Text | Should Be $correctionText\n\tGet-ExtentText $corrections[0] $violationFilepath | `\n\t\t Should Be $violationText\n}\n\n\nExport-ModuleMember -Function Get-ExtentText\nExport-ModuleMember -Function Test-CorrectionExtent" }, { "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\nFunction Test-CorrectionExtent\n{\n\tParam(\n\t\t[string] $violationFilepath,\n\t\t[Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord] $diagnosticRecord, \n\t\t[int] $correctionsCount, \n\t\t[string] $violationText, \n\t\t[string] $correctionText\n\t)\n\t$corrections = $diagnosticRecord.SuggestedCorrections\n\t$corrections.Count | Should Be $correctionsCount\n\t$corrections[0].Text | Should Be $correctionText\n\tGet-ExtentText $corrections[0] $violationFilepath | `\n\t\t Should Be $violationText\n}\n\n\nExport-ModuleMember -Function Get-ExtentText\nExport-ModuleMember -Function Test-CorrectionExtent" } ]
powershell
chosen
[ { "from": "human", "value": "Add a basic PowerShell profile\n" }, { "from": "gpt", "value": "Import-Module PSReadLine\n\nSet-PSReadLineOption -EditMode Vi\n\nSet-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward\nSet-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward\nSet-PSReadlineKeyHandler -Key Shift+Ctrl+C -Function Copy\nSet-PSReadlineKeyHandler -Key Ctrl+V -Function Paste\nSet-PSReadlineKeyHandler -Key Alt+D -Function ShellKillWord\nSet-PSReadlineKeyHandler -Key Alt+B -Function ShellBackwardWord\nSet-PSReadlineKeyHandler -Key Alt+F -Function ShellForwardWord\nSet-PSReadlineKeyHandler -Key Tab -Function Complete\nSet-PSReadlineKeyHandler -Key Ctrl+r -Function ReverseSearchHistory\nSet-PSReadlineKeyHandler -Key Ctrl+w -Function UnixWordRubout\nSet-PSReadlineKeyHandler -Key Ctrl+[ -Function ViCommandMode\n\nSet-Alias vi vim\n\n# The following function is respectfully borrowed from \n# https://github.com/lzybkr/PSReadLine/blob/master/PSReadLine/SamplePSReadLineProfile.ps1\n\n# Ctrl+Shift+j then type a key to mark the current directory.\n# Ctrj+j then the same key will change back to that directory without\n# needing to type cd and won't change the command line.\n\n$global:PSReadlineMarks = @{}\n\nSet-PSReadlineKeyHandler -Key Ctrl+Shift+j `\n -BriefDescription MarkDirectory `\n -LongDescription \"Mark the current directory\" `\n -ScriptBlock {\n param($key, $arg)\n\n $key = [Console]::ReadKey($true)\n $global:PSReadlineMarks[$key.KeyChar] = $pwd\n}\n\nSet-PSReadlineKeyHandler -Key Ctrl+j `\n -BriefDescription JumpDirectory `\n -LongDescription \"Goto the marked directory\" `\n -ScriptBlock {\n param($key, $arg)\n\n $key = [Console]::ReadKey()\n $dir = $global:PSReadlineMarks[$key.KeyChar]\n if ($dir)\n {\n cd $dir\n [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()\n }\n}\n\nSet-PSReadlineKeyHandler -Key Alt+j `\n -BriefDescription ShowDirectoryMarks `\n -LongDescription \"Show the currently marked directories\" `\n -ScriptBlock {\n param($key, $arg)\n\n $global:PSReadlineMarks.GetEnumerator() | % {\n [PSCustomObject]@{Key = $_.Key; Dir = $_.Value} } |\n Format-Table -AutoSize | Out-Host\n\n [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix resource group names in swap ps1 file\n" }, { "from": "human", "value": "# make sure the script stops if one of the swaps failed\n$ErrorActionPreference = \"Stop\"\n\nSelect-AzureRmSubscription -SubscriptionName \"Websites migration\"\n\n$ParametersObject = @{\n\ttargetSlot = \"staging\"\n}\n\nWrite-Host swapping bay site ....\nInvoke-AzureRmResourceAction -ResourceGroupName Default-Web-MSFTWestUS -ResourceType Microsoft.Web/sites -ResourceName explorer-bay -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping blu site ....\nInvoke-AzureRmResourceAction -ResourceGroupName Default-Web-MSFTEastUS -ResourceType Microsoft.Web/sites -ResourceName explorer-blu -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping db3 site ....\nInvoke-AzureRmResourceAction -ResourceGroupName Default-Web-MSFTNorthEurope -ResourceType Microsoft.Web/sites -ResourceName explorer-db3 -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping hk1 site ....\nInvoke-AzureRmResourceAction -ResourceGroupName Default-Web-MSFTEastAsia -ResourceType Microsoft.Web/sites -ResourceName explorer-hk1 -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host Done Swapping all sites" }, { "from": "gpt", "value": "# make sure the script stops if one of the swaps failed\n$ErrorActionPreference = \"Stop\"\n\nSelect-AzureRmSubscription -SubscriptionName \"Websites migration\"\n\n$ParametersObject = @{\n\ttargetSlot = \"staging\"\n}\n\nWrite-Host swapping bay site ....\nInvoke-AzureRmResourceAction -ResourceGroupName explorer-bay -ResourceType Microsoft.Web/sites -ResourceName explorer-bay -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping blu site ....\nInvoke-AzureRmResourceAction -ResourceGroupName explorer-blu -ResourceType Microsoft.Web/sites -ResourceName explorer-blu -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping db3 site ....\nInvoke-AzureRmResourceAction -ResourceGroupName explorer-db3 -ResourceType Microsoft.Web/sites -ResourceName explorer-db3 -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host swapping hk1 site ....\nInvoke-AzureRmResourceAction -ResourceGroupName explorer-hk1 -ResourceType Microsoft.Web/sites -ResourceName explorer-hk1 -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-08-01 -Force\n\nWrite-Host Done Swapping all sites" } ]
powershell
chosen
[ { "from": "human", "value": "Add powershell equivalent of build script\n" }, { "from": "gpt", "value": "<#\n .DESCRIPTION\n Runs a docker build for the DSE version specified in the DSE_VERSION file.\n#>\n\n$scriptPath = Split-Path -parent $PSCommandPath\n\n# Use contents of DSE_VERSION file as variables\nGet-Content \"$scriptPath\\DSE_VERSION\" |% {\n if ($_) {\n $varParts = $_.Split('=')\n New-Variable -Name $varParts[0] -Value $varParts[1]\n }\n}\n\ndocker build --build-arg DSE_VERSION=$DSE_VERSION -t luketillman/datastax-enterprise:$DSE_VERSION -t luketillman/datastax-enterprise:latest ." } ]
powershell
chosen
[ { "from": "human", "value": "Add build script for 2022" }, { "from": "gpt", "value": "param (\n [bool]$DoNotVagrantIfy = $false\n)\n\n$here = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n\n$Timer = [Diagnostics.Stopwatch]::StartNew()\n\nif($DoNotVagrantIfy)\n{\n packer build --only=hyperv-iso --except vagrant-image $here\\windows-2022.json \n}\nelse\n{\n packer build --only=hyperv-iso $here\\windows-2022.json \n}\n\n$Timer.Stop()\n\nWrite-Host \"Hyper-V Image Built in $($Timer.Elapsed)\"" } ]
powershell
chosen
[ { "from": "human", "value": "Add PowerShell completion support for Docker\n" }, { "from": "gpt", "value": "if ($DotFilesShowScriptEntry) {\n Write-Verbose -Message (Get-DotFilesMessage -Message $PSCommandPath)\n}\n\nif (!(Get-Command -Name docker -ErrorAction Ignore)) {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping Docker settings as unable to locate docker.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading Docker settings ...')\n\ntry {\n Import-Module -Name DockerCompletion -ErrorAction Stop -Verbose:$false\n} catch {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Docker command completion unavailable as DockerCompletion module not found.')\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add logging to verion bump script\n" }, { "from": "human", "value": "\n$buildNumber = $env:APPVEYOR_BUILD_VERSION\n$buildFolder = '.'\n\nif($env:APPVEYOR_BUILD_FOLDER) {\n\t$buildFolder = $env:APPVEYOR_BUILD_FOLDER\n}\n\n$projectFilePath = Join-Path $buildFolder \"src\\Halcyon.Mvc\\project.json\"\n\nWrite-Host \"Bumping version for project file: $projectFilePath to $buildNumber\"\n\n$projectConfig = Get-Content $projectFilePath | \n\t\t\t\t\tConvertFrom-Json\n\n$projectConfig.version = $buildNumber\n\n$projectConfig | \n\tConvertTo-Json |\n\tOut-File $projectFilePath\n" }, { "from": "gpt", "value": "\n$buildNumber = $env:APPVEYOR_BUILD_VERSION\n$buildFolder = '.'\n\nif($env:APPVEYOR_BUILD_FOLDER) {\n\t$buildFolder = $env:APPVEYOR_BUILD_FOLDER\n}\n\n$projectFilePath = Join-Path $buildFolder \"src\\Halcyon.Mvc\\project.json\"\n\nWrite-Host \"Bumping version for project file: $projectFilePath to $buildNumber\"\n\n$projectFileContent = Get-Content $projectFilePath\n\nWrite-Host $projectFileContent\n\n$projectConfig = $projectFileContent | ConvertFrom-Json\n\n$projectConfig.version = \"$buildNumber-alpha\"\n\n$projectConfig | \n\tConvertTo-Json |\n\tOut-File $projectFilePath\n" } ]
powershell
chosen
[ { "from": "human", "value": "Install file for google sysprep scripts.\n" }, { "from": "gpt", "value": "# Copyright 2015 Google Inc. All Rights Reserved.\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# 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,\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\n# Install script for updating sysprep scripts on Windows.\n\n$github_zip = 'https://github.com/GoogleCloudPlatform/compute-image-windows/archive/master.zip'\n$local_dest = 'C:\\Program Files\\Google\\Compute Engine'\n$local_github_zip = \"$local_dest\\github_source.zip\"\n$local_github_source = \"$local_dest\\github_source\"\n$sysprep_src = \"$local_github_source\\compute-image-windows-master\\gce\\*\"\n\nWrite-Host 'Starting sysprep install script...'\n\n# Download the GitHub zip of Windows guest code.\n$client = New-Object System.Net.WebClient\n$client.DownloadFile($github_zip, $local_github_zip)\n\n# Load the assembly.\nAdd-Type -AssemblyName System.IO.Compression.FileSystem\n\n# Extract the GitHub zip file.\n[System.IO.Compression.ZipFile]::ExtractToDirectory($local_github_zip, $local_github_source)\n\nCopy-Item $sysprep_src $local_dest -Recurse -Force\nRemove-Item $local_github_zip -Force\nRemove-Item $local_github_source -Recurse -Force\n\nWrite-Host 'Installation of sysprep scripts complete.'\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update environment variables instead of writing appsettings.json.\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\nImport-Module -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\nBackup-File appsettings.json {\n $creds = Get-Content -Raw $env:GOOGLE_APPLICATION_CREDENTIALS | ConvertFrom-Json\n .\\Set-Up.ps1 $creds.client_email\n Run-KestrelTest 5601 -CasperJs11\n}" }, { "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.\n\nImport-Module -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\n$envars = $env:DataProtection:Bucket, $env:DataProtection:KmsKeyName\ntry {\n $env:DataProtection:Bucket = $env:GOOGLE_BUCKET\n $env:DataProtection:KmsKeyName = \"projects/$env:GOOGLE_PROJECT_ID/locations/global/keyRings/dataprotection/cryptoKeys/masterkey\"\n Run-KestrelTest 5601 -CasperJs11\n} finally {\n $env:DataProtection:Bucket, $env:DataProtection:KmsKeyName = $envars\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Install scoop only if the cmd does not exist\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\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" }, { "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\nif (-Not (Get-Command 'scoop' -errorAction SilentlyContinue)) {\n Invoke-Expression (new-object net.webclient).downloadstring('https://get.scoop.sh')\n}\n\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": "Enable Bash on Ubuntu on Windows\n" }, { "from": "human", "value": "# Dev Machine Powershell setup - Requires Admin prompt\n\n# Chocolatey install\niex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))\n\n# install applications\ncinst slack -y\ncinst firefox -y\ncinst google-chrome-x64 -y\ncinst notepadplusplus -y\n# cinst git -y\n# cinst github -y # failing due to md5 sum mismatch\ncinst vim -y\ncinst procexp -y\ncinst putty -y\ncinst nuget.commandline -y\n\n# Setup Powershell symlinks\ncmd /c mklink /D \"$env:USERPROFILE\\Documents\\WindowsPowerShell\\\" \"$PSScriptRoot\"\n\n# Setup vimrc\ncmd /c mklink \"$env:USERPROFILE\\_vimrc\" \"$((Get-Item $PSScriptRoot).parent.FullName)\\.vimrc\"\n" }, { "from": "gpt", "value": "# Dev Machine Powershell setup - Requires Admin prompt\nif (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] \"Administrator\"))\n{\n\t$arguments = \"& '\" + $myinvocation.mycommand.definition + \"'\"\n\tStart-Process powershell -Verb runAs -ArgumentList $arguments\n\tBreak\n}\n\n# Chocolatey install\nif (!(gcm cinst -ErrorAction SilentlyContinue)){\n\tiex ((new-object net.webclient).DownloadString('http://bit.ly/psChocInstall'))\n}\n\n# install applications\ncinst slack -y\ncinst firefox -y\ncinst google-chrome-x64 -y\ncinst notepadplusplus -y\n# cinst git -y\n# cinst github -y # failing due to md5 sum mismatch\ncinst vim -y\ncinst procexp -y\ncinst putty -y\ncinst nuget.commandline -y\n\n# Setup Powershell symlinks\ncmd /c mklink /D \"$env:USERPROFILE\\Documents\\WindowsPowerShell\\\" \"$PSScriptRoot\"\n\n# Setup vimrc\ncmd /c mklink \"$env:USERPROFILE\\_vimrc\" \"$((Get-Item $PSScriptRoot).parent.FullName)\\.vimrc\"\n\n# Enable Windows Optional Features\ntry { Enable-WindowsOptionalFeature -Online -FeatureName \"Microsoft-Windows-Subsystem-Linux\" } catch {} # Fails on TH2, swallow the error." } ]
powershell
chosen
[ { "from": "human", "value": "Add tests for hierarchical paths\n" }, { "from": "gpt", "value": "Describe \"Hierarchical paths\" {\n BeforeAll {\n $data = \"Hello World\"\n Setup -File testFile.txt -Content $data\n }\n\n It \"should work with Join-Path \" {\n $testPath = Join-Path $TestDrive testFile.txt\n Get-Content $testPath | Should Be $data\n }\n\n It \"should work with platform's slashes\" {\n $testPath = \"$TestDrive$([IO.Path]::DirectorySeparatorChar)testFile.txt\"\n Get-Content $testPath | Should Be $data\n }\n\n It \"should work with forward slashes\" {\n $testPath = \"$TestDrive/testFile.txt\"\n Get-Content $testPath | Should Be $data\n }\n\n It \"should work with backward slashes\" {\n $testPath = \"$TestDrive\\testFile.txt\"\n Get-Content $testPath | Should Be $data\n }\n\n It \"should work with backward slashes for each separator\" {\n $testPath = \"$TestDrive\\testFile.txt\".Replace(\"/\",\"\\\")\n Get-Content $testPath | should be $data\n }\n\n It \"should work with forward slashes for each separator\" {\n $testPath = \"$TestDrive/testFile.txt\".Replace(\"\\\",\"/\")\n Get-Content $testPath | should be $data\n }\n\n It \"should work even if there are too many forward slashes\" {\n $testPath = \"$TestDrive//////testFile.txt\"\n Get-Content $testPath | should be $data\n }\n\n It \"should work even if there are too many backward slashes\" {\n $testPath = \"$TestDrive\\\\\\\\\\\\\\testFile.txt\"\n Get-Content $testPath | should be $data\n }\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add additional generally uninteresting AD User properties\n" }, { "from": "human", "value": "if (!(Test-IsWindows)) {\n return\n}\n\nif (!(Get-Module -Name ActiveDirectory -ListAvailable)) {\n Write-Verbose -Message '[dotfiles] Skipping ActiveDirectory settings as module not found.'\n return\n}\n\nWrite-Verbose -Message '[dotfiles] Loading ActiveDirectory settings ...'\n\n# User properties we usually don't care about\n$ADUserIgnoredProperties = @(\n # Only exposed via LDAP attributes\n 'dSCorePropagationData',\n 'lastLogoff',\n 'logonCount',\n 'mS-DS-ConsistencyGuid',\n 'uSNChanged',\n 'uSNCreated',\n\n # LDAP attributes & PoSh properties with identical names\n 'CanonicalName',\n 'CN',\n 'DistinguishedName',\n 'MemberOf',\n 'ObjectGUID',\n\n # PoSh property followed by equivalent LDAP attribute(s)\n 'BadLogonCount',\n 'badPwdCount',\n\n 'Created',\n 'whenCreated',\n 'createTimeStamp',\n\n 'LastBadPasswordAttempt',\n 'badPasswordTime',\n\n 'LastLogonDate',\n 'lastLogon',\n 'lastLogonTimestamp',\n\n 'Modified',\n 'whenChanged',\n 'modifyTimeStamp',\n\n 'PasswordLastSet',\n 'pwdLastSet',\n\n 'SID'\n 'objectSid',\n\n # Interesting but duplicated properties\n 'sn' # Surname\n)\n" }, { "from": "gpt", "value": "if (!(Test-IsWindows)) {\n return\n}\n\nif (!(Get-Module -Name ActiveDirectory -ListAvailable)) {\n Write-Verbose -Message '[dotfiles] Skipping ActiveDirectory settings as module not found.'\n return\n}\n\nWrite-Verbose -Message '[dotfiles] Loading ActiveDirectory settings ...'\n\n# User properties we usually don't care about\n$ADUserIgnoredProperties = @(\n # Only exposed via LDAP attributes\n 'dSCorePropagationData',\n 'lastLogoff',\n 'logonCount',\n 'mS-DS-ConsistencyGuid',\n 'msDS-KeyCredentialLink',\n 'uSNChanged',\n 'uSNCreated',\n\n # LDAP attributes & PoSh properties with identical names\n 'CanonicalName',\n 'CN',\n 'DistinguishedName',\n 'MemberOf',\n 'ObjectGUID',\n\n # PoSh property followed by equivalent LDAP attribute(s)\n 'BadLogonCount',\n 'badPwdCount',\n\n 'Created',\n 'whenCreated',\n 'createTimeStamp',\n\n 'LastBadPasswordAttempt',\n 'badPasswordTime',\n\n 'LastLogonDate',\n 'lastLogon',\n 'lastLogonTimestamp',\n\n 'Modified',\n 'whenChanged',\n 'modifyTimeStamp',\n\n 'PasswordLastSet',\n 'pwdLastSet',\n\n 'SID'\n 'objectSid',\n\n # Interesting but duplicated properties\n 'mail' # EmailAddress\n 'sn' # Surname\n)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix out of control clean script\n" }, { "from": "human", "value": "param(\n [Parameter(Mandatory=$true)][string]$apikey)\n \n$url=\"http://mobile.nuget.couchbase.com/nuget/CI/Packages()?`$format=json\"\n$content=$(Invoke-WebRequest $url).Content\n$results = $(ConvertFrom-Json $content).d.results\nforeach($result in $results) {\n $ticks = [long]$result.Published.Substring(7,18)\n $published = New-Object DateTime($ticks)\n $now = Get-Date\n $limit = New-TimeSpan -Days 30\n if(($now - $published) -gt $limit) {\n echo \"Deleting $($result.Id)-$($result.Version)\"\n \n # Nuget won't fail when deleting a non-existent package, and Internal is a strict subset of CI\n nuget delete -ApiKey $apikey -Source http://mobile.nuget.couchbase.com/nuget/CI -NonInteractive $result.Id $result.Version\n nuget delete -ApiKey $apikey -Source http://mobile.nuget.couchbase.com/nuget/Internal -NonInteractive $result.Id $result.Version\n }\n}" }, { "from": "gpt", "value": "param(\n [Parameter(Mandatory=$true)][string]$apikey)\n \n$ErrorActionPreference = \"Stop\"\n\n$url=\"http://mobile.nuget.couchbase.com/nuget/CI/Packages()?`$format=json\"\n$content=$(Invoke-WebRequest $url).Content\n$results = $(ConvertFrom-Json $content).d.results\nforeach($result in $results) {\n $ticks = [long]$result.Published.Substring(7,13)\n $published = New-Object DateTime($ticks)\n $now = Get-Date\n $limit = New-TimeSpan -Days 30\n if(($now - $published) -gt $limit) {\n echo \"Deleting $($result.Id)-$($result.Version)\"\n \n # Nuget won't fail when deleting a non-existent package, and Internal is a strict subset of CI\n nuget delete -ApiKey $apikey -Source http://mobile.nuget.couchbase.com/nuget/CI -NonInteractive $result.Id $result.Version\n nuget delete -ApiKey $apikey -Source http://mobile.nuget.couchbase.com/nuget/Internal -NonInteractive $result.Id $result.Version\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Correct typo in chef-dk installer name\n" }, { "from": "human", "value": "# Download the chef-solo installer\r\n$chefSoloInstaller = Join-Path $tmpDir 'chef-solo.msi'\r\nWrite-Host \"Downloading chef-solo MSI to $chefSoloInstaller...\"\r\nDoFileDownload 'https://www.opscode.com/chef/install.msi' \"$chefSoloInstaller\"\r\n\r\n# Execute the installer and pass the exit code through to the shell\r\nWrite-Host \"Running the chef-solo installer...\"\r\n(Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/package $chefSoloInstaller /passive\" -Wait -Passthru).ExitCode\r\n\r\n# Download the chef-dk installer\r\n$chefDkInstaller = Join-Path $tmpDir 'chef-solo.msi'\r\nWrite-Host \"Downloading chef-dk MSI to $chefDkInstaller...\"\r\nDoFileDownload 'https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chefdk-0.4.0-1.msi' \"$chefDkInstaller\"\r\n\r\n# Execute the installer and pass the exit code through to the shell\r\nWrite-Host \"Running the chef-dk installer...\"\r\n(Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/package $chefDkInstaller /passive\" -Wait -Passthru).ExitCode\r\n" }, { "from": "gpt", "value": "# Download the chef-solo installer\r\n$chefSoloInstaller = Join-Path $tmpDir 'chef-solo.msi'\r\nWrite-Host \"Downloading chef-solo MSI to $chefSoloInstaller...\"\r\nDoFileDownload 'https://www.opscode.com/chef/install.msi' \"$chefSoloInstaller\"\r\n\r\n# Execute the installer and pass the exit code through to the shell\r\nWrite-Host \"Running the chef-solo installer...\"\r\n(Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/package $chefSoloInstaller /passive\" -Wait -Passthru).ExitCode\r\n\r\n# Download the chef-dk installer\r\n$chefDkInstaller = Join-Path $tmpDir 'chef-dk.msi'\r\nWrite-Host \"Downloading chef-dk MSI to $chefDkInstaller...\"\r\nDoFileDownload 'https://opscode-omnibus-packages.s3.amazonaws.com/windows/2008r2/x86_64/chefdk-0.4.0-1.msi' \"$chefDkInstaller\"\r\n\r\n# Execute the installer and pass the exit code through to the shell\r\nWrite-Host \"Running the chef-dk installer...\"\r\n(Start-Process -FilePath \"msiexec.exe\" -ArgumentList \"/package $chefDkInstaller /passive\" -Wait -Passthru).ExitCode\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Refactor and fix for choco version\n" }, { "from": "human", "value": "Param(\r\n [Parameter(Mandatory=$true)][string]$version\r\n)\r\n\r\n$chocoInstall = 'chocolatey\\tools\\chocolateyInstall.ps1'\r\n$setup = \"build\\installers\\headset-$version-setup.exe\"\r\n\r\nif (!(Test-Path -Path \"$setup\")) {\r\n exit 1\r\n}\r\n\r\n$sha256 = (CertUtil -hashfile \"$setup\" SHA256)[1].Replace(' ', '')\r\n\r\n$choco = Get-Content $chocoInstall\r\n$choco[11] = \" checksum = '$sha256'\"\r\n$choco | Out-File -filepath \"$chocoInstall\" -Encoding UTF8\r\n\r\nif (!(Test-Path -Path \"$PWD\\build\")) {\r\n New-Item -ItemType Directory -Force -Path \"$PWD\\build\"\r\n}\r\n\r\nchoco pack 'chocolatey\\headset.nuspec' -outputdirectory 'build'" }, { "from": "gpt", "value": "Param(\r\n [Parameter(Mandatory=$true)][string]$version\r\n)\r\n\r\n$chocoInstall = '..\\.chocolatey\\tools\\chocolateyInstall.ps1'\r\n$setup = \"build\\installers\\headset-$version-setup.exe\"\r\n\r\nif (!(Test-Path -Path \"$setup\")) {\r\n exit 1\r\n}\r\n\r\n$sha256 = (CertUtil -hashfile \"$setup\" SHA256)[1].Replace(' ', '')\r\n\r\n$choco = Get-Content $chocoInstall\r\n\r\n$choco[0] = \"`$version = $version\"\r\n$choco[11] = \" checksum = '$sha256'\"\r\n\r\n$choco | Out-File -filepath \"$chocoInstall\" -Encoding UTF8\r\n\r\nif (!(Test-Path -Path \"$PWD\\build\")) {\r\n New-Item -ItemType Directory -Force -Path \"$PWD\\build\"\r\n}\r\n\r\nchoco pack '..\\.chocolatey\\headset.nuspec' -outputdirectory 'build'" } ]
powershell
chosen
[ { "from": "system", "value": "Add 'alpha' prelease designation for version 4.8.0\n" }, { "from": "human", "value": "@{\r\n RootModule = 'psake.psm1'\r\n ModuleVersion = '4.8.0'\r\n GUID = 'cfb53216-072f-4a46-8975-ff7e6bda05a5'\r\n Author = 'James Kovacs'\r\n Copyright = 'Copyright (c) 2010-18 James Kovacs, Damian Hickey, Brandon Olin, and Contributors'\r\n PowerShellVersion = '3.0'\r\n Description = 'psake is a build automation tool written in PowerShell.'\r\n FunctionsToExport = @(\r\n 'Invoke-psake'\r\n 'Invoke-Task'\r\n 'Get-PSakeScriptTasks'\r\n 'Task'\r\n 'Properties'\r\n 'Include'\r\n 'FormatTaskName'\r\n 'TaskSetup'\r\n 'TaskTearDown'\r\n 'Framework'\r\n 'Assert'\r\n 'Exec'\r\n )\r\n VariablesToExport = 'psake'\r\n PrivateData = @{\r\n PSData = @{\r\n ReleaseNotes = 'https://raw.githubusercontent.com/psake/psake/master/CHANGELOG.md'\r\n LicenseUri = 'https://raw.githubusercontent.com/psake/psake/master/license.txt'\r\n ProjectUri = 'https://github.com/psake/psake'\r\n Tags = @('Build', 'Task')\r\n IconUri = 'https://raw.githubusercontent.com/psake/graphics/master/png/psake-single-icon-teal-bg-256x256.png'\r\n }\r\n }\r\n}\r\n" }, { "from": "gpt", "value": "@{\r\n RootModule = 'psake.psm1'\r\n ModuleVersion = '4.8.0'\r\n GUID = 'cfb53216-072f-4a46-8975-ff7e6bda05a5'\r\n Author = 'James Kovacs'\r\n Copyright = 'Copyright (c) 2010-18 James Kovacs, Damian Hickey, Brandon Olin, and Contributors'\r\n PowerShellVersion = '3.0'\r\n Description = 'psake is a build automation tool written in PowerShell.'\r\n FunctionsToExport = @(\r\n 'Invoke-psake'\r\n 'Invoke-Task'\r\n 'Get-PSakeScriptTasks'\r\n 'Task'\r\n 'Properties'\r\n 'Include'\r\n 'FormatTaskName'\r\n 'TaskSetup'\r\n 'TaskTearDown'\r\n 'Framework'\r\n 'Assert'\r\n 'Exec'\r\n )\r\n VariablesToExport = 'psake'\r\n PrivateData = @{\r\n PSData = @{\r\n PreRelease = 'alpha'\r\n ReleaseNotes = 'https://raw.githubusercontent.com/psake/psake/master/CHANGELOG.md'\r\n LicenseUri = 'https://raw.githubusercontent.com/psake/psake/master/license.txt'\r\n ProjectUri = 'https://github.com/psake/psake'\r\n Tags = @('Build', 'Task')\r\n IconUri = 'https://raw.githubusercontent.com/psake/graphics/master/png/psake-single-icon-teal-bg-256x256.png'\r\n }\r\n }\r\n}\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Refactor postbuild js/html processing script\n" }, { "from": "human", "value": "Param([Parameter(Mandatory = $True, Position = 1)][string] $dir)\n$ErrorActionPreference = \"Stop\"\n\nSet-Location $dir\n\nForEach($file in Get-ChildItem -Include *.js, *.html -Recurse){\n $lines = Get-Content -Path $file.FullName\n $lines = ($lines | % { $_.TrimStart() }) -Replace '^(.*?)((?<=^|[;{}()] )//\\s.*)?$', '$1'\n $lines | Where { $_ -ne '' } | Set-Content -Path $file.FullName\n\n Write-Host \"Processed\" $file.FullName.Substring($dir.Length)\n}\n" }, { "from": "gpt", "value": "Param([Parameter(Mandatory = $True, Position = 1)][string] $dir)\n$ErrorActionPreference = \"Stop\"\n\nSet-Location $dir\n\nfunction Rewrite-File{\n [CmdletBinding()]\n Param([Parameter(Mandatory = $True, ValueFromPipeline = $True)][array] $lines, [Parameter(Mandatory = $True, Position = 1)] $file)\n \n $lines | Where { $_ -ne '' } | Set-Content -Path $file.FullName\n Write-Host \"Processed\" $file.FullName.Substring($dir.Length)\n}\n\nForEach($file in Get-ChildItem -Include *.js -Recurse){\n $lines = Get-Content -Path $file.FullName\n $lines = ($lines | % { $_.TrimStart() }) -Replace '^(.*?)((?<=^|[;{}()])\\s?//(?:\\s.*|$))?$', '$1'\n ,$lines | Rewrite-File $file\n}\n\nForEach($file in Get-ChildItem -Include *.html -Recurse){\n $lines = Get-Content -Path $file.FullName\n ,($lines | % { $_.TrimStart() }) | Rewrite-File $file\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update Coverity Scan script to v7.6.0\n" }, { "from": "human", "value": "# Move to the project root folder (parent from current script folder)\n\nfunction Get-ScriptDirectory\n{ \n $Invocation = (Get-Variable MyInvocation -Scope 1).Value \n Split-Path $Invocation.MyCommand.Path \n}\n\n$rootFolder = (Get-Item (Get-ScriptDirectory)).Parent.FullName\nSet-Location $rootFolder\n\n# Import modules\n\nImport-Module -Name \".\\scripts\\Invoke-NuGet.psm1\"\nImport-Module -Name \".\\scripts\\Invoke-DotNetZip.psm1\"\n\n# Install DotNetZip package via NuGet\n\nInstall-DotNetZip\n\n# Clean the solution\n\n./scripts/Clean.ps1\n\n# Run the Coverity Build tool\n\n& \"C:\\Program Files\\cov-analysis-win64-7.5.0\\bin\\cov-build\" --dir artifacts\\cov-int powershell ./scripts/BuildRelease.ps1 -noTests\n\n# Zip the resulting files\n\nWrite-Zip .\\artifacts\\cov-int .\\artifacts\\Okra.Core-cov-int.zip" }, { "from": "gpt", "value": "# Move to the project root folder (parent from current script folder)\n\nfunction Get-ScriptDirectory\n{ \n $Invocation = (Get-Variable MyInvocation -Scope 1).Value \n Split-Path $Invocation.MyCommand.Path \n}\n\n$rootFolder = (Get-Item (Get-ScriptDirectory)).Parent.FullName\nSet-Location $rootFolder\n\n# Import modules\n\nImport-Module -Name \".\\scripts\\Invoke-NuGet.psm1\"\nImport-Module -Name \".\\scripts\\Invoke-DotNetZip.psm1\"\n\n# Install DotNetZip package via NuGet\n\nInstall-DotNetZip\n\n# Clean the solution\n\n./scripts/Clean.ps1\n\n# Run the Coverity Build tool\n\n& \"C:\\Program Files\\cov-analysis-win64-7.6.0\\bin\\cov-build\" --dir artifacts\\cov-int powershell ./scripts/BuildRelease.ps1 -noTests\n\n# Zip the resulting files\n\nWrite-Zip .\\artifacts\\cov-int .\\artifacts\\Okra.Core-cov-int.zip" } ]
powershell
chosen
[ { "from": "human", "value": "Create script to build on windows\n" }, { "from": "gpt", "value": "docker build -q -f Dockerfile.windows.ci -t ruby-slim .\ndocker run -ti --rm -v ${PWD}:C:\\stack_master -w C:\\stack_master ruby-slim gem build stack_master.gemspec\n" } ]
powershell
chosen
[ { "from": "system", "value": "Make sure profile is sourced\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 cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n}\n\niex (new-object net.webclient).downloadstring('https://get.scoop.sh')\nscoop install concfg\nconcfg import -n solarized-light small concfg\\source-code-pro.json\nconcfg clean\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 cmd /c mklink \"$PROFILE\" \"$($args[0])\"\n}\n\n. $PROFILE\n\niex (new-object net.webclient).downloadstring('https://get.scoop.sh')\nscoop install concfg\nconcfg import -n solarized-light small concfg\\source-code-pro.json\nconcfg clean\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix package installer to use default directory\n" }, { "from": "human", "value": "$packageName = 'PneumaticTube.portable' \n$url = 'https://github.com/hartez/PneumaticTube/releases/download/1.0.2/PneumaticTube.zip' \n\ntry { \n $binRoot = Get-BinRoot\n $installDir = Join-Path $binRoot \"$packageName\"\n Write-Host \"Adding `'$installDir`' to the path and the current shell path\"\n Install-ChocolateyPath \"$installDir\"\n $env:Path = \"$($env:Path);$installDir\"\n \n Install-ChocolateyZipPackage \"$packageName\" \"$url\" \"$installDir\"\n \n Write-ChocolateySuccess \"$packageName\"\n} catch {\n Write-ChocolateyFailure \"$packageName\" \"$($_.Exception.Message)\"\n throw \n}" }, { "from": "gpt", "value": "$packageName = 'PneumaticTube.portable' \n$url = 'https://github.com/hartez/PneumaticTube/releases/download/1.0.2/PneumaticTube.zip' \n\ntry { \n $installDir = \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\n Install-ChocolateyZipPackage \"$packageName\" \"$url\" \"$installDir\"\n Write-ChocolateySuccess \"$packageName\"\n} catch {\n Write-ChocolateyFailure \"$packageName\" \"$($_.Exception.Message)\"\n throw \n}" } ]
powershell
chosen
[ { "from": "system", "value": "Use netapi-helper base image for 1709\n" }, { "from": "human", "value": "$version=$(select-string -Path Dockerfile -Pattern \"ENV PROMETHEUS_VERSION\").ToString().split()[-1]\ndocker tag prometheus stefanscherer/prometheus-windows:$version-2016\ndocker push stefanscherer/prometheus-windows:$version-2016\n\nnpm install -g rebase-docker-image\nrebase-docker-image stefanscherer/prometheus-windows:$version-2016 -t stefanscherer/prometheus-windows:$version-1709 -b microsoft/nanoserver:1709\n\nInvoke-WebRequest -UseBasicParsing https://6582-88013053-gh.circle-artifacts.com/0/work/build/docker-windows-amd64 -OutFile docker.exe\n\n.\\docker.exe manifest create `\n stefanscherer/prometheus-windows:$version `\n stefanscherer/prometheus-windows:$version-2016 `\n stefanscherer/prometheus-windows:$version-1709\n.\\docker.exe manifest push stefanscherer/prometheus-windows:$version\n\n.\\docker.exe manifest create `\n stefanscherer/prometheus-windows:latest `\n stefanscherer/prometheus-windows:$version-2016 `\n stefanscherer/prometheus-windows:$version-1709\n.\\docker.exe manifest push stefanscherer/prometheus-windows:latest\n" }, { "from": "gpt", "value": "$version=$(select-string -Path Dockerfile -Pattern \"ENV PROMETHEUS_VERSION\").ToString().split()[-1]\ndocker tag prometheus stefanscherer/prometheus-windows:$version-1607\ndocker push stefanscherer/prometheus-windows:$version-1607\n\nnpm install -g rebase-docker-image\nrebase-docker-image stefanscherer/prometheus-windows:$version-1607 `\n -t stefanscherer/prometheus-windows:$version-1709 `\n -b stefanscherer/netapi-helper:1709\n\n..\\update-docker-cli.ps1\n\ndocker manifest create `\n stefanscherer/prometheus-windows:$version `\n stefanscherer/prometheus-windows:$version-1607 `\n stefanscherer/prometheus-windows:$version-1709\ndocker manifest push stefanscherer/prometheus-windows:$version\n\ndocker manifest create `\n stefanscherer/prometheus-windows:latest `\n stefanscherer/prometheus-windows:$version-1607 `\n stefanscherer/prometheus-windows:$version-1709\ndocker manifest push stefanscherer/prometheus-windows:latest\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix for it not working with windows\n" }, { "from": "human", "value": "git clone https://github.com/CorruptComputer/Officer-Beepsky\n\ncd Officer-Beepsky\n\n$token = Read-Host -Prompt 'What is the Discord token? '\n\n$owner = Read-Host -Prompt 'What is the Discord ID of the owner? '\n\nfor($i = 1; $i -gt 0; $i = $LASTEXITCODE){\n git pull origin master\n ./gradlew.bat fatJar\n $file = Resolve-Path 'build/libs/Officer-Beepsky-*.jar' | Select-Object -ExpandProperty Path\n java -jar $file %token% %owner%\n}\n" }, { "from": "gpt", "value": "git clone https://github.com/CorruptComputer/Officer-Beepsky\n\ncd Officer-Beepsky\n\n$token = Read-Host -Prompt 'What is the Discord token? '\n\n$owner = Read-Host -Prompt 'What is the Discord ID of the owner? '\n\nfor($i = 1; $i -gt 0; $i = $LASTEXITCODE){\n git pull origin master\n ./gradlew.bat fatJar\n $file = Resolve-Path 'build/libs/Officer-Beepsky-*.jar' | Select-Object -ExpandProperty Path\n java -jar $file $token $owner\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add sync-WsusClient to force computers to check in with update server\n" }, { "from": "gpt", "value": "function sync-WsusClient {\n <#\n.SYNOPSIS\n Function to force the given computer(s) to check for updates and check in with the WSUS server\n.DESCRIPTION\n Connects to computer list over WinRM (PsSession) and forces it to check for updates and report to its WSUS server\n Default if no computers listed is to use localhost\n Meant to run against many computers and get quick results\n.PARAMETER ComputerName\n A string list of computer names against which to run this sync command\n.PARAMETER Credential\n A \"pscredential\" that will be used to connect to the remote computer(s)\n.EXAMPLE\n Sync-WsusClient\n \"localhost - Done!\"\n.EXAMPLE\n Sync-WsusClient server1, server2, server3, server4\n \"server2 - Done!\"\n \"server1 - Done!\"\n \"server4 - Done!\"\n \"server3 - Done!\"\n.EXAMPLE\n Sync-WsusClient server1, server2 -Credential admin\n (enter your credential and then...)\n \"server2 - Done!\"\n \"server1 - Done!\"\n.NOTES\n Here's one place where it came from: http://pleasework.robbievance.net/howto-force-really-wsus-clients-to-check-in-on-demand/\n Roger P Seekell, (2019), 9-13-2019\n#>\nParam(\n [Parameter(ValueFromPipeline=$true,\n ValueFromPipelineByPropertyName=$true)]\n [string[]]$ComputerName = 'localhost',\n [pscredential]$Credential = $null\n)\nprocess {\n #this script block will run on each computer\n $scriptBlock = {\n try {\n $updateSession = New-Object -com \"Microsoft.Update.Session\"\n $null = $updateSession.CreateUpdateSearcher().Search($criteria).UPdates #I don't want to see them\n wuauclt /reportnow\n \"$env:computername - Done!\"\n }\n catch {\n Write-Error \"Sync unsuccessful on $env:computername : $_\"\n }\n }#end script block\n\n $splat = @{\"ComputerName\" = $ComputerName; \"ScriptBlock\" = $scriptBlock}\n\n if ($Credential -ne $null) {\n $splat += @{\"Credential\" = $Credential}\n }\n\n Invoke-Command @splat #run with the two or three parameters above\n}#end process\n\n}#end function\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add a script to update package\n" }, { "from": "gpt", "value": "function Update-Package\n{\n [CmdletBinding()]\n Param\n (\n # Name of the package\n [Parameter(Mandatory=$true,\n Position=0)]\n [string[]]\n $Name,\n\n # Provider associated with the package\n [Alias(\"Provider\")]\n [string]\n $ProviderName\n )\n\n DynamicParam {\n $paramDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary\n\n # Get the required dynamic parameter for install\n if (-not ([string]::IsNullOrWhiteSpace($ProviderName)))\n {\n $providerObject = Get-PackageProvider -Name $ProviderName | Select -First 1\n \n if ($null -ne $providerObject -and ($providerObject.DynamicOptions -ne $null -and $providerObject.DynamicOptions.Count -gt 0))\n {\n foreach ($option in $providerObject.DynamicOptions)\n {\n $optionalAttribute = New-Object System.Management.Automation.ParameterAttribute\n $optionalAttribute.Mandatory = $option.IsRequired\n\n $attributes = New-Object System.Collections.ObjectModel.Collection[System.Attribute]\n $attributes.Add($optionalAttribute)\n\n $param = New-Object System.Management.Automation.RuntimeDefinedParameter($option.Name, [System.Object], $attributes)\n\n $paramDictionary.Add($option.Name, $param)\n }\n } \n }\n\n return $paramDictionary\n }\n\n Process {\n $packagesToBeUpdated = Get-Package @PSBoundParameters\n\n foreach ($package in $packagesToBeUpdated)\n {\n $possibleNewPackage = Find-Package -Name $package.Name -ProviderName $package.ProviderName\n $possibleNewVersion = [version]$possibleNewPackage.Version\n $version = [version]$package.Version\n\n if ($possibleNewVersion -gt $version)\n {\n Write-Verbose \"Need to update since $possibleNewVersion is found for $($package.Name) which has version $($package.Version)\" \n $PSBoundParameters[\"RequiredVersion\"] = $possibleNewVersion\n Install-Package @PSBoundParameters\n }\n else\n {\n Write-Verbose \"$($package.Name) has the latest version $possibleNewVersion\"\n } \n }\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Fix typo in artifact script.\n" }, { "from": "human", "value": "[CmdletBinding()]\nParam(\n [Parameter(Mandatory=$True)]\n [string]$Platform,\n\n [Parameter(Mandatory=$True)]\n [string]$Configuration\n)\n\n$binStub = $Configuration\n\n$zip = \"colore.zip\"\n\nIf ($Platform -eq \"Any CPU\")\n{\n $zip = \"colore_anycpu.zip\"\n}\nElse\n{\n $binStub = \"$Platform\\$binStub\"\n If ($Platform -eq \"x86\")\n {\n $zip = \"colore_x86.zip\"\n }\n Else\n {\n $zip = \"colore_x64.zip\"\n }\n}\n\nWrite-Host \"Zipping artifacts for $Platform - $Configuration\"\n\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.dll\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.xml\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.pdb\n\n# Create NuGet package if Release and Any CPU\nif ($Configuration -eq \"Release\" -And $Platform -eq \"Any CPU\")\n{\n Write-Host \"Creating NuGet package\"\n nuget.exe --% pack Corale.Colore\\Corale.Colore.csproj -Prop Configuration=Release -Prop Platform=AnyCPU -Version \"%APPVEYOR_BUILD_VERSION%\"\n $name = \"Corale.Colore.$Env:APPVEYOR_BUILD_VERSION\"\n $file = \"$name.nupkg\"\n Push-AppveyorArtifact $file -FileName $name -DeploymentName \"nuget_package\" }\n}\n" }, { "from": "gpt", "value": "[CmdletBinding()]\nParam(\n [Parameter(Mandatory=$True)]\n [string]$Platform,\n\n [Parameter(Mandatory=$True)]\n [string]$Configuration\n)\n\n$binStub = $Configuration\n\n$zip = \"colore.zip\"\n\nIf ($Platform -eq \"Any CPU\")\n{\n $zip = \"colore_anycpu.zip\"\n}\nElse\n{\n $binStub = \"$Platform\\$binStub\"\n If ($Platform -eq \"x86\")\n {\n $zip = \"colore_x86.zip\"\n }\n Else\n {\n $zip = \"colore_x64.zip\"\n }\n}\n\nWrite-Host \"Zipping artifacts for $Platform - $Configuration\"\n\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.dll\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.xml\n7z.exe a $zip .\\Corale.Colore\\bin\\$binStub\\*.pdb\n\n# Create NuGet package if Release and Any CPU\nif ($Configuration -eq \"Release\" -And $Platform -eq \"Any CPU\")\n{\n Write-Host \"Creating NuGet package\"\n nuget.exe --% pack Corale.Colore\\Corale.Colore.csproj -Prop Configuration=Release -Prop Platform=AnyCPU -Version \"%APPVEYOR_BUILD_VERSION%\"\n $name = \"Corale.Colore.$Env:APPVEYOR_BUILD_VERSION\"\n $file = \"$name.nupkg\"\n Push-AppveyorArtifact $file -FileName $name -DeploymentName \"nuget_package\"\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Allow the password for the created user to be supplied at the command line.\n" }, { "from": "human", "value": "param\r\n(\r\n [Parameter(Mandatory=$true)]\r\n [string]$user\r\n)\r\n$Computer = [ADSI]\"WinNT://$Env:COMPUTERNAME,Computer\"\r\n\r\n$LocalUser = $Computer.Create(\"User\", $user)\r\n$LocalUser.SetPassword(\"PASsw0r4&!=\")\r\n$LocalUser.SetInfo()\r\nnet localgroup Administrators $user /ADD\r\n" }, { "from": "gpt", "value": "param\r\n(\r\n [Parameter(Mandatory=$true)]\r\n [string]$user,\r\n [Parameter(Mandatory=$false)]\r\n [string]$password=\"PASsw0r4&!=\"\r\n)\r\n$Computer = [ADSI]\"WinNT://$Env:COMPUTERNAME,Computer\"\r\n\r\n$LocalUser = $Computer.Create(\"User\", $user)\r\n$LocalUser.SetPassword($password)\r\n$LocalUser.SetInfo()\r\nnet localgroup Administrators $user /ADD\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Set path in Publish script\n" }, { "from": "human", "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 \".\"\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" }, { "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.LinqExtensions\"\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": "windows: Allow run_all_tests.ps1 to skip tests\n\nUse -TestExceptions to filter out tests with known problems.\nTest list should follow a space, separated by a colon, i.e.\n\npowershell -command .\\run_all_tests.ps1 -TestExceptions ^\nVkLayerTest.RequiredParameter:^\nVkLayerTest.UnrecognizedValue\n" }, { "from": "human", "value": "# Be sure to run \"Set-ExecutionPolicy RemoteSigned\" before running powershell scripts\r\n\r\nParam([switch]$Debug)\r\n\r\nif ($Debug) {\r\n $dPath = \"Debug\"\r\n} else {\r\n $dPath = \"Release\"\r\n}\r\n\r\nSet-Item -path env:Path -value ($env:Path + \";..\\loader\\$dPath\")\r\nSet-Item -path env:Path -value ($env:Path + \";gtest-1.7.0\\$dPath\")\r\n$env:VK_LAYER_PATH = \"..\\layers\\$dPath\"\r\n\r\n& $dPath\\vk_loader_validation_tests\r\nif ($lastexitcode -ne 0) {\r\n exit 1\r\n}\r\n\r\n& $dPath\\vk_layer_validation_tests\r\nif ($lastexitcode -ne 0) {\r\n exit 1\r\n}\r\n.\\vkvalidatelayerdoc.ps1\r\nexit $lastexitcode" }, { "from": "gpt", "value": "# Be sure to run \"Set-ExecutionPolicy RemoteSigned\" before running powershell scripts\r\n\r\n# Use TestExceptions to filter out tests with known problems, separated by a colon\r\n# i.e. run_all_tests.ps1 -TestExceptions VkLayerTest.RequiredParameter:VkLayerTest.UnrecognizedValue\r\n\r\n# To trigger Debug tests, specify the parameter with a hyphen\r\n# i.e run_all_tests.ps1 -Debug\r\n\r\nParam(\r\n [switch]$Debug,\r\n [string]$TestExceptions\r\n)\r\n\r\nif ($Debug) {\r\n $dPath = \"Debug\"\r\n} else {\r\n $dPath = \"Release\"\r\n}\r\n\r\nSet-Item -path env:Path -value ($env:Path + \";..\\loader\\$dPath\")\r\nSet-Item -path env:Path -value ($env:Path + \";gtest-1.7.0\\$dPath\")\r\n$env:VK_LAYER_PATH = \"..\\layers\\$dPath\"\r\n\r\n& $dPath\\vk_loader_validation_tests\r\nif ($lastexitcode -ne 0) {\r\n exit 1\r\n}\r\n\r\n& $dPath\\vk_layer_validation_tests --gtest_filter=-$TestExceptions\r\nif ($lastexitcode -ne 0) {\r\n exit 1\r\n}\r\n\r\n.\\vkvalidatelayerdoc.ps1\r\nexit $lastexitcode\r\n" } ]
powershell
chosen
[ { "from": "human", "value": "Upgrade packges script. Keeps things up to date.\n" }, { "from": "gpt", "value": "echo \"Upgrading NCU:\"\nnpm install -g npm-check-updates\n\ncd packages\n\necho \"Upgrading ste-core:\"\ncd ste-core\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading ste-events:\"\ncd ste-events\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading ste-signals:\"\ncd ste-signals\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading ste-simple-events:\"\ncd ste-simple-events\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading strongly-typed-Events:\"\ncd strongly-typed-events\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading ste-browser:\"\ncd ste-browser\nncu -u\nnpm install\ncd ..\n\necho \"Upgrading root:\"\ncd ..\nncu -u\nnpm install\n\necho \"Building & testing:\"\nnpm build\nnpm test\n\necho \"Ready!\"" } ]
powershell
chosen
[ { "from": "system", "value": "Allow force of native build through an environment variable\n" }, { "from": "human", "value": "$files = git diff --name-only HEAD~1 HEAD\n\nif ($files -contains \"ImageMagick/Source/ImageMagick.commit\") {\n Write-Host \"##vso[task.setvariable variable=BuildNative;isOutput=true]true\"\n}" }, { "from": "gpt", "value": "function BuildNative() {\n if ($env:native -eq \"true\") {\n return $true\n }\n\n $files = git diff --name-only HEAD~1 HEAD\n return $files -contains \"ImageMagick/Source/ImageMagick.commit\"\n}\n\nif (BuildNative) {\n Write-Host \"##vso[task.setvariable variable=BuildNative;isOutput=true]true\"\n} else {\n Write-Host \"Not building the native library.\"\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Fix git function where it does not handle /.\n" }, { "from": "human", "value": "function IsDirty {\n if((git status -s --ignore-submodules=dirty).length -ne 0) {\n return 1\n }\n\n return 0\n}\n\nfunction GetCurrentGitBranch {\n $ref=git symbolic-ref --quiet HEAD\n\tif($ref.length -ne 0) {\n\t\t$postion = $ref.LastIndexOf(\"/\")\n\t\treturn $ref.Substring($postion+1)\n }\n else {\n $ref=git rev-parse --short HEAD\n }\n return $ref\n}\n\nfunction GetCurrentGitBranchSha {\n return git rev-parse --short HEAD\n}\n\n" }, { "from": "gpt", "value": "function IsDirty {\n if((git status -s --ignore-submodules=dirty).length -ne 0) {\n return 1\n }\n\n return 0\n}\n\nfunction GetCurrentGitBranch {\n $ref=git symbolic-ref --quiet HEAD\n\tif($ref.length -ne 0) {\n\t\treturn $ref.Substring(11)\n }\n else {\n $ref=git rev-parse --short HEAD\n }\n return $ref\n}\n\nfunction GetCurrentGitBranchSha {\n return git rev-parse --short HEAD\n}\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix test results file name\n" }, { "from": "human", "value": "$env:PSModulePath = \"${PWD}\\packages;\" + $env:PSModulePath\n\n.\\paket\\paket.bootstrapper.exe\n.\\paket\\paket.exe restore\n\nImport-Module .\\PSForge.psm1\n\nInvoke-Pester -Path .\\PSForge.Tests.ps1 -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru\n" }, { "from": "gpt", "value": "$env:PSModulePath = \"${PWD}\\packages;\" + $env:PSModulePath\n\n.\\paket\\paket.bootstrapper.exe\n.\\paket\\paket.exe restore\n\nImport-Module .\\PSForge.psm1\n\nInvoke-Pester -Path .\\PSForge.Tests.ps1 -OutputFormat NUnitXml -OutputFile TestResults.xml -PassThru\n" } ]
powershell
chosen
[ { "from": "system", "value": "Include Git in base image" }, { "from": "human", "value": "$scriptName = 'buildAgent.ps1'\r\n\r\n# Common expression logging and error handling function, copied, not referenced to ensure atomic process\r\nfunction executeExpression ($expression) {\r\n\t$error.clear()\r\n\tWrite-Host \"[$scriptName] $expression\"\r\n\ttry {\r\n\t\tInvoke-Expression $expression\r\n\t if(!$?) { Write-Host \"[$scriptName] `$? = $?\"; exit 1 }\r\n\t} catch { echo $_.Exception|format-list -force; exit 2 }\r\n if ( $error[0] ) { Write-Host \"[$scriptName] `$error[0] = $error\"; exit 3 }\r\n if (( $LASTEXITCODE ) -and ( $LASTEXITCODE -ne 0 )) { Write-Host \"[$scriptName] `$LASTEXITCODE = $LASTEXITCODE \"; exit $LASTEXITCODE }\r\n}\r\n\r\n# Use the CDAF provisioning helpers\r\nWrite-Host \"`n[$scriptName] ---------- start ----------`n\"\r\n\r\nif ( Test-Path \"c:\\vagrant\" ) {\r\n\texecuteExpression 'cd c:\\vagrant'\r\n}\r\n\r\nWrite-Host \"[$scriptName] Install Chocolately, Python and Python Package Manager (PiP)`n\"\r\nexecuteExpression \"./automation/provisioning/base.ps1 python3\"\r\n\r\nWrite-Host \"[$scriptName] Use Python Package Manager (PiP) to install dependancies:`n\"\r\ncat requirements.txt\r\n\r\nWrite-Host\r\nexecuteExpression 'pip install -r requirements.txt' \r\n\r\nWrite-Host \"`n[$scriptName] ---------- stop ----------`n\"\r\n" }, { "from": "gpt", "value": "$scriptName = 'buildAgent.ps1'\r\n\r\n# Common expression logging and error handling function, copied, not referenced to ensure atomic process\r\nfunction executeExpression ($expression) {\r\n\t$error.clear()\r\n\tWrite-Host \"[$scriptName] $expression\"\r\n\ttry {\r\n\t\tInvoke-Expression $expression\r\n\t if(!$?) { Write-Host \"[$scriptName] `$? = $?\"; exit 1 }\r\n\t} catch { echo $_.Exception|format-list -force; exit 2 }\r\n if ( $error[0] ) { Write-Host \"[$scriptName] `$error[0] = $error\"; exit 3 }\r\n if (( $LASTEXITCODE ) -and ( $LASTEXITCODE -ne 0 )) { Write-Host \"[$scriptName] `$LASTEXITCODE = $LASTEXITCODE \"; exit $LASTEXITCODE }\r\n}\r\n\r\n# Use the CDAF provisioning helpers\r\nWrite-Host \"`n[$scriptName] ---------- start ----------`n\"\r\n\r\nif ( Test-Path \"c:\\vagrant\" ) {\r\n\texecuteExpression 'cd c:\\vagrant'\r\n}\r\n\r\nWrite-Host \"[$scriptName] Install Chocolately, Python and Python Package Manager (PiP)`n\"\r\nexecuteExpression \"./automation/provisioning/base.ps1 python3 git\"\r\n\r\nWrite-Host \"[$scriptName] Use Python Package Manager (PiP) to install dependancies:`n\"\r\ncat requirements.txt\r\n\r\nWrite-Host\r\nexecuteExpression 'pip install -r requirements.txt' \r\n\r\nWrite-Host \"`n[$scriptName] ---------- stop ----------`n\"\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Comment out my profile, for now.\n" }, { "from": "human", "value": "\n# Add the git SSH agent to the PATH to avoid \"could not find ssh-agent\"\n$env:path += \";\" + (Get-Item \"Env:ProgramFiles(x86)\").Value + \"\\Git\\bin\"\n\n# Load posh-git example profile\n. 'C:\\tools\\poshgit\\dahlbyk-posh-git-95df787\\profile.example.ps1'\n\n# Load my posh-git profile using the dot-source notation\n# . 'C:\\Users\\BigFont\\Documents\\WindowsPowerShell\\My.PoshGitProfile.ps1'\n\n# Customize the prompt\nfunction prompt\n{\n Write-Host (\"Shaun>\") -nonewline -foregroundcolor White\n return \" \"\n}\n\n# Helper functions\n\nfunction firefox \n{\n Start-Process firefox.exe\n}\n" }, { "from": "gpt", "value": "\n# Add the git SSH agent to the PATH to avoid \"could not find ssh-agent\"\n$env:path += \";\" + (Get-Item \"Env:ProgramFiles(x86)\").Value + \"\\Git\\bin\"\n\n# Load posh-git example profile\n. 'C:\\tools\\poshgit\\dahlbyk-posh-git-95df787\\profile.example.ps1'\n\n# Load my posh-git profile using the dot-source notation\n# . 'C:\\Users\\BigFont\\Documents\\WindowsPowerShell\\My.PoshGitProfile.ps1'\n\n# Customize the prompt\n# function prompt\n# {\n# Write-Host (\"Shaun>\") -nonewline -foregroundcolor White\n# return \" \"\n# }\n\n# Helper functions\n\nfunction firefox \n{\n Start-Process firefox.exe\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add the exit code to the remote result\n" }, { "from": "human", "value": "param(\n [string] $server = $env:TEST_SERVER,\n [string] $userName = $env:TEST_SERVER_USER,\n [string] $password = $env:TEST_SERVER_PASS,\n [string] $serverFolder = \"dev\"\n)\n$ErrorActionPreference = \"Stop\"\n\n$projectFile = \"MusicStore.Test\\project.json\"\n\nWrite-Host \"Test server: $server\"\nWrite-Host \"Test folder: $serverFolder\"\n\n$projectName = (get-item $projectFile).Directory.Name\nWrite-Host \"Test project: $projectName\"\n\nInvoke-Expression \"..\\tools\\BundleAndDeploy.ps1 -projectFile $projectFile -server $server -serverFolder $serverFolder -userName $userName -password $password\"\n\n$pass = ConvertTo-SecureString $password -AsPlainText -Force\n$cred = New-Object System.Management.Automation.PSCredential ($userName, $pass);\n\nSet-Item WSMan:\\localhost\\Client\\TrustedHosts \"$server\" -Force\n\n#This block of code will be executed remotely\n$remoteScript = {\n $ErrorActionPreference = \"Continue\"\n cd C:\\$using:serverFolder\\$using:projectName\n dir \n $env:DNX_TRACE=1\n $testResult = & .\\test.cmd 2>&1\n $testResult\n}\n\nWrite-Host \">>>> Remote code execution started <<<<\"\n$result = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript\n$result\nWrite-Host \"<<<< Remote execution code completed >>>>\"\n\n$testExitCode = $result[$result.length-1];\nexit $testExitCode\n" }, { "from": "gpt", "value": "param(\n [string] $server = $env:TEST_SERVER,\n [string] $userName = $env:TEST_SERVER_USER,\n [string] $password = $env:TEST_SERVER_PASS,\n [string] $serverFolder = \"dev\"\n)\n$ErrorActionPreference = \"Stop\"\n\n$projectFile = \"MusicStore.Test\\project.json\"\n\nWrite-Host \"Test server: $server\"\nWrite-Host \"Test folder: $serverFolder\"\n\n$projectName = (get-item $projectFile).Directory.Name\nWrite-Host \"Test project: $projectName\"\n\nInvoke-Expression \"..\\tools\\BundleAndDeploy.ps1 -projectFile $projectFile -server $server -serverFolder $serverFolder -userName $userName -password $password\"\n\n$pass = ConvertTo-SecureString $password -AsPlainText -Force\n$cred = New-Object System.Management.Automation.PSCredential ($userName, $pass);\n\nSet-Item WSMan:\\localhost\\Client\\TrustedHosts \"$server\" -Force\n\n#This block of code will be executed remotely\n$remoteScript = {\n $ErrorActionPreference = \"Continue\"\n cd C:\\$using:serverFolder\\$using:projectName\n dir \n $env:DNX_TRACE=1\n $testResult = & .\\test.cmd 2>&1\n $testResult = & $lastexitcode\n}\n\nWrite-Host \">>>> Remote code execution started <<<<\"\n$result = Invoke-Command -ComputerName $server -Credential $cred -ScriptBlock $remoteScript\n$result\nWrite-Host \"<<<< Remote execution code completed >>>>\"\n\n$testExitCode = $result[$result.length-1];\nexit $testExitCode\n" } ]
powershell
chosen
[ { "from": "system", "value": "Extend the timeout for dailogflow tests.\n" }, { "from": "human", "value": "# Copyright(c) 2018 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 -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\nSet-TestTimeout 900\n\ndotnet restore\ndotnet build\ndotnet test --test-adapter-path:. --logger:junit --no-build --no-restore -v n\n" }, { "from": "gpt", "value": "# Copyright(c) 2018 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 -DisableNameChecking ..\\..\\..\\BuildTools.psm1\n\nSet-TestTimeout 1200\n\ndotnet restore\ndotnet build\ndotnet test --test-adapter-path:. --logger:junit --no-build --no-restore -v n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix pester tests on Unix\n" }, { "from": "human", "value": "\n\nif([Environment]::OSVersion.Platform -eq \"Unix\"){\n $env:PSModulePath = \"${PWD}/packages:\" + $env:PSModulePath\n mono .nuget/nuget.exe install -ExcludeVersion\n}else{\n $env:PSModulePath = \"${PWD}\\packages;\" + $env:PSModulePath\n .nuget\\nuget.exe install -ExcludeVersion\n}\n\nRemove-Module Pester -ErrorAction SilentlyContinue\nRemove-Module PSForge -ErrorAction SilentlyContinue\nImport-Module .\\PSForge.psm1\nImport-Module .\\packages\\Pester\\Pester.psd1\n\nImport-LocalizedData -BaseDirectory \".\" -FileName \"PSForge.psd1\" -BindingVariable metadata\n\n$moduleVersion = $metadata.ModuleVersion\n$buildNumber = \"$moduleVersion-$(Get-Date -Format 'yyyyMMddHHmmss')\"\n\nWrite-Host \"##vso[task.setvariable variable=moduleversion]${moduleVersion}\"\nWrite-Host \"##vso[build.updatebuildnumber]${buildNumber}\"\n\n$result = Invoke-Pester -Path .\\PSForge.Tests.ps1 -OutputFormat NUnitXml -OutputFile TestResults.xml -PassThru # -CodeCoverage .\\PSForge.psm1 -CodeCoverageOutputFile coverage.xml \n\nExit $result.FailedCount" }, { "from": "gpt", "value": "\n\nif([Environment]::OSVersion.Platform -eq \"Unix\"){\n $env:PSModulePath = \"${PWD}/packages:\" + $env:PSModulePath\n mono .nuget/nuget.exe install -ExcludeVersion\n}else{\n $env:PSModulePath = \"${PWD}\\packages;\" + $env:PSModulePath\n .nuget\\nuget.exe install -ExcludeVersion\n}\n\n# Fix Pester on Unix\n$mockFile = \"./Packages/Pester/Functions/Mock.ps1\"\n(Get-Content $mockFile).replace('if ($PSVersionTable.PSVersion -ge ''5.0.10586.122'')', 'if (''5.0.10586.122'' -le $PSVersionTable.PSVersion)') | Set-Content $mockFile\n\nRemove-Module Pester -ErrorAction SilentlyContinue\nRemove-Module PSForge -ErrorAction SilentlyContinue\nImport-Module .\\PSForge.psm1\nImport-Module .\\packages\\Pester\\Pester.psd1\n\nImport-LocalizedData -BaseDirectory \".\" -FileName \"PSForge.psd1\" -BindingVariable metadata\n\n$moduleVersion = $metadata.ModuleVersion\n$buildNumber = \"$moduleVersion-$(Get-Date -Format 'yyyyMMddHHmmss')\"\n\nWrite-Host \"##vso[task.setvariable variable=moduleversion]${moduleVersion}\"\nWrite-Host \"##vso[build.updatebuildnumber]${buildNumber}\"\n\n$result = Invoke-Pester -Path .\\PSForge.Tests.ps1 -OutputFormat NUnitXml -OutputFile TestResults.xml -PassThru -CodeCoverage .\\PSForge.psm1 -CodeCoverageOutputFile coverage.xml \n\nExit $result.FailedCount" } ]
powershell
chosen
[ { "from": "system", "value": "Split long line to improve future parallel updates\n\nWhen each exported member is on a new line, multiple PR can be created\nsimultaneously that all add a new member in this file and still there\nwill be no merge conflict\n" }, { "from": "human", "value": "Resolve-Path $PSScriptRoot\\*.ps1 | \r\n % { . $_.ProviderPath }\r\n\r\nExport-ModuleMember Disable-UAC, Enable-UAC, Get-UAC, Disable-InternetExplorerESC, Get-ExplorerOptions, Set-TaskbarSmall, Install-WindowsUpdate, Move-LibraryDirectory, Enable-RemoteDesktop, Set-ExplorerOptions, Get-LibraryNames, Update-ExecutionPolicy, Enable-MicrosoftUpdate, Disable-MicrosoftUpdate, Set-StartScreenOptions, Set-CornerNavigationOptions, Set-WindowsExplorerOptions, Set-TaskbarOptions" }, { "from": "gpt", "value": "Resolve-Path $PSScriptRoot\\*.ps1 | \r\n % { . $_.ProviderPath }\r\n\r\nExport-ModuleMember `\r\n Disable-UAC, `\r\n Enable-UAC, `\r\n Get-UAC, `\r\n Disable-InternetExplorerESC, `\r\n Get-ExplorerOptions, `\r\n Set-TaskbarSmall, `\r\n Install-WindowsUpdate, `\r\n Move-LibraryDirectory, `\r\n Enable-RemoteDesktop, `\r\n Set-ExplorerOptions, `\r\n Get-LibraryNames, `\r\n Update-ExecutionPolicy, `\r\n Enable-MicrosoftUpdate, `\r\n Disable-MicrosoftUpdate, `\r\n Set-StartScreenOptions, `\r\n Set-CornerNavigationOptions, `\r\n Set-WindowsExplorerOptions, `\r\n Set-TaskbarOptions" } ]
powershell
chosen
[ { "from": "system", "value": "Fix multiarray import error on appveyor\n\nFix numpy multiarray import error for Python < 3.5 in appveyor builds.\nRefer to: https://github.com/matplotlib/matplotlib/issues/6115\n" }, { "from": "human", "value": "# Sample script to install Miniconda under Windows\n# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner, Robert McGibbon\n# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/\n#\nfunction UpdateConda ($python_home) {\n $conda_path = $python_home + \"\\Scripts\\conda.exe\"\n Write-Host \"Updating conda...\"\n $args = \"update --yes conda\"\n Write-Host $conda_path $args\n Start-Process -FilePath \"$conda_path\" -ArgumentList $args -Wait -Passthru\n}\n\nfunction InstallCondaPackages ($python_home, $spec) {\n $conda_path = $python_home + \"\\Scripts\\conda.exe\"\n $args = \"install --yes \" + $spec\n Write-Host (\"conda \" + $args)\n Start-Process -FilePath \"$conda_path\" -ArgumentList $args -Wait -Passthru\n}\n\nfunction main () {\n UpdateConda $env:PYTHON\n InstallCondaPackages $env:PYTHON \"numpy scipy sympy cython pywin32 nose coverage\"\n}\n\nmain\n" }, { "from": "gpt", "value": "# Sample script to install Miniconda under Windows\n# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner, Robert McGibbon\n# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/\n#\nfunction UpdateConda ($python_home) {\n $conda_path = $python_home + \"\\Scripts\\conda.exe\"\n Write-Host \"Updating conda...\"\n $args = \"update --yes conda\"\n Write-Host $conda_path $args\n Start-Process -FilePath \"$conda_path\" -ArgumentList $args -Wait -Passthru\n}\n\nfunction InstallCondaPackages ($python_home, $spec) {\n $conda_path = $python_home + \"\\Scripts\\conda.exe\"\n $args = \"install --yes \" + $spec\n Write-Host (\"conda \" + $args)\n Start-Process -FilePath \"$conda_path\" -ArgumentList $args -Wait -Passthru\n}\n\nfunction main () {\n UpdateConda $env:PYTHON\n InstallCondaPackages $env:PYTHON \"numpy scipy sympy cython pywin32 nose coverage msvc_runtime\"\n}\n\nmain\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use a .NET API call instead of a Win8+ cmdlet\n\nThe root cause is that Windows 7 doesn't have Get-NetIPAddress (\nsee:\nhttps://stackoverflow.com/questions/19529442/gather-ip-address-information\n)\nbut the change was to try and solve the bug that the VPN IP\naddresses\naren't visible detailed\nhere:\nhttps://support.microsoft.com/en-us/kb/2549091\n\nResolved using the\n2nd solution\nfrom\nhttp://serverfault.com/questions/145259/powershell-win32-networkadapterconfiguration-not-seeing-ppp-adapter\n" }, { "from": "human", "value": "$ErrorAction = \"Stop\"\r\n\r\n$net = Get-NetIPAddress | Where-Object {\r\n ($_.IPAddress -ne \"127.0.0.1\") -and ($_.IPAddress -ne \"::1\")\r\n} | Sort-Object $_.AddressFamily\r\n\r\n$result = @{\r\n\tip_addresses = $net.IPAddress\r\n}\r\n\r\nWrite-Output $(ConvertTo-Json $result)\r\n" }, { "from": "gpt", "value": "$ErrorAction = \"Stop\"\n\n# Find all of the NICsq\n$nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()\n\n# Save the IP addresses somewhere\n$nic_ip_addresses = @()\n\nforeach ($nic in $nics) {\n $nic_ip_addresses += $nic.GetIPProperties().UnicastAddresses | Where-Object {\n ($_.Address.IPAddressToString -ne \"127.0.0.1\") -and ($_.Address.IPAddressToString -ne \"::1\")\n } | Select -ExpandProperty Address\n}\n\n$nic_ip_addresses = $nic_ip_addresses | Sort-Object $_.AddressFamily\n\n$result = @{\n\tip_addresses = $nic_ip_addresses.IPAddressToString\n}\n\nWrite-Output $(ConvertTo-Json $result)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add conemu and msys2 via chocolatey\n" }, { "from": "human", "value": "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\n" }, { "from": "gpt", "value": "Set-ExecutionPolicy Unrestricted\niex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))\nchoco install conemu\nchoco install msys2\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add MSOnline settings with ignored user properties\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 MSOnline\n }\n} catch {\n Write-Verbose -Message (Get-DotFilesMessage -Message 'Skipping MSOnline settings as module not found.')\n return\n}\n\nWrite-Verbose -Message (Get-DotFilesMessage -Message 'Loading MSOnline settings ...')\n\n# Mailbox properties we usually don't care about\n[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignment', '')]\n$MsolUserIgnoredProperties = @(\n # User identity\n 'ImmutableId',\n 'LiveId',\n 'SignInName',\n #'UserPrincipalName',\n\n # Uninteresting\n 'PortalSettings',\n 'UserLandingPageIdentifierForO365Shell',\n 'UserThemeIdentifierForO365Shell',\n\n # GUIDs\n 'ObjectId',\n\n # Timestamps\n 'LastDirSyncTime',\n 'LastPasswordChangeTimestamp',\n 'SoftDeletionTimestamp',\n 'StrongAuthenticationProofupTime',\n 'StsRefreshTokensValidFrom',\n 'WhenCreated'\n)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update format and error handling\n" }, { "from": "human", "value": "function Set-RDPEnable\n{\n<#\n .SYNOPSIS\n The function Set-RDPEnable enable RDP remotely using the registry\n\n .DESCRIPTION\n The function Set-RDPEnable enable RDP remotely using the registry\n\n .PARAMETER ComputerName\n Specifies the ComputerName\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable -ComputerName \"DC01\"\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable -ComputerName \"DC01\",\"DC02\",\"DC03\"\n\n .NOTES\n Francois-Xavier Cat\n lazywinadmin.com\n @lazywinadmin\n#>\n\n [CmdletBinding()]\n PARAM (\n [String[]]$ComputerName = $env:COMPUTERNAME\n )\n PROCESS\n {\n FOREACH ($Computer in $ComputerName)\n {\n TRY\n {\n IF (Test-Connection -ComputerName $Computer -Count 1 -Quiet)\n {\n $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Computer)\n $regKey = $regKey.OpenSubKey(\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Terminal Server\", $True)\n $regkey.SetValue(\"fDenyTSConnections\", 0)\n $regKey.flush()\n $regKey.Close()\n } #IF Test-Connection\n } #Try\n CATCH\n {\n $Error[0].Exception.Message\n } #Catch\n } #FOREACH\n } #Process\n}" }, { "from": "gpt", "value": "function Set-RDPEnable {\n <#\n .SYNOPSIS\n The function Set-RDPEnable enable RDP remotely using the registry\n\n .DESCRIPTION\n The function Set-RDPEnable enable RDP remotely using the registry\n\n .PARAMETER ComputerName\n Specifies the ComputerName\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable -ComputerName \"DC01\"\n\n .EXAMPLE\n PS C:\\> Set-RDPEnable -ComputerName \"DC01\",\"DC02\",\"DC03\"\n\n .NOTES\n Francois-Xavier Cat\n lazywinadmin.com\n @lazywinadmin\n#>\n\n [CmdletBinding()]\n PARAM (\n [String[]]$ComputerName = $env:COMPUTERNAME\n )\n PROCESS {\n FOREACH ($Computer in $ComputerName) {\n TRY {\n IF (Test-Connection -ComputerName $Computer -Count 1 -Quiet) {\n $regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Computer)\n $regKey = $regKey.OpenSubKey(\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Terminal Server\", $True)\n $regkey.SetValue(\"fDenyTSConnections\", 0)\n $regKey.flush()\n $regKey.Close()\n } #IF Test-Connection\n } #Try\n CATCH {\n $PSCmdlet.ThrowTerminatingError($_)\n } #Catch\n } #FOREACH\n } #Process\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Add script to update subtree\n" }, { "from": "gpt", "value": "# git subtree add --prefix .github-actions https://github.com/actions/virtual-environments.git master --squash\n\ngit subtree pull --prefix .github-actions https://github.com/actions/virtual-environments.git master\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Check ESXi 6.7 support Script\n" }, { "from": "gpt", "value": "# Author: Florian Grehl - www.virten.net\n# Reference: -\n# Description: Check ESXi 6.7 support with JSON based HCL provided by www.virten.net \n# (http://www.virten.net/2016/05/vmware-hcl-in-json-format/)\n#\n# Requires Check-HCL function (https://github.com/fgrehl/virten-scripts/blob/master/powershell/Check-HCL.ps1)\n\n\n#$scope = Get-VMHost esx73.virten.lab \n#$scope = Get-Cluster Production | Get-VMHost\n$scope = Get-VMHost\n\n(New-Object System.Net.WebClient).DownloadFile(\"https://raw.githubusercontent.com/fgrehl/virten-scripts/master/powershell/Check-HCL.ps1\", \"$Env:temp\\Check-HCL.ps1\")\n. $Env:temp\\Check-HCL.ps1\n$check = Check-HCL $scope\nforeach ($esx in $check){\n Write-Host \"$($esx.VMHost) ($($esx.Model)): \" -NoNewline\n if($esx.SupportedReleases){\n if ($esx.SupportedReleases -match \"6.7\"){\n Write-Host \"ESXi 6.7 supported\" -ForegroundColor Green\n } else {\n Write-Host \"ESXi 6.7 unsupported\" -ForegroundColor Red\n }\n } else {\n Write-Host \"unknown\"\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Add fix for running in Terminal Services\n" }, { "from": "human", "value": "<# \n.summary\n Test suite for MSFT_xPackageResource.psm1\n#>\n[CmdletBinding()]\nparam()\n\nImport-Module $PSScriptRoot\\..\\DSCResources\\MSFT_xPackageResource\\MSFT_xPackageResource.psm1\n\n$ErrorActionPreference = 'stop'\nSet-StrictMode -Version latest\n\n\nfunction Suite.BeforeAll {\n # Remove any leftovers from previous test runs\n Suite.AfterAll \n\n}\n\nfunction Suite.AfterAll {\n Remove-Module MSFT_xPackageResource\n}\n\nfunction Suite.BeforeEach {\n}\n\ntry\n{\n InModuleScope MSFT_xPackageResource {\n Describe 'Get-RegistryValueIgnoreError' {\n\n It 'Should get values from HKLM' {\n $installValue = Get-RegistryValueIgnoreError 'LocalMachine' \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\" \"ProgramFilesDir\" Registry64\n $installValue | should be $env:programfiles\n }\n It 'Should get values from HKCU' {\n $installValue = Get-RegistryValueIgnoreError 'CurrentUser' \"Environment\" \"Temp\" Registry64\n $installValue | should be $env:temp\n }\n\n }\n }\n}\nfinally\n{\n Suite.AfterAll\n}\n\n" }, { "from": "gpt", "value": "<# \n.summary\n Test suite for MSFT_xPackageResource.psm1\n#>\n[CmdletBinding()]\nparam()\n\nImport-Module $PSScriptRoot\\..\\DSCResources\\MSFT_xPackageResource\\MSFT_xPackageResource.psm1\n\n$ErrorActionPreference = 'stop'\nSet-StrictMode -Version latest\n\n\nfunction Suite.BeforeAll {\n # Remove any leftovers from previous test runs\n Suite.AfterAll \n\n}\n\nfunction Suite.AfterAll {\n Remove-Module MSFT_xPackageResource\n}\n\nfunction Suite.BeforeEach {\n}\n\ntry\n{\n InModuleScope MSFT_xPackageResource {\n Describe 'Get-RegistryValueIgnoreError' {\n\n It 'Should get values from HKLM' {\n $installValue = Get-RegistryValueIgnoreError 'LocalMachine' \"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\" \"ProgramFilesDir\" Registry64\n $installValue | should be $env:programfiles\n }\n It 'Should get values from HKCU' {\n $installValue = Get-RegistryValueIgnoreError 'CurrentUser' \"Environment\" \"Temp\" Registry64\n $installValue.length -gt 3 | should be $true\n $envBeginning = $env:temp.substring(0,$installValue.length)\n $installValue | should be $envBeginning\n }\n\n }\n }\n}\nfinally\n{\n Suite.AfterAll\n}\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Rename Get-ProjectByName to Get-Projects and fix its semantics.\n\nGet-Projects will return zero or more projects under the following\ncontitions:\na) Returns zero or all solution projects selected by wildcard if the\n ProjectName parameter is specified (ProjectName passed through to\n NuGet Get-Project)\nb) Returns zero or all solution projects if the ProjectName parameter\n isn't specified (returns Get-Project -All)\n" }, { "from": "human", "value": "<#\nVS+MSBuild.psm1 - Visual Studio and MSBuild utilities.\n\nCopyright (c) 2013 Precision Mojo, LLC.\n\nThis file is part of the Unity3D.DLLs project (< URL >) which is distributed under the MIT License.\nRefer to the LICENSE.MIT.md document located in the project directory for licensing terms.\n\nSeveral functions are copied from scripts found in David Fowler's NuGetPowerTools package (https://github.com/davidfowl/NuGetPowerTools).\nNuGetPowerTools is licensed under the Apache License 2.0 (https://nuget.codeplex.com/license).\n#>\n\nfunction Get-ProjectFromName\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName\n\t)\n\n\tif ($ProjectName)\n\t{\n\t\t$projects = Get-Project $ProjectName\n\t}\n\telse\n\t{\n\t\t$projects = Get-Project\n\t}\n\n\t$projects\n}\n\nfunction Get-MSBuildProject\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName,\n\t\t[switch] $SpecifyUserProject\n\t)\n\n\tprocess\n\t{\n\t\t(Get-ProjectFromName $ProjectName) | % {\n\t\t\tif ($SpecifyUserProject)\n\t\t\t{\n\t\t\t\t$path = $_.FullName + \".user\"\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$path = $_.FullName\n\t\t\t}\n\n\t\t\t@([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($path))[0]\n\t\t}\n\t}\n}\n" }, { "from": "gpt", "value": "<#\nVS+MSBuild.psm1 - Visual Studio and MSBuild utilities.\n\nCopyright (c) 2013 Precision Mojo, LLC.\n\nThis file is part of the Unity3D.DLLs project (< URL >) which is distributed under the MIT License.\nRefer to the LICENSE.MIT.md document located in the project directory for licensing terms.\n\nSeveral functions are copied from scripts found in David Fowler's NuGetPowerTools package (https://github.com/davidfowl/NuGetPowerTools).\nNuGetPowerTools is licensed under the Apache License 2.0 (https://nuget.codeplex.com/license).\n#>\n\nfunction Get-Projects\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName\n\t)\n\n\tif ($ProjectName)\n\t{\n\t\t$projects = Get-Project $ProjectName\n\t}\n\telse\n\t{\n\t\t$projects = Get-Project -All\n\t}\n\n\t$projects\n}\n\nfunction Get-MSBuildProject\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName,\n\t\t[switch] $SpecifyUserProject\n\t)\n\n\tprocess\n\t{\n\t\t(Get-Projects $ProjectName) | % {\n\t\t\tif ($SpecifyUserProject)\n\t\t\t{\n\t\t\t\t$path = $_.FullName + \".user\"\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$path = $_.FullName\n\t\t\t}\n\n\t\t\t@([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($path))[0]\n\t\t}\n\t}\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Store bin folder from tagged build\n" }, { "from": "human", "value": "$nugetversion = $env:DOTNETR2RMLSTORE_NUGETVERSION\n\nfunction Update-NuspecVersion\n{\n Param ([string]$Version)\n \n foreach ($o in $input) \n {\n Write-output ('Updating nuspec file ' + $o.FullName)\n $TmpFile = $o.FullName + \".tmp\"\n\n get-content $o.FullName | \n %{$_ -replace '\\$version\\$', $Version } > $TmpFile\n\n move-item $TmpFile $o.FullName -force\n }\n}\n\nfunction Pack-Nuget\n{\n foreach ($o in $input) \n {\n Write-output ('Packing ' + $o.FullName)\n \n\tnuget pack $o.FullName -Symbols\n }\n}\n\nif($nugetversion)\n{\n\tAdd-AppveyorMessage -Message ('Nuget version ' + $nugetversion)\n\n\t$env:APPVEYOR_BUILD_FOLDER | get-childitem -recurse |? { $_.Name -like '*.nuspec' } | Update-NuspecVersion $nugetversion;\n\t$env:APPVEYOR_BUILD_FOLDER | get-childitem -recurse |? { $_.Name -like '*.nuspec' } | Pack-Nuget\n}\n\nGet-ChildItem .\\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }" }, { "from": "gpt", "value": "$nugetversion = $env:DOTNETR2RMLSTORE_NUGETVERSION\n\nfunction Update-NuspecVersion\n{\n Param ([string]$Version)\n \n foreach ($o in $input) \n {\n Write-output ('Updating nuspec file ' + $o.FullName)\n $TmpFile = $o.FullName + \".tmp\"\n\n get-content $o.FullName | \n %{$_ -replace '\\$version\\$', $Version } > $TmpFile\n\n move-item $TmpFile $o.FullName -force\n }\n}\n\nfunction Pack-Nuget\n{\n foreach ($o in $input) \n {\n Write-output ('Packing ' + $o.FullName)\n \n\tnuget pack $o.FullName -Symbols\n }\n}\n\nif($nugetversion)\n{\n\tAdd-AppveyorMessage -Message ('Nuget version ' + $nugetversion)\n\n\t$env:APPVEYOR_BUILD_FOLDER | get-childitem -recurse |? { $_.Name -like '*.nuspec' } | Update-NuspecVersion $nugetversion;\n\t$env:APPVEYOR_BUILD_FOLDER | get-childitem -recurse |? { $_.Name -like '*.nuspec' } | Pack-Nuget\n\t\n\tGet-ChildItem .\\*.nupkg | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }\n\t\n\tAdd-AppveyorMessage -Message 'Publish bin folder of the build where nuget was created'\t\n\tPush-AppveyorArtifact 'src\\Slp.r2rml4net.Storage\\Slp.r2rml4net.Storage\\bin' -FileName 'Slp.r2rml4net.Storage_bin'\n}\n\n" } ]
powershell
chosen
[ { "from": "system", "value": "Install Fira Code font with Chocolatey\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\nchoco install -y keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts\nchoco install -y notepadplusplus\nchoco install -y poshgit\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 keepass\nchoco install -y linqpad\nchoco install -y nodejs-lts\nchoco install -y notepadplusplus\nchoco install -y poshgit\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": "Update the plex install script to use chocolatey\n" }, { "from": "human", "value": "$url = \"http://ninite.com/plex/ninite.exe\"\n$file = \"plex.exe\"\n\n(New-Object net.webclient).DownloadFile($url, $file)\n\n(New-Object -com shell.application).shellExecute($file)" }, { "from": "gpt", "value": "choco install plexmediaserver\n\n## Filebot is probably optional, but great for handling renaming of tv episodes based on tvdb\n\nchoco install filebot" } ]
powershell
chosen
[ { "from": "system", "value": "Add svn status to powershell profile\n" }, { "from": "human", "value": "function prompt()\n{\n $host.ui.RawUI.WindowTitle = $pwd\n\n Write-Host \"\"\n Write-Host \"$pwd\" -ForegroundColor DarkBlue\n Write-Host \">\" -ForegroundColor DarkMagenta -NoNewline\n return \" \"\n}\n\n$dotfiles = \"$home\\dotfiles\"\n\n# Sourcing sub-dir files\n\nforeach($item in Get-ChildItem $dotfiles -Recurse -Filter \"aliases.ps1\")\n{\n . $item\n}\n\n# PSReadLine\n\n$PSReadLineOptions = @{\n EditMode = \"Vi\"\n}\nSet-PSReadlineOption @PSReadLineOptions\n\nfunction OnViModeChange\n{\n if ($args[0] -eq 'Command')\n {\n # Set the cursor to a blinking block.\n Write-Host -NoNewLine \"`e[1 q\"\n }\n else\n {\n # Set the cursor to a blinking line.\n Write-Host -NoNewLine \"`e[5 q\"\n }\n}\nSet-PSReadLineOption -ViModeIndicator Script -ViModeChangeHandler $Function:OnViModeChange" }, { "from": "gpt", "value": "function prompt()\n{\n $host.ui.RawUI.WindowTitle = $pwd\n\n $svn_branch = get_svn_branch\n\n Write-Host \"\"\n Write-Host \"$pwd\" -ForegroundColor DarkBlue -NoNewline\n Write-Host \" $svn_branch\" -ForegroundColor DarkGray\n Write-Host \"❯\" -ForegroundColor DarkMagenta -NoNewline\n return \" \"\n}\n\nfunction exists($command)\n{\n return Get-Command $command -errorAction SilentlyContinue\n}\n\nfunction get_svn_branch()\n{\n if(!(exists svn)){ return \"\" }\n\n $output = svn info --show-item relative-url\n if($null -eq $output) { return \"\" }\n \n $output_split = $output.split(\"/\")\n if($output_split.count -lt 2) { return \"\" }\n\n $location = $output_split[1] # [0] should always be ^\n\n if($location -eq \"trunk\")\n {\n return $location\n }\n elseif($location -eq \"branches\")\n {\n return $output_split[2]\n }\n elseif($location -eq \"tags\")\n {\n return $location + \"/\" + $output_split[2]\n }\n \n return \"\"\n}\n\nfunction get_svn_status() # leaving for posterity but svn st is too slow for actual prompt use\n{\n if(!(exists svn)){ return \"\" }\n \n $output = svn st -q\n if($null -eq $output) { return \"\" }\n\n return \"*\"\n}\n\n\n$dotfiles = \"$home\\dotfiles\"\n\nforeach($item in Get-ChildItem $dotfiles -Recurse -Filter \"aliases.ps1\")\n{\n . $item\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Add Powershell script to build content layer images\n" }, { "from": "gpt", "value": "[CmdletBinding()]\nparam\n(\n\t[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True,HelpMessage=\"Name of the output image\")]\n\t[string] $OutputImage,\n\t[Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True,HelpMessage=\"Path to the SQL script\")]\n\t[string] $SqlFile,\n [Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True,HelpMessage=\"Path to the database directory\")]\n [string] $DatabaseDir\n)\n\nfunction PrintFatal($errorMsg)\n{\n Write-Host $errorMsg -ForegroundColor Red\n}\n\nfunction Build($config)\n{\n $initialLocation = $pwd.Path\n Try\n {\n $tempDirName = [System.Guid]::NewGuid().ToString()\n Set-Location $env:temp\n $tempDir = New-Item -Type Directory -Name $tempDirName\n \n Try\n {\n Set-Location $tempDir\n Copy-Item -Path $config.SqlFile -Destination ([System.IO.Path]::Combine($tempDir.FullName, 'script.sql'))\n \n $tempDatabaseDir = New-Item -ItemType Directory -Name 'DATA'\n ForEach ($extension in '*.mdf', '*.ldf')\n {\n Get-ChildItem -Path $config.DatabaseDir -Filter $extension | Copy-Item -Destination $tempDatabaseDir\n }\n\n $webClient = New-Object System.Net.WebClient\n $webClient.DownloadFile('https://raw.githubusercontent.com/turboapps/turbome/master/sqlserver/content-layer/build.me', \"$tempDir\\build.me\")\n\n & \"turbo.exe\" build --overwrite --name $config.OutputImage build.me script.sql DATA\n }\n Finally\n {\n Set-Location $env:temp\n Remove-Item -Recurse $tempDirName\n }\n }\n Finally\n {\n Set-Location $initialLocation\n }\n}\n\n$sqlFileExists = Test-Path $SqlFile\nif(-not $sqlFileExists)\n{\n PrintFatal \"Script file '$SqlFile' was not found\"\n Exit -1\n}\n\n$databaseDirExists = Test-Path $DatabaseDir\nif(-not $databaseDirExists)\n{\n PrintFatal \"Database directory '$DatabaseDir' was not found\"\n Exit -1\n}\n\n$config = New-Object -TypeName PsObject -Property (@{\n 'OutputImage' = $OutputImage;\n 'SqlFile' = (Get-Item $SqlFile | % { $_.FullName });\n 'DatabaseDir'= (Get-Item $DatabaseDir | % { $_.FullName });\n}) \n\nTry\n{\n Build $config\n}\nCatch\n{\n PrintFatal $_.Exception.Message\n PrintFatal $_.Exception.StackTrace\n Exit -1\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Rename duktape release folder on windows as the folder name changed\n" }, { "from": "human", "value": "\nInvoke-WebRequest \"https://github.com/svaarala/duktape-releases/archive/v1.4.0.zip\" -OutFile \".\\dependencies\\duktape-1.4.0.zip\"\n[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')\nif (Test-Path .\\dependencies\\duktape-1.4.0) {\n Remove-Item .\\dependencies\\duktape-1.4.0 -Force -Recurse\n}\n[System.IO.Compression.ZipFile]::ExtractToDirectory((Get-Location).ToString() + '\\dependencies\\duktape-1.4.0.zip', (Get-Location).ToString() + '\\dependencies')\nRemove-Item .\\dependencies\\duktape-1.4.0.zip -Force\n" }, { "from": "gpt", "value": "\nInvoke-WebRequest \"https://github.com/svaarala/duktape-releases/archive/v1.4.0.zip\" -OutFile \".\\dependencies\\duktape-1.4.0.zip\"\n[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem')\nif (Test-Path .\\dependencies\\duktape-1.4.0) {\n Remove-Item .\\dependencies\\duktape-1.4.0 -Force -Recurse\n}\n[System.IO.Compression.ZipFile]::ExtractToDirectory((Get-Location).ToString() + '\\dependencies\\duktape-1.4.0.zip', (Get-Location).ToString() + '\\dependencies')\nMove-Item .\\dependencies\\duktape-releases-1.4.0 .\\dependencies\\duktape-1.4.0\nRemove-Item .\\dependencies\\duktape-1.4.0.zip -Force\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update script to skip uploading on pull requests" }, { "from": "human", "value": "$artifactsSearchPattern = \"./*.vsix\"\n$artifactsCollection = (Get-ChildItem $artifactsSearchPattern -Recurse)\n\n$vsixMyGetUploadEndpoint = \"https://www.myget.org/F/nanoframework-dev/vsix/upload\"\n\n# for the environment variable MyGetToken to work here it has to be set in AppVeyor UI\n\nforeach($file in $artifactsCollection)\n{\n 'Uploading VSIX package to MyGet feed...' | Write-Host -ForegroundColor White -NoNewline\n\n $webClient = New-Object System.Net.WebClient\n $webClient.Headers.add('X-NuGet-ApiKey', $env:MyGetToken)\n $webClient.UploadFile($vsixMyGetUploadEndpoint, 'POST', $file)\n 'OK' | Write-Host -ForegroundColor Green\n}\n" }, { "from": "gpt", "value": "# skip pull requests\nif ($env:APPVEYOR_PULL_REQUEST_NUMBER)\n{\n return\n}\n\n$artifactsSearchPattern = \"./*.vsix\"\n$artifactsCollection = (Get-ChildItem $artifactsSearchPattern -Recurse)\n\n$vsixMyGetUploadEndpoint = \"https://www.myget.org/F/nanoframework-dev/vsix/upload\"\n\n# for the environment variable MyGetToken to work here it has to be set in AppVeyor UI\n\nforeach($file in $artifactsCollection)\n{\n 'Uploading VSIX package to MyGet feed...' | Write-Host -ForegroundColor White -NoNewline\n\n $webClient = New-Object System.Net.WebClient\n $webClient.Headers.add('X-NuGet-ApiKey', $env:MyGetToken)\n $webClient.UploadFile($vsixMyGetUploadEndpoint, 'POST', $file)\n 'OK' | Write-Host -ForegroundColor Green\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "[CI] Add a Powershell script for running tests on windows\n\nSummary:\nThis diff adds a Powershell script which takes the build artifacts from\na windows cross build as an input and run some basic tests on it.\n\nThis version is simple enough to run on any Windows 10 teamcity agent\nand requires no additional dependency nor VCS checkout. More tests can\nbe added later as needed. The avalanche test\n`processor_tests/poll_inflight_timeout` will hang forever and needs\nfurther investigation, it is disabled for now.\n\nTest Plan:\nI setup a Windows 10 VM, installed the teamcity agent software and ran\nthis script from the teamcity config. Example output:\nhttps://build.bitcoinabc.org/viewLog.html?buildId=65812&buildTypeId=BitcoinABC_Master_CrossBuilds_TestNativeWindows&tab=buildLog\n\nReviewers: #bitcoin_abc, jasonbcox, deadalnix\n\nReviewed By: #bitcoin_abc, jasonbcox, deadalnix\n\nSubscribers: deadalnix, jasonbcox\n\nDifferential Revision: https://reviews.bitcoinabc.org/D7559\n" }, { "from": "gpt", "value": "Set-PSDebug -Off\r\n$ErrorActionPreference='Stop'\r\n\r\nWrite-Host \"--- Extracting the artifacts ---\"\r\nmkdir -Force artifacts | out-null\r\ntar xzf artifacts.tar.gz -C artifacts\r\n\r\npushd artifacts/bin\r\n\r\nfunction check_help_version {\r\n try {\r\n .\\bitcoind.exe -version\r\n .\\bitcoind.exe -help\r\n .\\bitcoin-qt.exe -version\r\n .\\bitcoin-qt.exe -help\r\n .\\bitcoin-cli.exe -version\r\n .\\bitcoin-cli.exe -help\r\n .\\bitcoin-tx.exe -help\r\n .\\bitcoin-wallet -help\r\n }\r\n catch {\r\n Write-Error $_\r\n }\r\n finally {\r\n Stop-Process -name bitcoin-qt -Force -ErrorAction SilentlyContinue\r\n }\r\n}\r\n\r\nfunction check_bitcoind {\r\n trap {\r\n Stop-Process -name bitcoind -Force \r\n }\r\n\r\n Write-Host \"Launching bitcoind in the background\"\r\n Start-Process -NoNewWindow .\\bitcoind.exe \"-noprinttoconsole\"\r\n\r\n for($i=60; $i -gt 0; $i--) {\r\n Start-Sleep -Seconds 1\r\n if(.\\bitcoin-cli.exe help) {\r\n break\r\n }\r\n }\r\n if($i -eq 0) {\r\n throw \"Failed to start bitcoind\"\r\n }\r\n\r\n Write-Host \"Stopping bitcoind\"\r\n .\\bitcoin-cli.exe stop\r\n\r\n for($i=60; $i -gt 0; $i--) {\r\n Start-Sleep -Seconds 1\r\n if(-Not (Get-Process -Name bitcoind -ErrorAction SilentlyContinue)) {\r\n break\r\n }\r\n }\r\n if($i -eq 0) {\r\n throw \"Failed to stop bitcoind\"\r\n }\r\n}\r\n\r\nWrite-Host \"--- Checking helps and versions ---\"\r\ncheck_help_version\r\n\r\nWrite-Host \"--- Checking bitcoind can run and communicate via bitcoin-cli ---\"\r\ncheck_bitcoind\r\n\r\nWrite-Host \"--- Running bitcoin unit tests ---\"\r\n.\\test_bitcoin.exe\r\nWrite-Host \"--- Running bitcoin-qt unit tests ---\"\r\n.\\test_bitcoin-qt.exe -platform windows\r\nWrite-Host \"--- Running pow unit tests ---\"\r\n.\\test-pow.exe\r\nWrite-Host \"--- Running avalanche unit tests ---\"\r\n# FIXME: figure out why the poll_inflight_timeout test fails and fix it\r\n.\\test-avalanche.exe -t !processor_tests/poll_inflight_timeout\r\n\r\npopd\r\n\r\nWrite-Host -ForegroundColor Green \"--- All checks passed ---\"\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add Azure Db tools (incl CosmosDB)" }, { "from": "human", "value": "###\n### Install Visual Studio Code via Chocolatey and my preferred extensions\n###\n\n$Extensions = @(\n 'ms-dotnettools.csharp',\n 'ms-vscode.powershell',\n 'ms-azuretools.vscode-docker',\n 'eamodio.gitlens',\n 'ms-mssql.mssql',\n 'esbenp.prettier-vscode'\n)\n\nchoco install vscode\n\nforeach($Extension in $Extensions)\n{\n Write-Output \"Installing VSCode Extension $Extension\"\n\n & \"C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd\" --install-extension $Extension\n}" }, { "from": "gpt", "value": "###\n### Install Visual Studio Code via Chocolatey and my preferred extensions\n###\n\n$Extensions = @(\n 'ms-dotnettools.csharp',\n 'ms-vscode.powershell',\n 'ms-azuretools.vscode-docker',\n 'eamodio.gitlens',\n 'ms-mssql.mssql',\n 'esbenp.prettier-vscode',\n 'ms-azuretools.vscode-cosmosdb'\n)\n\nchoco install vscode\n\nforeach($Extension in $Extensions)\n{\n Write-Output \"Installing VSCode Extension $Extension\"\n\n & \"C:\\Program Files\\Microsoft VS Code\\bin\\code.cmd\" --install-extension $Extension\n}\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add example for changing NCM Profile\n" }, { "from": "gpt", "value": "Import-Module SwisPowerShell\n\n# SolarWinds connection details\n$hostname = 'localhost'\n$username = 'admin'\n$password = ''\n\n$swis = Connect-Swis -Hostname $hostname -Username $username -Password $password\n\n$query = \"\n SELECT Uri\n FROM Cirrus.Nodes\n WHERE AgentIP = '192.0.2.0'\n\"\n$uri = Get-SwisData $swis $query\n\n$properties = @{\n ConnectionProfile = 1\n}\n\nSet-SwisObject $swis $uri $properties\n" } ]
powershell
chosen
[ { "from": "system", "value": "Load https_proxy if http_proxy has been set" }, { "from": "human", "value": "$scriptName = 'buildAgent.ps1'\n\n# Common expression logging and error handling function, copied, not referenced to ensure atomic process\nfunction executeExpression ($expression) {\n\t$error.clear()\n\tWrite-Host \"[$scriptName] $expression\"\n\ttry {\n\t\tInvoke-Expression $expression\n\t if(!$?) { Write-Host \"[$scriptName] `$? = $?\"; exit 1 }\n\t} catch { echo $_.Exception|format-list -force; exit 2 }\n if ( $error[0] ) { Write-Host \"[$scriptName] `$error[0] = $error\"; exit 3 }\n if (( $LASTEXITCODE ) -and ( $LASTEXITCODE -ne 0 )) { Write-Host \"[$scriptName] `$LASTEXITCODE = $LASTEXITCODE \"; exit $LASTEXITCODE }\n}\n\n# Use the CDAF provisioning helpers\nWrite-Host \"`n[$scriptName] ---------- start ----------`n\"\n\nif ( Test-Path \"c:\\vagrant\" ) {\n\texecuteExpression 'cd c:\\vagrant'\n}\n\nWrite-Host \"[$scriptName] Install Chocolately, Python and Python Package Manager (PiP)`n\"\nexecuteExpression \"./automation/provisioning/base.ps1 'python git'\"\n\nWrite-Host \"[$scriptName] Use Python Package Manager (PiP) to install dependancies:`n\"\ncat requirements.txt\n\nWrite-Host\nexecuteExpression 'pip install -r requirements.txt' \n\nWrite-Host \"`n[$scriptName] ---------- stop ----------`n\"\n" }, { "from": "gpt", "value": "$scriptName = 'buildAgent.ps1'\n\n# Common expression logging and error handling function, copied, not referenced to ensure atomic process\nfunction executeExpression ($expression) {\n\t$error.clear()\n\tWrite-Host \"[$scriptName] $expression\"\n\ttry {\n\t\tInvoke-Expression $expression\n\t if(!$?) { Write-Host \"[$scriptName] `$? = $?\"; exit 1 }\n\t} catch { echo $_.Exception|format-list -force; exit 2 }\n if ( $error[0] ) { Write-Host \"[$scriptName] `$error[0] = $error\"; exit 3 }\n if (( $LASTEXITCODE ) -and ( $LASTEXITCODE -ne 0 )) { Write-Host \"[$scriptName] `$LASTEXITCODE = $LASTEXITCODE \"; exit $LASTEXITCODE }\n}\n\n# Use the CDAF provisioning helpers\nWrite-Host \"`n[$scriptName] ---------- start ----------`n\"\nif ( $env:http_proxy ) {\n\tWrite-Host \"[$scriptName] Set HTTPS proxy for Python Package Manager (PiP)`n\"\n\texecuteExpression \"`$env:https_proxy = '$env:http_proxy'\"\n}\n\nif ( Test-Path \"c:\\vagrant\" ) {\n\texecuteExpression 'cd c:\\vagrant'\n}\n\nWrite-Host \"[$scriptName] Install Chocolately, Python and Python Package Manager (PiP)`n\"\nexecuteExpression \"./automation/provisioning/base.ps1 'python git'\"\n\nWrite-Host \"[$scriptName] Use Python Package Manager (PiP) to install dependancies:`n\"\ncat requirements.txt\n\nWrite-Host\nexecuteExpression 'pip install -r requirements.txt' \n\nWrite-Host \"`n[$scriptName] ---------- stop ----------`n\"\n" } ]
powershell
chosen
[ { "from": "human", "value": "Create ps script for common system logs.\n" }, { "from": "gpt", "value": "$scriptLocation = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)\n. \"$scriptLocation\\config.ps1\"\n\nsysteminfo >> \"$openstackLogs\\systeminfo.log\"\nwmic qfe list >> \"$openstackLogs\\windows_hotfixes.log\"\npip freeze >> \"$openstackLogs\\pip_freeze.log\"\nipconfig /all >> \"$openstackLogs\\ipconfig.log\"\n\npowershell -executionpolicy remotesigned get-netadapter ^| Select-object * >> \"$openstackLogs\\get_netadapter.log\"\npowershell -executionpolicy remotesigned get-vmswitch ^| Select-object * >> \"$openstackLogs\\get_vmswitch.log\"\npowershell -executionpolicy remotesigned get-WmiObject win32_logicaldisk ^| Select-object * >> \"$openstackLogs\\disk_free.log\"\npowershell -executionpolicy remotesigned get-netfirewallprofile ^| Select-Object * >> \"$openstackLogs\\firewall.log\"\npowershell -executionpolicy remotesigned get-process ^| Select-Object * >> \"$openstackLogs\\get_process.log\"\npowershell -executionpolicy remotesigned get-service ^| Select-Object * >> \"$openstackLogs\\get_service.log\"\n\nsc qc nova-compute >> \"$openstackLogs\\nova_compute_service.log\"\nsc qc neutron-hyperv-agent >> \"$openstackLogs\\neutron_hyperv_agent_service.log\"\n" } ]
powershell
chosen
[ { "from": "system", "value": "Make buildscript also copy pluginbase to VS folder\n" }, { "from": "human", "value": "cd 'Visual Studio Project Template C#'\n& 'C:\\Program Files\\7-Zip\\7z.exe' a -tzip NppPlugin.zip *\ncd ..\n& 'C:\\Program Files\\7-Zip\\7z.exe' a -tzip c:\\temp\\nppDemoAndProjectTemplate.zip *\nrm 'Visual Studio Project Template C#\\NppPlugin.zip'\n\n" }, { "from": "gpt", "value": "cd 'Visual Studio Project Template C#'\n& 'C:\\Program Files\\7-Zip\\7z.exe' a -tzip NppPlugin.zip *\n$path = [Environment]::GetFolderPath(\"MyDocuments\")+'\\Visual Studio 2015\\Templates\\ProjectTemplates\\Visual C#\\'\ncopy NppPlugin.zip $path\ncd ..\n& 'C:\\Program Files\\7-Zip\\7z.exe' a -tzip c:\\temp\\nppDemoAndProjectTemplate.zip *\nrm 'Visual Studio Project Template C#\\NppPlugin.zip'\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add a script to which build contains a changese/commit\n" }, { "from": "gpt", "value": "##-----------------------------------------------------------------------\n## <copyright file=\"Get-BuildContainingChangeset.ps1\">(c) Richard Fennell. </copyright>\n##-----------------------------------------------------------------------\n# From a changeset/commit numver find any builds that are associated\n\nparam (\n [parameter(Mandatory=$true,HelpMessage=\"URL of the Team Project Collection e.g. 'http://myserver:8080/tfs/defaultcollection'\")]\n [string] $serverName,\n\n [parameter(Mandatory=$true,HelpMessage=\"Team Project name e.g. 'My Team project'\")]\n [string] $teamproject,\n\n [parameter(Mandatory=$false,HelpMessage=\"Username for use with Password (should be blank if using Personal Access Toekn or default credentials)\")]\n $username,\n \n [parameter(Mandatory=$false,HelpMessage=\"Password or Personal Access Token (if blank default credentials are used)\")]\n $password, \n\n [parameter(Mandatory=$true,HelpMessage=\"Changeset/Commit number\")]\n [string]$id\n)\n\n\nfunction Get-WebClient\n{\nparam\n (\n [string]$username,\n [string]$password,\n [string]$ContentType = \"application/json\"\n )\n\n $wc = New-Object System.Net.WebClient\n $wc.Headers[\"Content-Type\"] = $ContentType\n\n if ([System.String]::IsNullOrEmpty($password))\n {\n $wc.UseDefaultCredentials = $true\n } else\n {\n $pair = \"${username}:${password}\"\n $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)\n $base64 = [System.Convert]::ToBase64String($bytes)\n $wc.Headers.Add(\"Authorization\",\"Basic $base64\");\n }\n $wc\n}\nfunction Get-BuildDefinitions\n{\n param (\n [string]$username, \n [string]$password, \n [string]$tfsUri)\n\n $wc = Get-WebClient -username $username -password $password\n $uri = \"$($tfsUri)/_apis/build/definitions?api-version=4.1\"\n $wc.DownloadString($uri) | ConvertFrom-Json\n}\n\nfunction Get-BuildByDefinition\n{\n param (\n [string]$username, \n [string]$password, \n [string]$tfsUri, \n [string]$id, \n [string]$token)\n\n $wc = Get-WebClient -username $username -password $password\n $uri = \"$($tfsUri)/_apis/build/builds?definitions=$id&deletedFilter=includeDeleted&continuationToken=$token&api-version=4.1\"\n $wc.DownloadString($uri) | ConvertFrom-Json\n}\n\n\n\n$builddefs = Get-BuildDefinitions -tfsUri $serverName/$teamproject -password $password -username $username\nwrite-verbose \"Found $($builddefs.Count) build definitions\"\nforeach ($def in $builddefs.value)\n{\n $builds = Get-BuildByDefinition -tfsUri $serverName/$teamproject -password $password -username $username -id $def.id\n write-verbose \"Found $($builds.count) builds using definition $($def.Name)\"\n foreach ($build in $builds.value)\n {\n if ($build.sourceVersion -contains $id)\n {\n write-host \"Changeset/Commit $id was found in the build '$($build.buildNumber)' with ID '$($build.id)'\"\n }\n }\n}\n\n\n\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add %UserProfile%\\bin to %PATH% environment variable\n\nThis is necessary for Windows Credential Manager\n" }, { "from": "gpt", "value": "# file : extend-PATH-environment-variable.ps1\n# author : bryjamus <bryjamus@gmail.com>\n# license : MIT\n\n# This script:\n# * Adds to %PTH% environment variable paths\n\nFunction AddTo-SystemPath {\r\n Param([array] $PathToAdd)\r\n $VerifiedPathsToAdd = $Null\r\n Foreach ($Path in $PathToAdd) {\r\n if ($env:Path -like \"*$Path*\") {\r\n Write-Host \"Currnet item in path is: $Path\"\r\n Write-Host \"$Path already exists in Path statement\"\r\n }\r\n else {\r\n $VerifiedPathsToAdd += \";$Path\"\r\n Write-Host \"`$VerifiedPathsToAdd updated to contain: $Path\"\r\n } \r\n\r\n if($VerifiedPathsToAdd -ne $null) {\r\n Write-Host \"`$VerifiedPathsToAdd contains: $verifiedPathsToAdd\"\r\n Write-Host \"Adding $Path to Path statement now...\"\r\n [Environment]::SetEnvironmentVariable(\"Path\",$env:Path + $VerifiedPathsToAdd,\"Process\")\r\n }\r\n }\r\n}\n\n$Path = Join-Path $ENV:UserProfile 'bin'\n\nAddTo-SystemPath(@($Path))" } ]
powershell
chosen
[ { "from": "system", "value": "tests: Allow filtering loader tests on Windows\n" }, { "from": "human", "value": "# Be sure to run \"Set-ExecutionPolicy RemoteSigned\" before running powershell scripts\n\n# Use TestExceptions to filter out tests with known problems, separated by a colon\n# i.e. run_all_tests.ps1 -TestExceptions VkLayerTest.RequiredParameter:VkLayerTest.UnrecognizedValue\n\n# To trigger Debug tests, specify the parameter with a hyphen\n# i.e run_all_tests.ps1 -Debug\n\nParam(\n [switch]$Debug,\n [string]$TestExceptions\n)\n\nif ($Debug) {\n $dPath = \"Debug\"\n} else {\n $dPath = \"Release\"\n}\n\nSet-Item -path env:Path -value ($env:Path + \";..\\loader\\$dPath\")\nSet-Item -path env:Path -value ($env:Path + \";gtest-1.7.0\\$dPath\")\n$env:VK_LAYER_PATH = \"..\\layers\\$dPath\"\n\n& $dPath\\vk_loader_validation_tests\nif ($lastexitcode -ne 0) {\n exit 1\n}\n\n& $dPath\\vk_layer_validation_tests --gtest_filter=-$TestExceptions\n\nexit $lastexitcode\n" }, { "from": "gpt", "value": "# Be sure to run \"Set-ExecutionPolicy RemoteSigned\" before running powershell scripts\n\n# Use TestExceptions to filter out tests with known problems, separated by a colon\n# i.e. run_all_tests.ps1 -TestExceptions VkLayerTest.RequiredParameter:VkLayerTest.UnrecognizedValue\n\n# To trigger Debug tests, specify the parameter with a hyphen\n# i.e run_all_tests.ps1 -Debug\n\nParam(\n [switch]$Debug,\n [string]$LoaderTestExceptions,\n [string]$TestExceptions\n)\n\nif ($Debug) {\n $dPath = \"Debug\"\n} else {\n $dPath = \"Release\"\n}\n\nSet-Item -path env:Path -value ($env:Path + \";..\\loader\\$dPath\")\nSet-Item -path env:Path -value ($env:Path + \";gtest-1.7.0\\$dPath\")\n$env:VK_LAYER_PATH = \"..\\layers\\$dPath\"\n\n& $dPath\\vk_loader_validation_tests --gtest_filter=-$LoaderTestExceptions\nif ($lastexitcode -ne 0) {\n exit 1\n}\n\n& $dPath\\vk_layer_validation_tests --gtest_filter=-$TestExceptions\n\nexit $lastexitcode\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add build script for pushing packages to NuGet.org\n" }, { "from": "gpt", "value": "[CmdletBinding()]\nParam([Parameter(Mandatory=$True)][Version]$versionNumber)\n\n# Move to the project root folder (parent from current script folder)\n\nfunction Get-ScriptDirectory\n{ \n $Invocation = (Get-Variable MyInvocation -Scope 1).Value \n Split-Path $Invocation.MyCommand.Path \n}\n\n$rootFolder = (Get-Item (Get-ScriptDirectory)).Parent.FullName\nSet-Location $rootFolder\n\n# Check NuGet is installed and updated\n\nIf (!(Test-Path .\\.nuget\\nuget.exe))\n{\n New-Item .\\.nuget -type directory -Force | Out-Null\n Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '.\\.nuget\\nuget.exe'\n}\n\n.\\.nuget\\NuGet.exe update -self\n\n# Push packages to NuGet.org\n\n.\\.nuget\\NuGet.exe push .\\artifacts\\Okra.Data.$versionNumber.nupkg" } ]
powershell
chosen
[ { "from": "system", "value": "Upgrade to use v7.0.3 VM by default\n" }, { "from": "human", "value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.2.1\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion" }, { "from": "gpt", "value": "\n# Powershell script to pull the VM files from GitHub into the current folder.\n# Edit the following to match the version of the VM that is compatible with this image\n\nparam \n(\n [string]$VMversion=\"v7.0.3\"\n)\n\nTry \n{\n\t$scriptDir = Split-Path $script:MyInvocation.MyCommand.Path;\n\tWrite-Host \"Fetching DolphinVM.zip\" $VMversion\n\t$source = \"https://github.com/dolphinsmalltalk/DolphinVM/releases/download/$VMversion/DolphinVM.zip\";\n\t$zipFile = $scriptDir+\"\\DolphinVM.zip\";\n\tInvoke-WebRequest $source -OutFile $zipFile;\n}\nCatch\n{\n\tWrite-Host \"Unable to fetch DolphinVM.zip\" $VMversion;\n\tBreak;\n}\n\n$shell = new-object -com shell.application;\n$zip = $shell.NameSpace($zipFile);\nforeach($item in $zip.items())\n{\n\tWrite-Host \"..unpack\" $item.Name\n\t$shell.Namespace($scriptDir).copyhere($item, 0x14);\n}\nWrite-Host \"Removing Zip\"\nRemove-Item $zipFile\nWrite-Host \"Done fetching DolphinVM.zip\" $VMversion" } ]
powershell
chosen
[ { "from": "human", "value": "Add ability to update an APIM Api from a release\n" }, { "from": "gpt", "value": "<#\n.SYNOPSIS\nUpdate an APIM API with a swagger definition\n\n.PARAMETER ResourceGroupName\nThe name of the resource group that contains the APIM instnace\n\n.PARAMETER InstanceName\nThe name of the APIM instnace\n\n.PARAMETER ApiName\nThe name of the API to update\n\n.PARAMETER SwaggerSpecificationName\nThe full path to the swagger defintion\n\nFor example:\nhttps://sit-manage-vacancy.apprenticeships.sfa.bis.gov.uk/swagger/docs/v1\n\n#>\n[CmdletBinding()]\nParam(\n [Parameter(Mandatory=$true)]\n [String]$ResourceGroupName,\n [Parameter(Mandatory=$true)]\n [String]$InstanceName,\n [Parameter(Mandatory=$true)]\n [String]$ApiName,\n [Parameter(Mandatory=$true)]\n [String]$SwaggerSpecificationUrl\n)\n\ntry {\n # --- Build context and retrieve apiid\n Write-Host \"Building APIM context for $ResourceGroupName\\$InstanceName\"\n $Context = New-AzureRmApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $InstanceName\n Write-Host \"Retrieving ApiId for API $ApiName\"\n $ApiId = (Get-AzureRmApiManagementApi -Context $Context -Name $ApiName).ApiId\n\n # --- Throw if ApiId is null\n if (!$ApiId) {\n throw \"Could not retrieve ApiId for API $ApiName\"\n }\n\n # --- Import swagger definition\n Write-Host \"Updating API $ApiId\\$InstanceName from definition $SwaggerSpecficiationUrl\"\n Import-AzureRmApiManagementApi -Context $Context -SpecificationFormat \"Swagger\" -SpecificationUrl $SwaggerSpecificationUrl -ApiId $ApiId -ErrorAction Stop -Verbose:$VerbosePreference\n} catch {\n throw $_\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Rename 'Dropbox' folder to 'My Dropbox'\n" }, { "from": "human", "value": "param(\n[string]$a\n)\n<# \n.\\go.ps1 \"Text Comment for Commit\"\n\n\tMake sure to have a \"My Dropbox\" link in the Documents Library\n#>\nif (!$a)\n{ \n\t$a = Read-Host 'comment: or (<cr> for generic comment)'\n}\nif (!$a)\n{\n\t$a = Get-Date\n\t$a = $a + \" page updated.\"\n}\ngit add -A\ngit commit -m $a\ngit push\necho \"Copying webpage to Dropbox\"\ncopy \"$env:USERPROFILE\\Documents\\github\\webpage\\index.html\" \"$env:USERPROFILE\\Documents\\My Dropbox\\ftp sync\\index.html\"" }, { "from": "gpt", "value": "param(\n[string]$a\n)\n<# \n.\\go.ps1 \"Text Comment for Commit\"\n\n\tMake sure to have Dropbox folder named as \"My Dropbox\"\n#>\nif (!$a)\n{ \n\t$a = Read-Host 'comment: or (<cr> for generic comment)'\n}\nif (!$a)\n{\n\t$a = Get-Date\n\t$a = $a + \" page updated.\"\n}\ngit add -A\ngit commit -m $a\ngit push\necho \"Copying webpage to Dropbox\"\ncopy \"$env:USERPROFILE\\Documents\\github\\webpage\\index.html\" \"$env:USERPROFILE\\Documents\\My Dropbox\\ftp sync\\index.html\"" } ]
powershell
chosen
[ { "from": "system", "value": "Add publishing API keys to Whiskey.\n" }, { "from": "human", "value": "[CmdletBinding(DefaultParameterSetName='Build')]\r\nparam(\r\n [Parameter(Mandatory=$true,ParameterSetName='Clean')]\r\n [Switch]\r\n # Runs the build in clean mode, which removes any files, tools, packages created by previous builds.\r\n $Clean,\r\n\r\n [Parameter(Mandatory=$true,ParameterSetName='Initialize')]\r\n [Switch]\r\n # Initializes the repository.\r\n $Initialize\r\n)\r\n\r\n\r\n#Requires -Version 4\r\nSet-StrictMode -Version Latest\r\n\r\n& (Join-Path -Path $PSScriptRoot -ChildPath '.whiskey\\Import-Whiskey.ps1' -Resolve)\r\n\r\n$configPath = Join-Path -Path $PSScriptRoot -ChildPath 'whiskey.yml' -Resolve\r\n\r\n$optionalArgs = @{ }\r\nif( $Clean )\r\n{\r\n $optionalArgs['Clean'] = $true\r\n}\r\n\r\nif( $Initialize )\r\n{\r\n $optionalArgs['Initialize'] = $true\r\n}\r\n\r\n$context = New-WhiskeyContext -Environment 'Dev' -ConfigurationPath $configPath\r\nInvoke-WhiskeyBuild -Context $context @optionalArgs\r\n" }, { "from": "gpt", "value": "[CmdletBinding(DefaultParameterSetName='Build')]\r\nparam(\r\n [Parameter(Mandatory=$true,ParameterSetName='Clean')]\r\n [Switch]\r\n # Runs the build in clean mode, which removes any files, tools, packages created by previous builds.\r\n $Clean,\r\n\r\n [Parameter(Mandatory=$true,ParameterSetName='Initialize')]\r\n [Switch]\r\n # Initializes the repository.\r\n $Initialize\r\n)\r\n\r\n\r\n#Requires -Version 4\r\nSet-StrictMode -Version Latest\r\n\r\n& (Join-Path -Path $PSScriptRoot -ChildPath '.whiskey\\Import-Whiskey.ps1' -Resolve)\r\n\r\n$configPath = Join-Path -Path $PSScriptRoot -ChildPath 'whiskey.yml' -Resolve\r\n\r\n$optionalArgs = @{ }\r\nif( $Clean )\r\n{\r\n $optionalArgs['Clean'] = $true\r\n}\r\n\r\nif( $Initialize )\r\n{\r\n $optionalArgs['Initialize'] = $true\r\n}\r\n\r\n$context = New-WhiskeyContext -Environment 'Dev' -ConfigurationPath $configPath\r\n\r\n$apiKeys = @{\r\n 'PowerShellGallery' = 'POWERSHELL_GALLERY_API_KEY'\r\n 'github.com' = 'GITHUB_ACCESS_TOKEN'\r\n}\r\n\r\n$apiKeys.Keys |\r\n Where-Object { Test-Path -Path ('env:{0}' -f $apiKeys[$_]) } |\r\n ForEach-Object {\r\n $apiKeyID = $_\r\n $envVarName = $apiKeys[$apiKeyID]\r\n Write-Verbose ('Adding API key \"{0}\" with value from environment variable \"{1}\".' -f $apiKeyID,$envVarName)\r\n Add-WhiskeyApiKey -Context $context -ID $apiKeyID -Value (Get-Item -Path ('env:{0}' -f $envVarName)).Value\r\n }\r\n\r\nInvoke-WhiskeyBuild -Context $context @optionalArgs\r\n" } ]
powershell
chosen
[ { "from": "system", "value": "Extend Get-MSBuildProject to return the .user project.\n\nAlso fix the Get-ProjectFromName and Get-MSBuildProject parameters to\nmatch the ProjectName property.\n" }, { "from": "human", "value": "<#\nVS+MSBuild.psm1 - Visual Studio and MSBuild utilities.\n\nCopyright (c) 2013 Precision Mojo, LLC.\n\nThis file is part of the Unity3D.DLLs project (< URL >) which is distributed under the MIT License.\nRefer to the LICENSE.MIT.md document located in the project directory for licensing terms.\n\nSeveral functions are copied from scripts found in David Fowler's NuGetPowerTools package (https://github.com/davidfowl/NuGetPowerTools).\nNuGetPowerTools is licensed under the Apache License 2.0 (https://nuget.codeplex.com/license).\n#>\n\nfunction Get-ProjectFromName\n{\n\tparam (\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]]$projectName\n\t)\n\n\tif ($projectName)\n\t{\n\t\t$projects = Get-Project $projectName\n\t}\n\telse\n\t{\n\t\t$projects = Get-Project\n\t}\n\n\t$projects\n}\n\nfunction Get-MSBuildProject\n{\n\tparam (\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]]$projectName\n\t)\n\n\tprocess\n\t{\n\t\t(Get-ProjectFromName $projectName) | % {\n\t\t\t$path = $_.FullName\n\t\t\t@([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($path))[0]\n\t\t}\n\t}\n}\n" }, { "from": "gpt", "value": "<#\nVS+MSBuild.psm1 - Visual Studio and MSBuild utilities.\n\nCopyright (c) 2013 Precision Mojo, LLC.\n\nThis file is part of the Unity3D.DLLs project (< URL >) which is distributed under the MIT License.\nRefer to the LICENSE.MIT.md document located in the project directory for licensing terms.\n\nSeveral functions are copied from scripts found in David Fowler's NuGetPowerTools package (https://github.com/davidfowl/NuGetPowerTools).\nNuGetPowerTools is licensed under the Apache License 2.0 (https://nuget.codeplex.com/license).\n#>\n\nfunction Get-ProjectFromName\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName\n\t)\n\n\tif ($ProjectName)\n\t{\n\t\t$projects = Get-Project $ProjectName\n\t}\n\telse\n\t{\n\t\t$projects = Get-Project\n\t}\n\n\t$projects\n}\n\nfunction Get-MSBuildProject\n{\n\tparam\n\t(\n\t\t[Parameter(ValueFromPipelineByPropertyName=$true)]\n\t\t[String[]] $ProjectName,\n\t\t[switch] $SpecifyUserProject\n\t)\n\n\tprocess\n\t{\n\t\t(Get-ProjectFromName $ProjectName) | % {\n\t\t\tif ($SpecifyUserProject)\n\t\t\t{\n\t\t\t\t$path = $_.FullName + \".user\"\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t$path = $_.FullName\n\t\t\t}\n\n\t\t\t@([Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($path))[0]\n\t\t}\n\t}\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix ExecutionPolicy tests to -Skip instead of return\n" }, { "from": "human", "value": "Describe \"ExecutionPolicy\" {\n # We check against Windows because Linux and OS X behavior is the same\n $isWindows = [System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform([System.Runtime.InteropServices.OSPlatform]::Windows)\n\n Context \"Check Get-ExecutionPolicy behavior\" {\n\tIt \"Should throw PlatformNotSupported when not on Windows\" {\n\t if (!$isWindows) {\n\t\t{ Get-ExecutionPolicy } | Should Throw \"Operation is not supported on this platform.\"\n\t }\n\t}\n\n\tIt \"Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows\" {\n\t if ($isWindows) {\n\t\t(Get-ExecutionPolicy).GetType() | Should Be Microsoft.Powershell.ExecutionPolicy\n\t }\n\t}\n }\n\n Context \"Check Set-ExecutionPolicy behavior\" {\n\tIt \"Should throw PlatformNotSupported when not on Windows\" {\n\t if (!$isWindows) {\n\t\t{ Set-ExecutionPolicy Unrestricted } | Should Throw \"Operation is not supported on this platform.\"\n\t }\n\t}\n\n\tIt \"Should succeed on Windows\" {\n\t if ($isWindows) {\n\t\t# We use the Process scope to avoid affecting the system\n\t\t# Unrestricted is assumed \"safe\", otherwise these tests would not be running\n\t\t{ Set-ExecutionPolicy -Force -Scope Process -ExecutionPolicy Unrestricted } | Should Not Throw\n\t }\n\t}\n }\n}\n" }, { "from": "gpt", "value": "Describe \"ExecutionPolicy\" {\n\n Context \"Check Get-ExecutionPolicy behavior\" {\n It \"Should throw PlatformNotSupported when not on Windows\" -Skip:$IsWindows {\n { Get-ExecutionPolicy } | Should Throw \"Operation is not supported on this platform.\"\n }\n\n It \"Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows\" -Skip:($IsLinux -Or $IsOSX) {\n (Get-ExecutionPolicy).GetType() | Should Be Microsoft.Powershell.ExecutionPolicy\n }\n }\n\n Context \"Check Set-ExecutionPolicy behavior\" {\n It \"Should throw PlatformNotSupported when not on Windows\" -Skip:$IsWindows {\n { Set-ExecutionPolicy Unrestricted } | Should Throw \"Operation is not supported on this platform.\"\n }\n\n It \"Should succeed on Windows\" -Skip:($IsLinux -Or $IsOSX) {\n # We use the Process scope to avoid affecting the system\n # Unrestricted is assumed \"safe\", otherwise these tests would not be running\n { Set-ExecutionPolicy -Force -Scope Process -ExecutionPolicy Unrestricted } | Should Not Throw\n\t}\n }\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update chocolatey package's zip URL\n" }, { "from": "human", "value": "Install-ChocolateyZipPackage 'bytemark-client' 'http://repo.bytemark.co.uk/bytemark-client/windows/bytemark-0.4.268.zip' \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\r\n" }, { "from": "gpt", "value": "Install-ChocolateyZipPackage 'bytemark-client' 'http://repo.bytemark.co.uk/bytemark-client/windows/bytemark-0.5.0.zip' \"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\"\r\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add PowerShell script to run program.\n" }, { "from": "gpt", "value": "$mainClass = \"com.how_hard_can_it_be.primes.App\"\n\n$classPathElements=$(cat classpath.txt | ss -NotMatch '^[ \t]*#|^[ \t]*$')\nwrite-debug \"classPathElements = $classPathElements\"\n$classPath=\"\"\nforeach ($elt in $classPathElements)\n{\n\t$elt = $elt.ToString().Replace( \"~\", $env:USERPROFILE)\n if ($(Test-Path $elt))\n\t{\n if ( \"$classPath\" -eq \"\" ) {}\n else\n\t\t{\n $classPath=\"$classPath;\"\n\t\t}\n $classPath=\"$classPath$elt\"\n\t}\n else\n\t{\n Write-Warning (\"File not readable: {0}\" -f $elt)\n }\n}\n\njava -cp $classPath $mainClass $Args\n" } ]
powershell
chosen
[ { "from": "system", "value": "Revert \"http - NuGet path test\"\n\nThis reverts commit bbe02093b3859ecaaa54e8e55f0387bb95d0795e.\n" }, { "from": "human", "value": "$root = (split-path -parent $PSScriptRoot)\n\nWrite-Host \"ROOT - \" + $root -ForegroundColor Magenta\n\n$version = [System.Reflection.Assembly]::LoadFile(\"$root\\Haarlemmertrekvaart\\bin\\Release\\Haarlemmertrekvaart.dll\").GetName().Version\n$versionStr = \"{0}.{1}.{2}\" -f ($version.Major, $version.Minor, $version.Build)\n\nWrite-Host \"Setting .nuspec version tag to $versionStr\" -ForegroundColor Magenta\n\n$content = (Get-Content $root\\NuGet\\Haarlemmertrekvaart.nuspec) \n$content = $content -replace '\\$version\\$',$versionStr\n\n$content | Out-File $root\\nuget\\Haarlemmertrekvaart.compiled.nuspec\n\nWrite-Host PS C:\\> pathtest $($root)\\NuGet\" -ForegroundColor Magenta" }, { "from": "gpt", "value": "$root = (split-path -parent $PSScriptRoot)\n\nWrite-Host \"ROOT - \" + $root -ForegroundColor Magenta\n\n$version = [System.Reflection.Assembly]::LoadFile(\"$root\\Haarlemmertrekvaart\\bin\\Release\\Haarlemmertrekvaart.dll\").GetName().Version\n$versionStr = \"{0}.{1}.{2}\" -f ($version.Major, $version.Minor, $version.Build)\n\nWrite-Host \"Setting .nuspec version tag to $versionStr\" -ForegroundColor Magenta\n\n$content = (Get-Content $root\\NuGet\\Haarlemmertrekvaart.nuspec) \n$content = $content -replace '\\$version\\$',$versionStr\n\n$content | Out-File $root\\nuget\\Haarlemmertrekvaart.compiled.nuspec\n\nWrite-Host PS C:\\> pathtest $($root)\\NuGet\" -ForegroundColor Magenta\n\n# $file= \"Haarlemmertrekvaart.compiled.nuspec\"\n# Invoke-Expression \"$($root)\\NuGet\\NuGet.exe pack $($file) -Version $($version)\"" } ]
powershell
chosen
[ { "from": "system", "value": "Fix npm installer command again\n" }, { "from": "human", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\n\n$npm = echo \"C:\\Program Files\\nodejs\\npm.cmd\"\nif (!(test-path \"$npm\")) {\n $npm = echo \"C:\\Program Files (x86)\\nodejs\\npm.cmd\";\n}\n\necho \"Using npm at $npm\"\n\necho \"Installing base npm modules\"\ncmd /C \"'$npm' i\"\n\nif (test-path bin/) {\n echo \"Removing bin\"\n remove-item -Recurse -Force bin/\n}\n\necho \"Copying sources\"\ncp -r src/ bin/src/\n\necho \"Copying package.json\"\ncp package.json bin/\n\necho \"Copying README\"\ncp README.md bin/\n\necho \"Copying web.config\"\ncp web.config bin/\n\necho \"Moving into bin/\"\ncd bin/\n\necho \"Installing production modules\"\ncmd /C \"'$npm' i --production\"\n\necho \"Moving out of bin/\"\ncd ..\n\nif (test-path $zipPath) {\n echo \"Deleting old zip\"\n rm $zipPath\n}\n\necho \"Creating new zip\"\nZipFiles $zipPath bin/\n" }, { "from": "gpt", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\n\n$npm = echo \"C:\\Program Files\\nodejs\\npm.cmd\"\nif (!(test-path \"$npm\")) {\n $npm = echo \"C:\\Program Files (x86)\\nodejs\\npm.cmd\";\n}\n\necho \"Using npm at $npm\"\n\necho \"Installing base npm modules\"\ncmd /C \"$npm\" i\n\nif (test-path bin/) {\n echo \"Removing bin\"\n remove-item -Recurse -Force bin/\n}\n\necho \"Copying sources\"\ncp -r src/ bin/src/\n\necho \"Copying package.json\"\ncp package.json bin/\n\necho \"Copying README\"\ncp README.md bin/\n\necho \"Copying web.config\"\ncp web.config bin/\n\necho \"Moving into bin/\"\ncd bin/\n\necho \"Installing production modules\"\ncmd /C \"$npm\" i --production\n\necho \"Moving out of bin/\"\ncd ..\n\nif (test-path $zipPath) {\n echo \"Deleting old zip\"\n rm $zipPath\n}\n\necho \"Creating new zip\"\nZipFiles $zipPath bin/\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add Windows path for cmake test bundle dependency\n\nSigned-off-by: Jaymala Sinha <a04666c8f252cd920997ac90b34d2eff29d09ccc@chef.io>\n" }, { "from": "human", "value": "echo \"--- system details\"\n$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'\nGet-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize\n\n# Install winrm\nwinrm quickconfig -q\n\n# Install cmake\nchoco install cmake\n$Env:path += \";C:\\Program Files\\CMake\\mingw64\\bin;C:\\Program Files\\CMake\\usr\\bin\"\n\necho $Env:path\n\nwhich cmake\n\nruby -v\nbundle --version\n\necho \"--- bundle install\"\nbundle install\n\necho \"+++ bundle exec rake\"\nbundle exec rake spec\n\nexit $LASTEXITCODE" }, { "from": "gpt", "value": "echo \"--- system details\"\n$Properties = 'Caption', 'CSName', 'Version', 'BuildType', 'OSArchitecture'\nGet-CimInstance Win32_OperatingSystem | Select-Object $Properties | Format-Table -AutoSize\n\n# Install winrm\nwinrm quickconfig -q\n\n# Install cmake\nchoco install cmake\n$Env:path += \";C:\\Program Files\\CMake\\bin\"\n\necho $Env:path\n\nwhich cmake\n\nruby -v\nbundle --version\n\necho \"--- bundle install\"\nbundle install\n\necho \"+++ bundle exec rake\"\nbundle exec rake spec\n\nexit $LASTEXITCODE" } ]
powershell
chosen
[ { "from": "human", "value": "Add tests for `scoop reset scoop` command\n" }, { "from": "gpt", "value": "set-alias scoop \"$psscriptroot/../bin/scoop.ps1\"\n\ndescribe \"'scoop reset scoop'\" {\n beforeall {\n remove-item \"~/.bashrc.scoop\" -ea ignore\n }\n\n function alias_count {\n (gc \"~/.bashrc\" | where { $_ -eq 'alias scoop=\"powershell scoop.ps1\"' } | measure).count\n }\n\n function backup_bashrc_if_exists {\n # back up .bashrc if it exists\n if(test-path \"~/.bashrc\") {\n move-item \"~/.bashrc\" \"~/.bashrc.scoop\"\n }\n }\n\n function restore_bashrc_if_exists {\n # restore backup\n if(test-path \"~/.bashrc.scoop\") {\n move-item \"~/.bashrc.scoop\" \"~/.bashrc\"\n\n \"~/.bashrc.scoop\" | should not exist\n \"~/.bashrc\" | should exist\n }\n }\n\n context \"no .bashrc\" {\n it \"creates .bashrc when it doesn't exist\" {\n backup_bashrc_if_exists\n\n \"~/.bashrc\" | should not exist\n scoop reset scoop\n \"~/.bashrc\" | should exist\n alias_count | should be 1\n\n # cleanup\n remove-item \"~/.bashrc\"\n\n restore_bashrc_if_exists\n }\n }\n\n context \"bash scoop alias exists\" {\n it \"does not create another bash scoop alias\" {\n # call it once to create it if it doesn't exist\n scoop reset scoop\n alias_count | should be 1\n\n scoop reset scoop\n alias_count | should be 1\n }\n }\n\n context \"bash scoop alias doesn't exist\" {\n it \"creates bash scoop alias\" {\n backup_bashrc_if_exists\n new-item -type file \"~/.bashrc\"\n\n alias_count | should be 0\n\n scoop reset scoop\n alias_count | should be 1\n\n remove-item \"~/.bashrc\"\n restore_bashrc_if_exists\n }\n }\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Revert new line from commit dc834cc28f\n\nThis matches how cmd looks in conemu for cmder and PS seems to add some\npadding around command output so I really don't see what the extra new\nline is doing.\n\nSaving dat precious vertical space.\n" }, { "from": "human", "value": "# Global modules directory\n$global:PsGetDestinationModulePath = $PSScriptRoot + \"\\..\\vendor\\psmodules\"\n\n# Push to modules location\nPush-Location -Path ($PsGetDestinationModulePath)\n\n# Load modules from current directory\nImport-Module .\\PsGet\\PsGet\nGet-ChildItem -Exclude \"PsGet\" -Directory -Name | Foreach-Object {\n Import-Module .\\$_\\$_\n}\n\n# Come back to PWD\nPop-Location\n\n# Set up a Cmder prompt, adding the git prompt parts inside git repos\nfunction global:prompt {\n $realLASTEXITCODE = $LASTEXITCODE\n $Host.UI.RawUI.ForegroundColor = \"White\"\n Write-Host(\"`n\" + $pwd.ProviderPath) -NoNewLine -ForegroundColor Green\n if (Get-Module posh-git) {\n Write-VcsStatus\n }\n $global:LASTEXITCODE = $realLASTEXITCODE\n Write-Host \"`nλ\" -NoNewLine -ForegroundColor \"DarkGray\"\n return \" \"\n}\n\n# Load special features come from posh-git\nif (Get-Module posh-git) {\n Enable-GitColors\n Start-SshAgent -Quiet\n}\n\n# Move to the wanted location\nif (Test-Path Env:\\CMDER_START) {\n Set-Location -Path $Env:CMDER_START\n} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {\n Set-Location -Path $Env:USERPROFILE\n}\n" }, { "from": "gpt", "value": "# Global modules directory\n$global:PsGetDestinationModulePath = $PSScriptRoot + \"\\..\\vendor\\psmodules\"\n\n# Push to modules location\nPush-Location -Path ($PsGetDestinationModulePath)\n\n# Load modules from current directory\nImport-Module .\\PsGet\\PsGet\nGet-ChildItem -Exclude \"PsGet\" -Directory -Name | Foreach-Object {\n Import-Module .\\$_\\$_\n}\n\n# Come back to PWD\nPop-Location\n\n# Set up a Cmder prompt, adding the git prompt parts inside git repos\nfunction global:prompt {\n $realLASTEXITCODE = $LASTEXITCODE\n $Host.UI.RawUI.ForegroundColor = \"White\"\n Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green\n if (Get-Module posh-git) {\n Write-VcsStatus\n }\n $global:LASTEXITCODE = $realLASTEXITCODE\n Write-Host \"`nλ\" -NoNewLine -ForegroundColor \"DarkGray\"\n return \" \"\n}\n\n# Load special features come from posh-git\nif (Get-Module posh-git) {\n Enable-GitColors\n Start-SshAgent -Quiet\n}\n\n# Move to the wanted location\nif (Test-Path Env:\\CMDER_START) {\n Set-Location -Path $Env:CMDER_START\n} elseif ($Env:CMDER_ROOT -and $Env:CMDER_ROOT.StartsWith($pwd)) {\n Set-Location -Path $Env:USERPROFILE\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Update build to include web.config and clean bin/ folder\n" }, { "from": "human", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\n\necho \"Installing base npm modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i'\n\necho \"Copying sources\"\ncp -r src/ bin/\n\necho \"Copying package.json\"\ncp package.json bin/\n\necho \"Copying README\"\ncp README.md bin/\n\necho \"Moving into bin/\"\ncd bin/\n\necho \"Installing production modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i --production'\n\necho \"Moving out of bin/\"\ncd ..\n\nif (test-path $zipPath) {\n echo \"Deleting old zip\"\n rm $zipPath\n}\n\necho \"Creating new zip\"\nZipFiles $zipPath bin/\n" }, { "from": "gpt", "value": "Param(\n [string]$zipPath\n)\n\nfunction ZipFiles( $zipfilename, $sourcedir )\n{\n Add-Type -Assembly System.IO.Compression.FileSystem\n $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal\n [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,\n $zipfilename, $compressionLevel, $false)\n}\n\necho \"Installing base npm modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i'\n\necho \"Removing bin\"\nremove-item -Recurse -Force bin/\n\necho \"Copying sources\"\ncp -r src/ bin/src/\n\necho \"Copying package.json\"\ncp package.json bin/\n\necho \"Copying README\"\ncp README.md bin/\n\necho \"Copying web.config\"\ncp web.config bin/\n\necho \"Moving into bin/\"\ncd bin/\n\necho \"Installing production modules\"\ncmd /C '\"C:\\Program Files\\nodejs\\npm.cmd\" i --production'\n\necho \"Moving out of bin/\"\ncd ..\n\nif (test-path $zipPath) {\n echo \"Deleting old zip\"\n rm $zipPath\n}\n\necho \"Creating new zip\"\nZipFiles $zipPath bin/\n" } ]
powershell
chosen
[ { "from": "system", "value": "Use gitversion environment variables for script\n" }, { "from": "human", "value": "function NugetPack([bool] $pre) \n{\n $Version = gitversion /output json /showvariable MajorMinorPatch\n if ($pre)\n {\n echo \"Creating pre-release package...\"\n $VersionSuffix = \"-ci$(gitversion /output json /showvariable BuildMetaData)\"\n } \n else \n {\n echo \"Creating stable package...\"\n }\n\n Get-ChildItem $PSScriptRoot -Filter *.nuspec | \n Foreach-Object {\n (Get-Content $_) | ForEach-Object { $_ -replace \"%%VERSION%%\", \"$($VERSION)$($VersionSuffix)\" } | Set-Content $_\n }\n \n nuget pack Azuria.Core.nuspec -version \"$($VERSION)$($VersionSuffix)\"\n nuget pack Azuria.Api.nuspec -version \"$($VERSION)$($VersionSuffix)\"\n}\n\nfunction MygetPush \n{\n if ($env:myget_key)\n {\n Get-ChildItem $PSScriptRoot -Filter *.nupkg | \n Foreach-Object {\n nuget push $_ $env:myget_key -Source https://www.myget.org/F/infinitesoul/api/v2/package\n }\n }\n}\n\nNugetPack $env:APPVEYOR_REPO_TAG\nif ($env:APPVEYOR_REPO_BRANCH -eq \"master\") { MygetPush }" }, { "from": "gpt", "value": "function NugetPack([bool] $pre) \n{\n $Version = $env:GitVersion_MajorMinorPatch\n if ($pre)\n {\n echo \"Creating pre-release package...\"\n $VersionSuffix = \"-ci$($env:GitVersion_BuildMetaData)\"\n } \n else \n {\n echo \"Creating stable package...\"\n }\n\n Get-ChildItem $PSScriptRoot -Filter *.nuspec | \n Foreach-Object {\n (Get-Content $_) | ForEach-Object { $_ -replace \"%%VERSION%%\", \"$($VERSION)$($VersionSuffix)\" } | Set-Content $_\n }\n \n nuget pack Azuria.Core.nuspec -version \"$($VERSION)$($VersionSuffix)\"\n nuget pack Azuria.Api.nuspec -version \"$($VERSION)$($VersionSuffix)\"\n}\n\nfunction MygetPush \n{\n if ($env:myget_key)\n {\n Get-ChildItem $PSScriptRoot -Filter *.nupkg | \n Foreach-Object {\n nuget push $_ $env:myget_key -Source https://www.myget.org/F/infinitesoul/api/v2/package\n }\n }\n}\n\nNugetPack ($env:APPVEYOR_REPO_TAG -eq \"true\")\nif ($env:APPVEYOR_REPO_BRANCH -eq \"master\") { MygetPush }" } ]
powershell
chosen
[ { "from": "system", "value": "Enhance the cr alias to allow specifying branches.\n" }, { "from": "human", "value": "$proj = (Get-Content .\\GitReview\\GitReview.csproj) -as [Xml]\n$url = $proj.Project.ProjectExtensions.VisualStudio.FlavorProperties.WebProjectProperties.IISUrl.TrimEnd('/') + '/new'\n\"Url: $url\"\n\ngit config --global alias.cr \"push $url @:refs/heads/source @{u}:refs/heads/destination\"\n" }, { "from": "gpt", "value": "$proj = (Get-Content .\\GitReview\\GitReview.csproj) -as [Xml]\n$url = $proj.Project.ProjectExtensions.VisualStudio.FlavorProperties.WebProjectProperties.IISUrl.TrimEnd('/') + '/new'\n\"Url: $url\"\n\n$command = \"git push $url \" + '${1:-HEAD}:refs/heads/source ${2:-$1@{u\\}}:refs/heads/destination'\n$quoted = \"'\" + ($command -replace '\\$', '\\$') + \"'\"\ngit config --global alias.cr \"`\"!sh -c '$command' --`\"\"\nWrite-Host -n \"Git alias.cr: \"\ngit config --get alias.cr\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add configuration to support SPFx (SharePoint Framework) development" }, { "from": "gpt", "value": "#Script Name: New-EasyDevWorkstation-SPFx.ps1\n#Purpose: Quick and clean way to setup a simple developer workstation for building SPFx (SharePoint Framework) webparts. Tested only for Windows 10\n#Author Nissan Dookeran\n#Date 23-08-2016\n#Version 0.01\n\n#set the execution policy to allow chocolatey to install and chocolatey scripts to install software\nSet-ExecutionPolicy RemoteSigned\n\n#install chocolatey\niwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex\nrefreshenv\n\n#Install the basics - Git, Chrome browser, updated Powershell (if running on older Windows like Win Server 2008R2)\n# Visual Studio Code (which is free), and latest SQL Server Management Studio (also free)\n# Utilities like Microsoft Azure Storage Explorer, Postman and Fiddler are handy to have\n# nodejs is essential for building SPFx webparts, as required components installed via npm (Node Package Manager)\nchoco install -y --allow-empty-checksums git GoogleChrome powershell visualstudiocode sql-server-management-studio postman fiddler4 microsoftazurestorageexplorer nodejs\n\nrefreshenv\n#note if these do not work, close and reopen PowerShell window as PATH hasn't updated to recognize node and npm commands\n\nnpm install -g yo gulp\nnpm install -g @microsoft/generator-sharepoint\n" } ]
powershell
chosen
[ { "from": "system", "value": "Move DotNet install after VS, probably taken care of\n" }, { "from": "human", "value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Development Tools - .NET\n\ncinst DotNet4.0\n\ncinst DotNet4.5\n\ncinst webpi\n\ncinst webpicommandline\n\n## cinst VisualStudio2013ExpressWeb\n\ncinst VisualStudio2013Professional -InstallArguments \"WebTools\"\n\n## IIS Configuration\n\ncwindowsfeatures IIS-WebServerRole\n\n## cwebpi IIS7\n## cwebpi IISManagementConsole\n## cwebpi ASPNET\n## cwebpi UrlRewrite2\n## cwebpi ASPNET_REGIIS_NET4\n\n## System Configuration\n\n## cinst openssh\n\n## cwindowsfeatures Microsoft-Hyper-V-All" }, { "from": "gpt", "value": "## Download Chocolatey Package Manager\nif(-not $env:ChocolateyInstall -or -not (Test-Path \"$env:ChocolateyInstall\"))\n{\n\tiex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1')) \n}\n\n## Development Tools - .NET\n\n## cinst VisualStudio2013ExpressWeb\n\ncinst VisualStudio2013Professional -InstallArguments \"WebTools\"\n\ncinst DotNet4.0\n\ncinst DotNet4.5\n\ncinst webpi\n\ncinst webpicommandline\n\n## IIS Configuration\n\ncwindowsfeatures IIS-WebServerRole\n\n## cwebpi IIS7\n## cwebpi IISManagementConsole\n## cwebpi ASPNET\n## cwebpi UrlRewrite2\n## cwebpi ASPNET_REGIIS_NET4\n\n## System Configuration\n\n## cinst openssh\n\n## cwindowsfeatures Microsoft-Hyper-V-All" } ]
powershell
chosen
[ { "from": "human", "value": "Add attempt at a PowerShell script (not working)\n" }, { "from": "gpt", "value": "$vimInstallDir = \"~\\vimfiles\\bundle\\fsharpbinding-vim\"\n\n$local = Get-Location\n$vimBinDir = Join-Path $local \"ftplugin\\bin\"\n$ftpluginDir = Join-Path $local \"ftplugin\"\n$autoloadDir = Join-Path $local \"autoload\"\n$syntaxDir = Join-Path $local \"syntax\"\n$ftdetectDir = Join-Path $local \"ftdetect\"\n$syntaxCheckersDir = Join-Path $local \"syntax_checkers\"\n\n$acArchive = \"fsautocomplete.zip\"\n$acVersion = \"0.15.0\"\n\n# Building\n\nif ((Test-Path $vimBinDir) -eq 0)\n{\n md $vimBinDir\n}\n$url = \"https://github.com/fsharp/FSharp.AutoComplete/releases/downloads/\" + $acVersion + \"/\" + $acArchive\n$file = Join-Path $vimBinDir $acArchive\nWrite-Output $file\n$client = New-Object System.Net.WebClient\n# TODO: get this working\n#$client.DownloadFile($url, $file)\n$client.Dispose()\n\n# Installing\n\nrm -r $vimInstallDir\nmd $vimInstallDir\ncp -r (Join-Path $vimInstallDir \"ftplugin\") $ftpluginDir\ncp -r (Join-Path $vimInstallDir \"autoload\") $autoloadDir\ncp -r (Join-Path $vimInstallDir \"syntax\") $syntaxDir\ncp -r (Join-Path $vimInstallDir \"syntax_checkers\") $syntax_checkersDir\ncp -r (Join-Path $vimInstallDir \"ftdetect\") $ftdetectDir\n\n# TODO: test for errors and only print the following if no errors occurred.\nWrite-Output (\"Installed to \" + $vimInstallDir)\n\n" } ]
powershell
chosen
[ { "from": "human", "value": "Add tests for removal of aliases\n" }, { "from": "gpt", "value": "$removeAliasList = @(\"ac\",\"compare\",\"cpp\",\"diff\",\"sleep\",\"sort\",\"start\",\"cat\",\"cp\",\"ls\",\"man\",\"mount\",\"mv\",\"ps\",\"rm\",\"rmdir\")\n$keepAliasList = @{cd=\"Set-Location\"},@{dir=\"Get-ChildItem\"},@{echo=\"Write-output\"},@{fc=\"format-custom\"},@{kill=\"stop-process\"},@{clear=\"clear-host\"}\nDescribe \"Windows aliases do not conflict with Linux commands\" {\n foreach ($alias in $removeAliasList) {\n It \"Should not have certain aliases on Linux\" -Skip:$IsWindows {\n Test-Path Alias:$alias | Should Be $false\n }\n }\n\n foreach ($alias in $keepAliasList) {\n It \"Should have aliases that are Bash built-ins on Linux\" {\n (Get-Alias $alias.Keys).Definition | Should Be $alias.Values\n }\n }\n\n It \"Should have more as a function\" {\n Test-Path Function:more | Should Be $true\n }\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Change the default machine folder for virtualbox VMs\n" }, { "from": "human", "value": "$vbox = (Get-ItemProperty -Path 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment' `\n -Name \"VBOX_MSI_INSTALL_PATH\").VBOX_MSI_INSTALL_PATH + \"VBoxManage.exe\"\n\nif (-not (Test-Path $vbox)) {\n throw \"VBoxManage.exe not found!\"\n}\n\n$version = (& \"$vbox\" --version).Split('r')[0]\n\n$url = \"https://download.virtualbox.org/virtualbox/$version/\" `\n + \"Oracle_VM_VirtualBox_Extension_Pack-$version.vbox-extpack\"\n$file = \"$env:TEMP\\Oracle_VM_VirtualBox_Extension_Pack-$version.vbox-extpack\"\n\n(New-Object System.Net.WebClient).DownloadFile(\"$url\", $file)\n\n\"y\" | & $vbox extpack install --replace $file\n\nif ($LastExitCode -ne 0) {\n throw \"Extension pack installation failed with exit code '$LastExitCode'\"\n}\n" }, { "from": "gpt", "value": "$vbox = (Get-ItemProperty -Path 'HKLM:\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment' `\n -Name \"VBOX_MSI_INSTALL_PATH\").VBOX_MSI_INSTALL_PATH + \"VBoxManage.exe\"\n\nif (-not (Test-Path $vbox)) {\n throw \"VBoxManage.exe not found!\"\n}\n\n$version = (& \"$vbox\" --version).Split('r')[0]\n\n$url = \"https://download.virtualbox.org/virtualbox/$version/\" `\n + \"Oracle_VM_VirtualBox_Extension_Pack-$version.vbox-extpack\"\n$file = \"$env:TEMP\\Oracle_VM_VirtualBox_Extension_Pack-$version.vbox-extpack\"\n\n(New-Object System.Net.WebClient).DownloadFile(\"$url\", $file)\n\n\"y\" | & $vbox extpack install --replace $file\n\nif ($LastExitCode -ne 0) {\n throw \"Extension pack installation failed with exit code '$LastExitCode'\"\n}\n\nWrite-Output \"Changing default VM location...\"\n\nif (-not (Test-Path \"$env:SystemDrive\\Virtual Machines\\VirtualBox\")) {\n New-Item -Path \"$env:SystemDrive\\Virtual Machines\\VirtualBox\" -ItemType Directory | Out-Null\n}\n\nvboxmanage setproperty machinefolder \"$env:SystemDrive\\Virtual Machines\\VirtualBox\"\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix bug with windows built script\n" }, { "from": "human", "value": "$BUILD_DIR = \"./dist\"\n$BUNDLE_DIR = \"$BUILD_DIR/improviz-win\"\nmkdir -p $BUILD_DIR\n\ngit clone --depth=1 --branch=master https://github.com/rumblesan/improviz-performance.git $BUNDLE_DIR\nrm -rf $BUNDLE_DIR/.git\nrm -r $BUNDLE_DIR/README.md\n\ncp -r ./assets $BUNDLE_DIR\ncp -r ./examples $BUNDLE_DIR\n\n$DOCUMENTATION_DIR = \"$BUNDLE_DIR/documentation\"\nmkdir -p $DOCUMENTATION_DIR\ncp ./docs/getting-started.md $BUNDLE_DIR/getting-started.txt\ncp ./docs/language.md $DOCUMENTATION_DIR/language.txt\ncp ./docs/interacting.md $DOCUMENTATION_DIR/interacting.txt\ncp ./docs/reference.md $DOCUMENTATION_DIR/reference.txt\ncp ./docs/textures.md $DOCUMENTATION_DIR/textures.txt\ncp ./docs/configuration.md $DOCUMENTATION_DIR/configuration.txt\n./stack.exe install --local-bin-path $BUNDLE_DIR\n\n7z a \"improviz-win-${ENV:APPVEYOR_REPO_TAG_NAME}.zip\" $BUNDLE_DIR\n" }, { "from": "gpt", "value": "$BUILD_DIR = \"./dist\"\n$BUNDLE_DIR = \"$BUILD_DIR/improviz-win\"\nmkdir -p $BUILD_DIR\n\ngit clone --depth=1 --branch=master https://github.com/rumblesan/improviz-performance.git $BUNDLE_DIR\nrm -r -fo $BUNDLE_DIR/.git\nrm -r $BUNDLE_DIR/README.md\n\ncp -r ./assets $BUNDLE_DIR\ncp -r ./examples $BUNDLE_DIR\n\n$DOCUMENTATION_DIR = \"$BUNDLE_DIR/documentation\"\nmkdir -p $DOCUMENTATION_DIR\ncp ./docs/getting-started.md $BUNDLE_DIR/getting-started.txt\ncp ./docs/language.md $DOCUMENTATION_DIR/language.txt\ncp ./docs/interacting.md $DOCUMENTATION_DIR/interacting.txt\ncp ./docs/reference.md $DOCUMENTATION_DIR/reference.txt\ncp ./docs/textures.md $DOCUMENTATION_DIR/textures.txt\ncp ./docs/configuration.md $DOCUMENTATION_DIR/configuration.txt\n./stack.exe install --local-bin-path $BUNDLE_DIR\n\n7z a \"improviz-win-${ENV:APPVEYOR_REPO_TAG_NAME}.zip\" $BUNDLE_DIR\n" } ]
powershell
chosen
[ { "from": "system", "value": "Switch from long from double\n" }, { "from": "human", "value": "write-host \"Present working directory: $($pwd)\"\n\n$testsuites = [xml](get-content .\\test-results\\*.xml)\n$anyFailures = $FALSE\n\nforeach ($testsuite in $testsuites.testsuite) {\n\n write-host \" $($testsuite.name)\"\n\n foreach ($testcase in $testsuite.testcase){\n $failed = $testcase.failure\n $time = [long]$testsuite.time * 1000 # from seconds to milliseconds\n $testName = \"$($testcase.classname) $($testcase.name)\"\n\n if ($failed) {\n write-host \"Failed $($testcase.name) $($testcase.failure.message)\"\n Add-AppveyorTest $testName -Outcome Failed -FileName $testsuite.name -ErrorMessage $testcase.failure.message -Duration $time\n $anyFailures = $TRUE\n }\n else {\n write-host \"Passed $($testcase.name)\"\n Add-AppveyorTest $testName -Outcome Passed -FileName $testsuite.name -Duration $time\n }\n }\n}\n\nif ($anyFailures -eq $TRUE){\n write-host \"Failing build as there are broken tests\"\n $host.SetShouldExit(1)\n}\n" }, { "from": "gpt", "value": "write-host \"Present working directory: $($pwd)\"\n\n$testsuites = [xml](get-content .\\test-results\\*.xml)\n$anyFailures = $FALSE\n\nforeach ($testsuite in $testsuites.testsuite) {\n\n write-host \" $($testsuite.name)\"\n\n foreach ($testcase in $testsuite.testcase){\n $failed = $testcase.failure\n $time = [double]$testsuite.time * 1000 # from seconds to milliseconds\n $testName = \"$($testcase.classname) $($testcase.name)\"\n\n if ($failed) {\n write-host \"Failed $($testcase.name) $($testcase.failure.message)\"\n Add-AppveyorTest $testName -Outcome Failed -FileName $testsuite.name -ErrorMessage $testcase.failure.message -Duration $time\n $anyFailures = $TRUE\n }\n else {\n write-host \"Passed $($testcase.name)\"\n Add-AppveyorTest $testName -Outcome Passed -FileName $testsuite.name -Duration $time\n }\n }\n}\n\nif ($anyFailures -eq $TRUE){\n write-host \"Failing build as there are broken tests\"\n $host.SetShouldExit(1)\n}\n" } ]
powershell
chosen
[ { "from": "system", "value": "Add config files to deployment\n" }, { "from": "human", "value": "$binPath = \"..\\src\\RoslynPad\\bin\\Release\"\n$exclude =\n@(\n\t\"Xceed.Wpf.AvalonDock.Themes.Aero.dll\",\n\t\"Xceed.Wpf.AvalonDock.Themes.Metro.dll\",\n\t\"Xceed.Wpf.AvalonDock.Themes.VS2010.dll\",\n\t\"Xceed.Wpf.DataGrid.dll\"\n);\n$files = get-childitem \"$location\\$binPath\\*.dll\" | select -ExpandProperty Name | where { $exclude -notcontains $_ }\t\n$files +=\n@(\n\t\"RoslynPad.exe\",\n\t\"RoslynPad.Host32.exe\",\n\t\"RoslynPad.Host64.exe\",\n\t\"RoslynPad.exe.config\"\n)\n" }, { "from": "gpt", "value": "$binPath = \"..\\src\\RoslynPad\\bin\\Release\"\n$exclude =\n@(\n\t\"Xceed.Wpf.AvalonDock.Themes.Aero.dll\",\n\t\"Xceed.Wpf.AvalonDock.Themes.Metro.dll\",\n\t\"Xceed.Wpf.AvalonDock.Themes.VS2010.dll\",\n\t\"Xceed.Wpf.DataGrid.dll\"\n);\n$files = get-childitem \"$location\\$binPath\\*.dll\" | select -ExpandProperty Name | where { $exclude -notcontains $_ }\t\n$files +=\n@(\n\t\"RoslynPad.exe\",\n\t\"RoslynPad.Host32.exe\",\n\t\"RoslynPad.Host64.exe\",\n\t\"RoslynPad.exe.config\",\n\t\"RoslynPad.Host32.exe.config\",\n\t\"RoslynPad.Host64.exe.config\"\n)\n" } ]
powershell
chosen
[ { "from": "system", "value": "Fix one other test file with trailing whitespace\n" }, { "from": "human", "value": "function GoodFunc\n{\n param(\n [Parameter(Mandatory=$true)]\n [ValidateNotNullOrEmpty()] \n [string]\n $Param1,\n [Parameter(Mandatory=$false)]\n [ValidateNotNullOrEmpty()] \n [string]\n $Param2=$null\n )\n $Param1\n}\n\nfunction GoodFunc2($Param1 = $null)\n{\n $Param1\n}" }, { "from": "gpt", "value": "function GoodFunc\n{\n param(\n [Parameter(Mandatory=$true)]\n [ValidateNotNullOrEmpty()]\n [string]\n $Param1,\n [Parameter(Mandatory=$false)]\n [ValidateNotNullOrEmpty()]\n [string]\n $Param2=$null\n )\n $Param1\n}\n\nfunction GoodFunc2($Param1 = $null)\n{\n $Param1\n}" } ]
powershell
chosen
[ { "from": "system", "value": "Change to be able to upgrade pip\n" }, { "from": "human", "value": "$url = \"https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi\"\n$output = \"C:\\nitor\\VCForPython27.msi\"\n(New-Object System.Net.WebClient).DownloadFile($url, $output)\nStart-Process msiexec -ArgumentList @(\"/i\", \"C:\\nitor\\VCForPython27.msi\", \"/passive\", \"/quiet\") -NoNewWindow -Wait\n\npip install -U pip setuptools awscli boto3 nitor-deploy-tools\n" }, { "from": "gpt", "value": "$url = \"https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi\"\n$output = \"C:\\nitor\\VCForPython27.msi\"\n(New-Object System.Net.WebClient).DownloadFile($url, $output)\nStart-Process msiexec -ArgumentList @(\"/i\", \"C:\\nitor\\VCForPython27.msi\", \"/passive\", \"/quiet\") -NoNewWindow -Wait\n\nC:\\Python27\\python.exe -m pip install -U pip setuptools awscli boto3 nitor-deploy-tools\n" } ]
powershell
chosen
[ { "from": "human", "value": "Build script for CI server\n" }, { "from": "gpt", "value": "Framework \"4.0x86\"\n\nTask Build-Master {\n\tInvoke-Psake default.ps1 -properties @{autoVersion = $false; noAsync = $true}\n}\n\nTask Build-Develop {\n\tInvoke-Psake default.ps1 -properties @{noAsync = $true}\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Add capacity test for initialsessionstate\n" }, { "from": "gpt", "value": "Describe \"InitialSessionState capacity\" -Tags CI {\n BeforeAll {\n $iss = [initialsessionstate]::CreateDefault()\n\n for ($i = 0; $i -lt 5000; $i++)\n {\n $ssfe = [System.Management.Automation.Runspaces.SessionStateFunctionEntry]::new(\"f$i\", \"'fn f$i'\")\n $iss.Commands.Add($ssfe)\n\n $ssve = [System.Management.Automation.Runspaces.SessionStateVariableEntry]::new(\"v$i\", \"var v$i\", $null)\n $iss.Variables.Add($ssve)\n\n $ssae = [System.Management.Automation.Runspaces.SessionStateAliasEntry]::new(\"a$i\", \"f$i\")\n $iss.Commands.Add($ssae)\n }\n\n $ps = [PowerShell]::Create($iss)\n }\n\n AfterAll {\n $ps.Dispose()\n }\n\n BeforeEach {\n $ps.Commands.Clear()\n }\n\n It \"function capacity in initial session state should not be limited\" {\n $ps.AddCommand('f4999').Invoke() | Should Be \"fn f4999\"\n $ps.Streams.Error | Should Be $null\n }\n\n It \"alias capacity in initial session state should not be limited\" {\n $ps.AddCommand('a4999').Invoke() | Should Be \"fn f4999\"\n $ps.Streams.Error | Should Be $null\n }\n\n It \"variable capacity in initial session state should not be limited\" {\n $ps.AddScript('$v4999').Invoke() | Should Be \"var v4999\"\n $ps.Streams.Error | Should Be $null\n }\n\n It \"function capacity should not be limited after runspace is opened\" {\n $ps.AddScript('function f5000 { \"in f5000\" } f5000').Invoke() | Should Be \"in f5000\"\n $ps.Streams.Error | Should Be $null\n }\n\n It \"variable capacity should not be limited after runspace is opened\" {\n $ps.AddScript('$v5000 = \"var v5000\"; $v5000').Invoke() | Should Be \"var v5000\"\n $ps.Streams.Error | Should Be $null\n }\n\n It \"alias capacity should not be limited after runspace is opened\" {\n $ps.AddScript('New-Alias -Name a5000 -Value f1; a5000').Invoke() | Should Be \"fn f1\"\n $ps.Streams.Error | Should Be $null\n }\n}" } ]
powershell
chosen
[ { "from": "human", "value": "Add script to download and run Windows Console ColorTool\n" }, { "from": "gpt", "value": "# Configure the default color scheme for all Windows consoles\nWrite-Host -ForegroundColor DarkGreen \"Downloading Windows Console ColorTool...\"\n$colorurl = \"https://github.com/Microsoft/console/releases/download/1810.02002/ColorTool.zip\"\n$colorscheme = \"OneHalfDark\"\n[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\nInvoke-WebRequest $colorurl -OutFile \"ColorTool.zip\"\nExpand-Archive -Path \"ColorTool.zip\" -DestinationPath \"ColorTool\"\nWrite-Host -ForegroundColor DarkGreen \"Changing color scheme to $colorscheme\"\n.\\ColorTool\\ColorTool.exe --quiet --defaults $colorscheme\nRemove-Item -Path ColorTool.zip -Force\n\n# Enable downloads for older TLS versions: https://stackoverflow.com/a/48030563/2214380\n# [Net.ServicePointManager]::SecurityProtocol = \"tls12, tls11, tls\"\n" } ]
powershell
chosen