├── .gitignore ├── ReadMe.md ├── ReadMe.pdf ├── demo ├── Vagrantfile ├── packages │ └── ReadMe.md ├── resources │ ├── installers │ │ └── download.ps1 │ └── licenses │ │ └── ReadMe.md └── shell │ ├── InstallChocolatey.ps1 │ ├── NotifyGuiAppsOfEnvironmentChanges.ps1 │ └── PrepareWindows.ps1 ├── presentations ├── Chocolatey-KCDC2017.pdf └── ChocolateyWorkshop-WinOpsLondon2017.pdf ├── setup ├── ReadMe.md ├── setup.bat ├── setup.ps1 └── vagrant_2.0.txt └── solutions └── Exercise2 └── googlechrome ├── googlechrome.nuspec └── tools ├── _ReadMe.md └── chocolateyinstall.ps1 /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | dotNetFx40.exe 3 | .DS_Store 4 | *chocolatey.license.xml 5 | demo/resources/installers 6 | demo/resources/packages 7 | demo/resources/NetFx4 8 | demo/packages 9 | *.exe 10 | *.msi 11 | *.nupkg 12 | *.dmg 13 | vagrant*SHA256SUMS 14 | -------------------------------------------------------------------------------- /ReadMe.md: -------------------------------------------------------------------------------- 1 | # Workshop on Chocolatey 2 | 3 | 4 | 5 | - [Summary](#summary) 6 | - [Requirements](#requirements) 7 | - [Terminology](#terminology) 8 | - [Types of Packages](#types-of-packages) 9 | - [Exercises](#exercises) 10 | - [Notes](#notes) 11 | - [Exercise 0: Setup](#exercise-0-setup) 12 | - [Vagrant Setup](#vagrant-setup) 13 | - [In the VM / physical system for workshop completion](#in-the-vm--physical-system-for-workshop-completion) 14 | - [Exercise 1: Install Visual Studio Code](#exercise-1-install-visual-studio-code) 15 | - [Exercise 2: Create a package the old fashioned way](#exercise-2-create-a-package-the-old-fashioned-way) 16 | - [Exercise 3: Create a package with Package Builder CLI (C4B)](#exercise-3-create-a-package-with-package-builder-cli-c4b) 17 | - [Exercise 4: Create a package with Package Builder UI (C4B)](#exercise-4-create-a-package-with-package-builder-ui-c4b) 18 | - [Exercise 5: Create a package with Package Builder (Right Click) (C4B)](#exercise-5-create-a-package-with-package-builder-right-click-c4b) 19 | - [1Password](#1password) 20 | - [Charles Proxy](#charles-proxy) 21 | - [7-Zip EXE](#7-zip-exe) 22 | - [7-Zip MSI](#7-zip-msi) 23 | - [Exercise 6: Create all the packages (C4B)](#exercise-6-create-all-the-packages-c4b) 24 | - [Exercise 7: Set up a local Chocolatey.Server](#exercise-7-set-up-a-local-chocolateyserver) 25 | - [Exercise 8: Push a package to a Chocolatey Server](#exercise-8-push-a-package-to-a-chocolatey-server) 26 | - [Exercise 9: Upgrade a package](#exercise-9-upgrade-a-package) 27 | - [Exercise 10: Install package from Internal Repository](#exercise-10-install-package-from-internal-repository) 28 | - [Exercise 11: Reporting](#exercise-11-reporting) 29 | - [Exercise 12: Package Synchronizer - Automatic Sync (Licensed)](#exercise-12-package-synchronizer---automatic-sync-licensed) 30 | - [Exercise 13: Package Synchronizer - Choco Sync (C4B)](#exercise-13-package-synchronizer---choco-sync-c4b) 31 | - [Exercise 14: Manually Internalize Notepad++ package](#exercise-14-manually-internalize-notepad-package) 32 | - [Exercise 15: Internalize Visual Studio Code package (MSP/C4B)](#exercise-15-internalize-visual-studio-code-package-mspc4b) 33 | - [Exercise 16: Internalize AdobeReader package (MSP/C4B)](#exercise-16-internalize-adobereader-package-mspc4b) 34 | - [Exercise 17: Download Chocolatey and Licensed packages (Licensed)](#exercise-17-download-chocolatey-and-licensed-packages-licensed) 35 | - [Exercise 18: Create an extension package](#exercise-18-create-an-extension-package) 36 | - [Exercise 19: Create a package template for MSIs](#exercise-19-create-a-package-template-for-msis) 37 | - [Exercise 20: Create a package from a template](#exercise-20-create-a-package-from-a-template) 38 | - [Exercise 21: Update a packaging template / use custom properties](#exercise-21-update-a-packaging-template--use-custom-properties) 39 | - [Exercise 22: Use package parameters](#exercise-22-use-package-parameters) 40 | - [Exercise 23: Use AutoHotKey for craptastic installers](#exercise-23-use-autohotkey-for-craptastic-installers) 41 | 42 | 43 | 44 | ## Summary 45 | In this workshop, you will learn both simple and advanced scenarios for Chocolatey. You will see that Chocolatey can manage anything software-related when it comes to Windows. Here are some of the things you will learn in this workshop: 46 | 47 | * General Chocolatey use 48 | * General packaging 49 | * Customizing package behavior at runtime (package parameters) 50 | * Extension packages 51 | * Custom packaging templates 52 | * Setting up an internal Chocolatey.Server repository 53 | * Adding and using internal repositories 54 | * Reporting 55 | * Advanced packaging techniques when installers are not friendly to automation 56 | 57 | You can complete this workshop with either Chocolatey open source (FOSS) or with Chocolatey for Business (C4B). There are sections that specifically apply to C4B. You can skip those sections if they don't apply (or [set up a trial](https://chocolatey.org/contact) - contact sales to take a closer look). 58 | 59 | ## Requirements 60 | 61 | * A Windows or macOS machine. 62 | * At least 40GB of free space. 63 | * Recommend 8GB+ of RAM, or as much as possible. 64 | * IN PERSON WORKSHOP: Will need to be able to accept a USB key to transfer setup files. 65 | * NOT IN PERSON WORKSHOP: A decent internet connection as you will need to download a 4GB image. If you are completing this workshop in person with the Chocolatey team, it's likely you are completing an offline workshop. Otherwise you are going to need internet to download everything. 66 | 67 | ## Terminology 68 | 69 | * Package - in Chocolatey-speak, package is strictly a Nupkg file. Binaries and installers are referred to as software or binaries. This reduces confusion. 70 | * C4B - you see this next to some exercises. This is the short form of Chocolatey for Business. 71 | * MSP - Managed Service Provider. Also a licensed edition of Chocolatey that has less features and support than C4B, but has a price point that works well for MSP organizations. 72 | * See [Notes](#notes) 73 | 74 | ## Types of Packages 75 | 76 | * Installer Package - contains an installer (everything in template is geared towards this type of package) 77 | * Zip Package - downloads or embeds and unpacks archives, may unpack and run an installer using `Install-ChocolateyInstallPackage` as a secondary step. 78 | * Portable Package - Contains runtime binaries (or unpacks them as a zip package) - cannot require administrative permissions to install or use 79 | * Config Package - sets config like files, registry keys, etc 80 | * Extension Package - Packages that add PowerShell functions to Chocolatey - https://chocolatey.org/docs/how-to-create-extensions 81 | * Template Package - Packages that add templates like this for `choco new -t=name` - https://chocolatey.org/docs/how-to-create-custom-package-templates 82 | * Other - there are other types of packages as well, these are the main package types seen in the wild 83 | 84 | ## Exercises 85 | Some of these exercises require a license for the commercial version of Chocolatey. They can be completed with a trial version, but may require pressing enter a few times (and repeating the command if the trial decides not to let Package Builder finish). 86 | 87 | If you are completing this lab for FOSS (open source), simply skip those exercises/steps that are indicated by either `C4B`, `MSP`, or `Licensed`. 88 | 89 | ### Notes 90 | 91 | * OFFLINE - Offline workshop typically means you are attending the workshop in person somewhere and all materials will be provided so you don't need to download anything. 92 | * PHYSICAL - using a physical machine instead of the provided VM. 93 | 94 | ### Exercise 0: Setup 95 | 96 | It's preferred that you perform all of this exercise from a Vagrant image, but you can follow along with a physical Windows box. With Vagrant, you will need either VirtualBox, VMWare Fusion, or Hyper-V for the box provider. 97 | 98 | #### Vagrant Setup 99 | 1. Ensure you have a recent version of [Vagrant](https://downloads.vagrantup.com). It is suggested you have at least 1.8.x for linked clones which makes Windows VMs come up lightning quick. Windows machine - `choco install vagrant -y` (then `refreshenv`). OFFLINE: You should find this in the chocolatey-workshop/setup folder that was provided in the USB key. NOTE: Vagrant 2.2.2 has been found to have issues with Windows guests, so go back to 2.1.5 or up to a newer version. 100 | 1. Pre-download the vagrant box we will be using - `vagrant init ferventcoder/win2012r2-x64-nocm` (this is a 4GB box, about 8GB unpacked). OFFLINE: You should find this in the vagrant_boxes folder that was copied to your system. If you didn't get this set as part of the setup.ps1, you will need to run something like `vagrant box add --name ferventcoder/win2012r2-x64-nocm ./path/to/vagrant.box` 101 | 1. VirtualBox - If you are completing the workshop with VirtualBox, ensure you have VirtualBox 5.x (up to about 5.2.20 as of 10 DEC2018 - 5.2.22 may have compat issues) installed. Windows install is `choco install virtualbox -y`. OFFLINE: You should find this in the chocolatey-workshop/setup folder. NOTE: 102 | 1. VirtualBox / MacOS - After you install VirtualBox, open VirtualBox and then Preferences. Go to Input -> Virtual Machine and remap the Host Key to Right Command or Right Alt instead of the default. We need the default to be for the Windows key. 103 | 1. OFFLINE WORKSHOP: If we've had you copy files for offline use of this workshop, copy the packages folder into the `demo/packages` () folder. Also copy files from the `downloads` folder to `resources/installers`. 104 | 1. OFFLINE: Go to `shell/InstallChocolatey.ps1` and set `$installLocalFile = $true` on line 1. 105 | 1. C4B: Place the license you received (by email or fileshare) in `demo/resources/licenses`. Make sure it is named `chocolatey.license.xml`. OFFLINE: This should already be placed, but ensure that it is there. 106 | 1. C4B TRIAL: If you have a trial license, put the `chocolatey.extension` package into the packages folder. 107 | 1. In your command shell, make sure you are in the `demo` subfolder here. Run `vagrant up` (or `vagrant provision` if already running). 108 | 1. Check for errors. Once it finishes, run `vagrant reload` to get copy paste working. Something in Virtualbox/vagrant doesn't apparently set things up properly on first provision. 109 | 110 | **Troubleshooting:** If you run into a UUID issue, you may want to vagrant destroy, then find the `.vagrant` folder in the demo folder or a folder just above and remove that. 111 | 112 | #### In the VM / physical system for workshop completion 113 | 114 | All the rest of these commands will be done inside the Vagrant box (or box you are using for this workshop). 115 | 116 | 1. **NOTE:** If you have placed the license file, you will see a message that looks like an error not finding licensed code. We are going to do that at the end of this, so bare with the issues. 117 | 1. Run the following: `choco source add -n local -s c:\vagrant\packages --priority 1`. PHYSICAL: This is likely to be `choco source add -n local -s c:\\chocolatey-workshop\demo\packages --priority 1`. 118 | 1. OFFLINE: Run the following: `choco source disable -n chocolatey` 119 | 1. Licensed: Ensure that there is a file at `C:\ProgramData\Chocolatey\license` named `chocolatey.license.xml`. If not, you missed a step above, please manually set the file so you get a warning about being licensed without the licensed extension when you run `choco -v`. 120 | 1. Licensed: Install the licensed edition of Chocolatey: 121 | * Type `choco install chocolatey.extension -y` (ensure you added the nupkg for the packages folder if running a trial) 122 | * If you get curious, check out `choco source list`. 123 | 1. Run the following commands: 124 | ~~~sh 125 | choco config set cacheLocation 'c:\programdata\choco-cache' 126 | ~~~ 127 | 1. C4B: Run the following commands: 128 | ~~~sh 129 | choco config set virusScannerType VirusTotal 130 | choco feature enable -n virusCheck 131 | choco feature enable -n allowPreviewFeatures 132 | choco feature enable -n internalizeAppendUseOriginalLocation 133 | choco feature enable -n reduceInstalledPackageSpaceUsage 134 | ~~~ 135 | 1. Install .NET Framework 4.5.2 - `choco install dotnet4.5.2 -y` 136 | 1. (***HOST***) Run `vagrant reload` to reboot the machine. Okay, there are a few commands you might run from the host machine, typically those are vagrant commands. ***PHYSICAL***: Restart your machine 137 | 1. Install the latest GUI - `choco install chocolateygui --pre -y` - this may error with 1603 if you have not rebooted the machine after installing .NET Framework 4.5.2. 138 | 1. Install/Upgrade Launchy, Notepad++, Baretail, and Git - `choco upgrade launchy notepadplusplus baretail git -y`. 139 | 1. Add the PowerShell profile - type `Set-Content -Path $profile -Encoding UTF8 -Value ""` 140 | 1. Type `Write-Host $profile`. 141 | 1. Type `start $profile`. Add the following content, then save and close the file: 142 | ~~~powershell 143 | $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" 144 | if (Test-Path($ChocolateyProfile)) { 145 | Import-Module "$ChocolateyProfile" 146 | } 147 | ~~~ 148 | 1. Type `. $profile` to reload the PowerShell profile. 149 | 1. Create a folder for packages if it doesn't already exist at "c:\packages" - `New-Item 'c:\packages' -ItemType 'Directory' -Force` 150 | 1. Navigate to the packages folder. All commands from here will be in that packages folder. 151 | 152 | ### Exercise 1: Install Visual Studio Code 153 | 1. Call `choco install vscode -y` 154 | 1. Note the message "Environment Vars have changed". 155 | 1. Type `code`. Notice that it errors. 156 | 1. Type `refreshenv`. 157 | 1. Type `code`. Note that it opens Visual Studio Code. 158 | 159 | ### Exercise 2: Create a package the old fashioned way 160 | This is meant to be an exploratory exercise and intentionally doesn't doesn't provide much direction. Most other exercises contain all steps and are very reflective. 161 | 162 | 1. Download Google Chrome from https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi and https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise.msi. OFFLINE: These files should be in C:\vagrant\resources\installers. 163 | 1. From a command line, call `choco new googlechrome` 164 | 1. Go into the googlechrome folder and read the readme, look through the files that were created and try to create a package just using the 64 bit Google Chrome MSI. 165 | 1. Run `choco pack` 166 | 1. Install the package using Chocolatey - `choco install googlechrome -y -s .` 167 | 168 | Note that first time packaging like this kind of throws you into the thick of it to see if the information provided is enough to move forward. 169 | 170 | ### Exercise 3: Create a package with Package Builder CLI (C4B) 171 | 1. Let's create that GoogleChrome package again. 172 | 1. Run `choco new --file googlechromestandaloneenterprise.msi --file64 googlechromestandaloneenterprise64.msi --build-package --outputdirectory $pwd` 173 | 1. Inspect the output. 174 | 175 | ### Exercise 4: Create a package with Package Builder UI (C4B) 176 | Let's start by packaging up and installing Puppet 177 | 1. Run PowerShell as an administrator 178 | 1. Type `packagebuilder` and hit enter. 179 | 1. Go to http://downloads.puppetlabs.com/windows/puppet5/ (URL: http://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.0.1-x86.msi - SHA256: 1D1D45FBF8134A70EA3A39F42CA070BD6600B2FA9506B186EBABA20D770858B1 / Url64: http://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.0.1-x64.msi - SHA256: 992FD379F60C6D57E9E819CFE7EAD423D1C8B547A6994113ECB96A8C0EE6227D). 180 | 1. In the interface that comes up, let's put in the Url and 64-bit Url. 181 | 1. Also pass the SHA for verifying the file is what we hope. 182 | 1. Click the box next to "Don't embed (don't include software binaries in package)?" 183 | 1. Click on Nuspec Information tab. 184 | 1. In id, insert "puppet-agent". 185 | 1. Click Generate 186 | 1. Note that it creates a full package. 187 | 1. Open up the packaging files in code. 188 | 1. Open the nuspec file. 189 | * Note how auto-detection filled out some of the fields here 190 | * Optionally we can remove some of the commented sections to tidy this file up and provide more information. 191 | 1. In the chocolateyInstall.ps1, note that it captured all MSI properties and prepared a fully ready to go installation. 192 | * Also note how it created nice packaging. 193 | * Optionally we can remove some of the comments and areas we don't need to tidy this up. 194 | 1. Right click on nuspec and select "Compile Chocolatey Package..." / type `choco pack` from that directory. 195 | 1. Copy the resulting file to the parent `packages` directory 196 | 1. Call `choco install puppet-agent -s . -y` (this tells Chocolatey to install from the local source location ".", which is current directory in both PowerShell.exe and Cmd.exe) 197 | 198 | ### Exercise 5: Create a package with Package Builder (Right Click) (C4B) 199 | #### 1Password 200 | 1. Download 1Password from this link - https://d13itkw33a7sus.cloudfront.net/dist/1P/win4/1Password-4.6.0.598.exe (ensure you unblock the file) OR OFFLINE: Find the file in `resources/installers` folder. 201 | 1. Right click on the file and choose "Create Chocolatey Package w/out GUI" - **NOTE**: This may error if UAC is on - if so, choose `Create Chocolatey Package...` instead and just click Generate when it comes up. 202 | 1. Inspect the output. 203 | 1. Let's install this package - `choco install 1password -s . -y --dir c:\programs\1password` (from the working directory where the nupkg is located). 204 | 205 | #### Charles Proxy 206 | 1. Download Charles Proxy (both 32 and 64 bit) - https://www.charlesproxy.com/download/ OR OFFLINE: Find the file in `resources/installers` folder. 207 | 1. Right click on the 32 bit download and choose "Create Chocolatey Package..." 208 | 1. Add the 64bit one into the field. 209 | 1. Click generate. 210 | 1. Inspect the output. 211 | 1. Install this package with `choco install charles -s . -y` (from the working directory where the nupkg is located) 212 | 213 | #### 7-Zip EXE 214 | 1. Download 7zip (EXE version) - http://www.7-zip.org/download.html (just the 64bit version) OR OFFLINE: Find the file in `resources/installers` folder. 215 | 1. Right click and choose "Create Chocolatey Package..." 216 | 1. Click Generate. 217 | 1. Inspect the output. 218 | 1. Open the TODO file that is generated and read over it. 219 | 1. Note that it doesn't necessarily figure out the silent arguments. 220 | 1. Add the proper silent arguments in the install script. 221 | 1. Right click on the 7zip nuspec and select "Compile Chocolatey Package..." 222 | 223 | #### 7-Zip MSI 224 | 1. Download 7zip (MSI version) - http://www.7-zip.org/download.html (just the 64bit version) OR OFFLINE: Find the file in `resources/installers` folder. 225 | 1. Right click and choose "Create Chocolatey Package..." 226 | 1. Click Generate. 227 | 1. Inspect the output. Note that it determines everything nicely. 228 | 1. Right click on the 7zip nuspec and select "Compile Chocolatey Package..." 229 | 230 | ### Exercise 6: Create all the packages (C4B) 231 | 1. Type `packagebuilder`. 232 | 1. Change output directory to add "programs" to the path (just to keep things separate). `C:\packages\programs` if you are in the packages folder. 233 | 1. Click on the Programs and Features tab. 234 | 1. Click `Generate` in that tab. 235 | 1. Note the output. 236 | 1. Look at package folders that didn't generate a nupkg. 237 | 238 | OR 239 | 240 | 1. `choco new --from-programs-and-features --build-package --outputdirectory programs` 241 | 1. Note the output. 242 | 1. Look at package folders that didn't generate a nupkg. 243 | 244 | ### Exercise 7: Set up a local Chocolatey.Server 245 | 1. ***HOST***: Start with `vagrant reload` to clear pending reboots. 246 | 1. Start the Windows Update service - `Get-Service wuauserv | Set-Service -StartupType Automatic -Passthru | Start-Service` 247 | 1. Install KB2919442 - `choco install KB2919442 -y` (note this may take a long time to install) 248 | 1. ***HOST***: Run `vagrant reload`. 249 | 1. Install KB2919355 - `choco install KB2919355 -y` - this one or the other Windows update takes a ***very*** long time to install, just be patient and let it complete. 250 | 1. ***HOST***: Run `vagrant reload`. 251 | 1. Run `choco install dotnet4.6.1 -y` 252 | 1. Stop the Windows Update service - `Get-Service wuauserv | Set-Service -StartupType Disabled -Passthru | Stop-Service` 253 | 1. ***HOST***: You guessed it, one more time - `vagrant reload` 254 | 1. Ensure IIS and Asp.NET are installed 255 | * `choco install IIS-WebServer -y --source windowsfeatures` 256 | * `choco install IIS-ASPNET45 -y --source windowsfeatures` 257 | 1. `choco install chocolatey.server -y` 258 | 1. Follow instructions at https://chocolatey.org/docs/how-to-set-up-chocolatey-server 259 | 1. Go to http://localhost, verify the setup, look at the password. 260 | 1. Add this repository to your default sources. Call it `internal_chocolatey` - try `choco source -?` to learn how. Ensure `http://localhost/chocolatey` is the source location you use. 261 | 262 | We are moving towards updating the base image to speed this bit up so that there is not the waiting around on it. 263 | 264 | ### Exercise 8: Push a package to a Chocolatey Server 265 | 1. Run `choco search -s http://localhost/chocolatey` 266 | 1. In the folder where we've generated packages, let's find 1Password nupkg. 267 | 1. Run `ls` to verify that there is a 1Password nupkg in the directory. If not, you need to navigate to that folder. 268 | 1. Run `choco push -s http://localhost -k chocolateyrocks` (note the push is different than the query url) - we only need to specify path to the nupkg if there is more than one in the current directory. 269 | 1. Run `choco search -s http://localhost/chocolatey`. Run `choco search -s internal_chocolatey` and note the output should be the same. 270 | 1. Note that the package is available. 271 | 272 | ### Exercise 9: Upgrade a package 273 | 1. Download an updated 1Password from this link - https://d13itkw33a7sus.cloudfront.net/dist/1P/win4/1Password-4.6.1.617.exe OR OFFLINE: Find the file in `resources/installers` folder. 274 | 1. Use any method for creating packages to generate the packaging for this upgrade. **NOTE**: When you do this, you may need to rename the existing 1Password package folder first. 275 | 1. Instead of using Package Builder, you can instead download the file into the tools directory of the current package, edit the nuspec version, delete the previous installer exe, and update the chocolateyInstall.ps1 to point to the new installer and then compile the package. 276 | 1. Push this updated package to the Chocolatey server. 277 | 278 | ### Exercise 10: Install package from Internal Repository 279 | 1. Run `choco search 1password -s internal_chocolatey` (or whatever name you passed) 280 | 1. Run `choco search 1password -s internal_chocolatey --all-versions`. Note the output. 281 | 1. Run `choco search 1password --detailed`. Note the output. 282 | 1. Run `choco upgrade 1password -s internal_chocolatey -y` 283 | 284 | ### Exercise 11: Reporting 285 | 1. Run `choco list -lo --include-programs` 286 | 1. Note the output. 287 | 1. Run `choco outdated` 288 | 1. Note the output. 289 | 290 | ### Exercise 12: Package Synchronizer - Automatic Sync (Licensed) 291 | 1. Run `choco list -lo --include-programs`. 292 | 1. Go to `C:\ProgramData\Chocolatey\lib`. Note the 1password package. 293 | 1. Rename the `C:\ProgramData\Chocolatey\license` folder to `licensed`. This will unlicense Chocolatey. 294 | 1. Go to Programs and Features. 295 | 1. Manually uninstall 1Password. 296 | 1. Run `choco list -lo --include-programs`. Note if 1password package is still there. 297 | 1. Rename the `C:\ProgramData\Chocolatey\licensed` folder to `license`. This will license Chocolatey. 298 | 1. Run `choco list -lo --include-programs`. Note if 1password package is still there. 299 | 1. Look for a lib-synced folder in `C:\ProgramData\Chocolatey`. 300 | 1. Note the contents. 301 | 1. You may need to reset some features due to running unlicensed Chocolatey. Run the following commands: 302 | ~~~sh 303 | choco feature enable -n virusCheck 304 | choco feature enable -n allowPreviewFeatures 305 | choco feature enable -n internalizeAppendUseOriginalLocation 306 | choco feature enable -n reduceInstalledPackageSpaceUsage 307 | ~~~ 308 | 309 | ### Exercise 13: Package Synchronizer - Choco Sync (C4B) 310 | 1. Go to `C:\ProgramData\chocolatey\.chocolatey` and delete the 7zip folder if it exists. Otherwise delete the 1password folder (these folders will have a version after them). 311 | 1. Run `choco list -lo --include-programs`. 312 | 1. Note any applications not being managed as Chocolatey packages. 313 | 1. Run `choco sync` - **NOTE**: If this errors, make sure you've turned on allowPreviewFeatures from exercise 0 to allow this feature to work. 314 | 1. Note how it relinks 7zip or 1password to an existing installed package. This is recreating a lost link. 315 | 1. Note that it is syncing with new packages for the rest of the items. 316 | 1. Go to the temp directory to see the packaging it created. 317 | 1. Run `choco list -lo --include-programs`. 318 | 1. Note any applications not being managed as Chocolatey packages. 319 | 320 | ### Exercise 14: Manually Internalize Notepad++ package 321 | 1. Follow the instructions at [internalize an existing package manually](https://chocolatey.org/docs/how-to-recompile-packages#how-to-internalizerecompile-an-existing-package-manually) to internalize Notepad++. 322 | 323 | ### Exercise 15: Internalize Visual Studio Code package (MSP/C4B) 324 | 1. Run `choco feature list`. Determine if `internalizeAppendUseOriginalLocation` is on. Turn it on otherwise. 325 | 1. Call `choco download vscode --internalize --resources-location http://somewhere/internal -s https://chocolatey.org/api/v2/` (literally). You only need to specify source if you've disabled the community repository source. 326 | 1. While it is downloading, head into the download folder it created. 327 | 1. Open the `download\vscode\tools\chocolateyInstall.ps1` (relative to the current working directory) in Notepad++ or Code. 328 | 1. Note the url variable. 329 | 1. When it finishes downloading and creating the package, note how that changes. 330 | 1. Note how it appended `-UseOriginalLocation` in this case. 331 | 332 | ### Exercise 16: Internalize AdobeReader package (MSP/C4B) 333 | 1. Run `choco feature list`. Determine if `internalizeAppendUseOriginalLocation` is on. Turn it on otherwise. 334 | 1. Call `choco download adobereader --internalize -s https://chocolatey.org/api/v2/` (you only need the source if you've disabled the community repo source) 335 | 1. While it is downloading, head into the download folder it created. 336 | 1. Open the chocolateyInstall.ps1 in Notepad++ or Code. 337 | 1. Note the url variable. 338 | 1. When it finishes downloading and creating the package, note how that changes. 339 | 1. Note that there is a files folder that contains the binaries. 340 | 1. Note how it has appended `-UseOriginalLocation` to the end of `Install-ChocolateyPackage`. 341 | 342 | **NOTE:** You can also complete this exercise with Chocolatey FOSS by manually internalizing the package, see [manually internalizing packages](https://chocolatey.org/docs/how-to-recompile-packages) for more information. 343 | 344 | ### Exercise 17: Download Chocolatey and Licensed packages (Licensed) 345 | To have a completely offline install for packaging, you need to remove 346 | 347 | 1. Run `choco source list` to see your sources. 348 | 1. Run `choco source disable -n chocolatey` 349 | 1. Run `choco download chocolatey -s https://chocolatey.org/api/v2/` 350 | 1. Run `choco download chocolatey.server -s https://chocolatey.org/api/v2/` 351 | 1. Run `choco download chocolatey.extension --ignore-dependencies --source https://licensedpackages.chocolatey.org/api/v2/` 352 | 1. C4B: Run `choco download chocolatey-agent --ignore-dependencies --source https://licensedpackages.chocolatey.org/api/v2/` 353 | 1. Run `choco source disable -n chocolatey.licensed` - **NOTE**: When you have a licensed version of Chocolatey, you are unable to remove this source. It can be disabled though. Also, once this is disabled, you would need your license id as the password you would pass to the licensed source in the previous steps. 354 | 1. Push all of these packages to your internal server. 355 | 1. You are now using Chocolatey with internal only packages. 356 | 357 | ### Exercise 18: Create an extension package 358 | We are going to create a package that checks for prerequisites prior to the install, such as ensuring at least 3 GB of free space. 359 | 360 | 1. Run `choco new prerequisites.extension` 361 | 1. Delete the `prerequisites.extension\tools` directory. 362 | 1. Create an `extensions` directory. 363 | 1. Create a file called `prerequisites.psm1` in the extensions directory. 364 | 1. Add this to the contents: 365 | ~~~powershell 366 | # Export functions that start with capital letter, others are private 367 | # Include file names that start with capital letters, ignore others 368 | $ScriptRoot = Split-Path $MyInvocation.MyCommand.Definition 369 | 370 | $pre = ls Function:\* 371 | ls "$ScriptRoot\*.ps1" | ? { $_.Name -cmatch '^[A-Z]+' } | % { . $_ } 372 | $post = ls Function:\* 373 | $funcs = compare $pre $post | select -Expand InputObject | select -Expand Name 374 | $funcs | ? { $_ -cmatch '^[A-Z]+'} | % { Export-ModuleMember -Function $_ } 375 | ~~~ 376 | 1. Create a file `Ensure-ThreeGBs.ps1` and add the following contents: 377 | ~~~powershell 378 | <# 379 | .SYNOPSIS 380 | Ensures that there is at least 3 GB of space left on a machine or it will not allow installation 381 | 382 | .OUTPUTS 383 | [String] 384 | #> 385 | function Ensure-ThreeGBs { 386 | Write-Debug "Running Get-AvailableDiskSpace to determine if there is enough space for installation." 387 | 388 | $disk = Get-PSDrive C | Select-Object Used,Free 389 | Write-Host "There is $($disk.Free) available" 390 | 391 | $ThreeGBs = 3221225472 392 | if ($disk.Free -lt $ThreeGBs) { 393 | throw "There is less than 3GB of free space left." 394 | } 395 | 396 | return $disk.Free 397 | } 398 | ~~~ 399 | 1. Update the nuspec appropriately. Ensure the version is at least `0.0.1`. 400 | 1. In the nuspec, change `` to ``. 401 | 1. Run `choco pack` against the directory with `prerequisites.extension.nuspec`. 402 | 1. Copy the nupkg file up to the packages directory. 403 | 1. Now head into the 1Password package from exercise and open `tools\chocolateyInstall.ps1`. 404 | 1. On line 1, add the following: `Ensure-ThreeGBs`. Save and close. 405 | 1. Open up `1password.nuspec` and add a dependency on the prerequisites.extension package (right before ``): 406 | ~~~xml 407 | 408 | 409 | 410 | ~~~ 411 | 1. Compile the 1password package back up and put it in the folder next to the `prerequisites.extension` nupkg. 412 | 1. Run `choco install 1password -s . -y`. **NOTE**: We uninstalled this with auto sync in an earlier exercise. 413 | 1. Note in the install how it automatically loads up the prerequisites functions and makes them available without any more work on the part of the installation scripts. 414 | 415 | **NOTE**: Learn more at https://chocolatey.org/docs/how-to-create-extensions. 416 | 417 | ### Exercise 19: Create a package template for MSIs 418 | 1. Run `choco new msi.template`. 419 | 1. Delete the `msi.template\tools` directory. 420 | 1. Create `templates\msi.nuspec.template` and add the following contents: 421 | ~~~powershell 422 | 423 | 424 | 425 | [[PackageNameLower]] 426 | [[PackageName]] (Install) 427 | [[PackageVersion]] 428 | Original authors 429 | [[MaintainerName]] 430 | __REPLACE__MarkDown_Okay [[AutomaticPackageNotesNuspec]] 431 | 432 | [[PackageNameLower]] admin 433 | 437 | 438 | 439 | 440 | 441 | 442 | ~~~ 443 | 1. Create `templates\tools\chocolateyInstall.ps1` and add the following contents: 444 | ~~~powershell 445 | $ErrorActionPreference = 'Stop'; 446 | $packageName= '[[PackageName]]' 447 | $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 448 | $fileLocation = Join-Path $toolsDir 'NAME_OF_EMBEDDED_INSTALLER_FILE' 449 | 450 | $packageArgs = @{ 451 | packageName = $packageName 452 | unzipLocation = $toolsDir 453 | fileType = 'msi' 454 | file = $fileLocation 455 | softwareName = '[[PackageName]]*' #part or all of the Display Name as you see it in Programs and Features. It should be enough to be unique 456 | silentArgs = "/qn /norestart /l*v `"$env:TEMP\chocolatey\$($packageName)\$($packageName).MsiInstall.log`"" # ALLUSERS=1 DISABLEDESKTOPSHORTCUT=1 ADDDESKTOPICON=0 ADDSTARTMENU=0 457 | validExitCodes= @(0, 3010, 1641) 458 | } 459 | 460 | Install-ChocolateyInstallPackage @packageArgs 461 | ~~~ 462 | 1. Open `msi.template.nuspec` and edit it appropriately. Set the version to `1.0.0`. 463 | 1. In the nuspec, change `` to ``. 464 | 1. Call `choco pack`. 465 | 1. Now we can push this up to our package server. 466 | 1. Let's install this template - `choco install msi.template -s internal_chocolatey`. 467 | 468 | **NOTE:** Learn more at https://chocolatey.org/docs/how-to-create-custom-package-templates. 469 | 470 | ### Exercise 20: Create a package from a template 471 | 1. Run `choco new bob -t msi`. 472 | 1. Head into the bob folder. 473 | 1. Note how it does replacements of all of the `[[variables]]` 474 | 475 | ### Exercise 21: Update a packaging template / use custom properties 476 | 1. Let's add a new variable. 477 | 1. Open `msi.template\templates\tools\chocolateyInstall.ps1` 478 | 1. Add the following at the top: `# [[CustomVariable]]` 479 | 1. Save and close that file. 480 | 1. Open `msi.template.nuspec` and increase the version to `1.0.1` . 481 | 1. Close that, package it up and push it up to the server again. 482 | 1. Run `choco upgrade msi.template -s internal_chocolatey`. 483 | 1. Now run `choco new tim -t msi CustomVariable="Yes"` 484 | 1. Note the output in the tim folder that is created. 485 | 486 | ### Exercise 22: Use package parameters 487 | 1. Run `choco new packagewithparameters` 488 | 1. Remove everything but the nuspec and `tools\chocolateyInstall.ps1`. 489 | 1. In the nuspec, take a dependency on `chocolatey-core.extension` version `[1,3)` (which means at least v1, but anything less than v3) and change the version to `0.0.1`. 490 | 1. In the `chocolateyInstall.ps1`, delete everything and just add the following: 491 | ~~~powershell 492 | $pp = Get-PackageParameters 493 | 494 | if (!$pp['LICENSE']) { $pp['LICENSE'] = 'License123' } 495 | #if (!$pp['LICENSE']) { $pp['LICENSE'] = Read-Host "Please provide LICENSE" } 496 | 497 | Write-Warning "LICENSE = '$($pp['LICENSE'])'" 498 | ~~~ 499 | 1. Package up the package and push it to your internal server. 500 | 1. Ensure the chocolatey-core.extension package is up on the internal server as well. 501 | 1. Run `choco install packagewithparameters -s internal_chocolatey --params "'/LICENSE:Yes'"` and note the output. 502 | 503 | **NOTE**: Learn more at https://chocolatey.org/docs/how-to-parse-package-parameters-argument. 504 | 505 | ### Exercise 23: Use AutoHotKey for craptastic installers 506 | 507 | **NOTE**: Craptastic is a technical term ;). 508 | 509 | 1. COMING SOON. 510 | -------------------------------------------------------------------------------- /ReadMe.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chocolatey/chocolatey-workshop/bd43f260c6136d519c0cf2bd565d511bd7d9935b/ReadMe.pdf -------------------------------------------------------------------------------- /demo/Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure('2') do |config| 2 | # This setting will download the atlas box at 3 | # https://atlas.hashicorp.com/ferventcoder/boxes/win2012r2-x64-nocm 4 | config.vm.box = 'ferventcoder/win2012r2-x64-nocm' 5 | 6 | config.vm.provider :virtualbox do |v, override| 7 | # Show the GUI 8 | v.gui = true 9 | # 4GB RAM 10 | v.customize ["modifyvm", :id, "--memory", "4096"] 11 | # 2 CPUs 12 | v.customize ["modifyvm", :id, "--cpus", "2"] 13 | # Video RAM is 32 MB 14 | v.customize ["modifyvm", :id, "--vram", 32] 15 | # For better DNS resolution 16 | v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 17 | # No audo 18 | v.customize ["modifyvm", :id, "--audio", "none"] 19 | # Clipboard enabled 20 | v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] 21 | v.customize ["modifyvm", :id, "--draganddrop", "hosttoguest"] 22 | # For performance 23 | v.customize ["modifyvm", :id, "--usb", "off"] 24 | # Huge performance gain here 25 | v.linked_clone = true if Vagrant::VERSION >= '1.8.0' 26 | end 27 | 28 | config.vm.provider :vmware_fusion do |v, override| 29 | #override.vm.box_url = ENTER A URL TO A VALID VMWARE FUSION BASE BOX OF win2012r2 30 | v.gui = true 31 | v.linked_clone = true if Vagrant::VERSION >= '1.8.0' 32 | # box customizations for speed 33 | v.vmx["memsize"] = "2048" 34 | v.vmx["usb.present"] = "false" 35 | v.vmx["sound.present"] = "false" 36 | v.vmx["ide1:0.present"] = "false" 37 | end 38 | 39 | # https://www.vagrantup.com/docs/hyperv/configuration.html 40 | # https://technet.microsoft.com/en-us/library/dn798297(v=ws.11).aspx 41 | config.vm.provider :hyperv do |v, override| 42 | # 4GB RAM 43 | v.memory = 4096 44 | # 2 CPUs 45 | v.cpus = 2 46 | # The time in seconds to wait for the virtual machine to report an IP address 47 | v.ip_address_timeout = 130 48 | # Use differencing disk instead of cloning whole VHD 49 | v.differencing_disk = true 50 | v.vm_integration_services = { 51 | guest_service_interface: true, 52 | heartbeat: true, 53 | key_value_pair_exchange: true, 54 | shutdown: true, 55 | time_synchronization: true, 56 | vss: true 57 | } 58 | end 59 | 60 | config.vm.communicator = "winrm" 61 | config.vm.guest = :windows 62 | config.windows.halt_timeout = 20 63 | config.winrm.username = "vagrant" 64 | config.winrm.password = "vagrant" 65 | 66 | # open up forwarded ports from the guest system to the host. 67 | config.vm.network :forwarded_port, guest: 5985, host: 55985, id: 'winrm', auto_correct: true 68 | config.vm.network :forwarded_port, guest: 22, host: 2222, id: 'ssh', auto_correct: true 69 | config.vm.network :forwarded_port, guest: 80, host: 8090, id: 'web', auto_correct: true 70 | 71 | config.vm.provision :shell, :path => 'shell/PrepareWindows.ps1' 72 | config.vm.provision :shell, :path => 'shell/InstallChocolatey.ps1' 73 | 74 | if Vagrant::VERSION < '1.8.0' 75 | config.vm.provision :shell, :path => 'shell/NotifyGuiAppsOfEnvironmentChanges.ps1' 76 | else 77 | config.vm.provision :shell, :path => 'shell/NotifyGuiAppsOfEnvironmentChanges.ps1', :powershell_elevated_interactive => true 78 | end 79 | end 80 | -------------------------------------------------------------------------------- /demo/packages/ReadMe.md: -------------------------------------------------------------------------------- 1 | Add packages to this folder if you are doing an offline workshop. 2 | -------------------------------------------------------------------------------- /demo/resources/installers/download.ps1: -------------------------------------------------------------------------------- 1 | & curl.exe -O https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise64.msi 2 | & curl.exe -O https://dl.google.com/tag/s/dl/chrome/install/googlechromestandaloneenterprise.msi 3 | & curl.exe -O http://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.3.3-x86.msi 4 | & curl.exe -O http://downloads.puppetlabs.com/windows/puppet5/puppet-agent-5.3.3-x64.msi 5 | & curl.exe -O https://d13itkw33a7sus.cloudfront.net/dist/1P/win4/1Password-4.6.0.598.exe 6 | & curl.exe -O https://d13itkw33a7sus.cloudfront.net/dist/1P/win4/1Password-4.6.1.617.exe 7 | 8 | & curl.exe -L -O http://www.7-zip.org/a/7z1801-x64.exe 9 | & curl.exe -L -O http://www.7-zip.org/a/7z1801-x64.msi 10 | # get from main machine https://www.charlesproxy.com/download/ 11 | # get from main machine http://www.7-zip.org/download.html 12 | 13 | choco download baretail chocolatey chocolatey-agent chocolatey.extension chocolateygui chocolatey.server dotnet4.5.2 dotnet4.6.1 git launchy notepadplusplus visualstudiocode --force --internalize --internalize-all-urls --append-use-original-location --output-directory=..\..\packages 14 | 15 | Remove-Item -Path '..\..\packages\download' -Recurse -Force -ErrorAction Continue 16 | 17 | choco download vagrant virtualbox --force --internalize --internalize-all-urls --append-use-original-location --output-directory=..\..\..\setup 18 | 19 | Remove-Item -Path '..\..\..\setup\download' -Recurse -Force -ErrorAction Continue 20 | -------------------------------------------------------------------------------- /demo/resources/licenses/ReadMe.md: -------------------------------------------------------------------------------- 1 | Add the chocolatey.license.xml file here. 2 | -------------------------------------------------------------------------------- /demo/shell/InstallChocolatey.ps1: -------------------------------------------------------------------------------- 1 | [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 2 | 3 | $installLocalFile = $false 4 | $localChocolateyPackageFilePath = 'C:\vagrant\packages\chocolatey.0.10.8.nupkg' 5 | 6 | $installLatestBeta = $true 7 | # OR install a version directly 8 | #$env:chocolateyVersion="0.9.10-beta-20160402" 9 | 10 | $ChocoInstallPath = "$($env:SystemDrive)\ProgramData\Chocolatey\bin" 11 | $env:ChocolateyInstall = "$($env:SystemDrive)\ProgramData\Chocolatey" 12 | $env:Path += ";$ChocoInstallPath" 13 | $DebugPreference = "Continue"; 14 | $env:ChocolateyEnvironmentDebug = 'true' 15 | 16 | function Install-LocalChocolateyPackage { 17 | param ( 18 | [string]$chocolateyPackageFilePath = '' 19 | ) 20 | 21 | if ($chocolateyPackageFilePath -eq $null -or $chocolateyPackageFilePath -eq '') { 22 | throw "You must specify a local package to run the local install." 23 | } 24 | 25 | if (!(Test-Path($chocolateyPackageFilePath))) { 26 | throw "No file exists at $chocolateyPackageFilePath" 27 | } 28 | 29 | if ($env:TEMP -eq $null) { 30 | $env:TEMP = Join-Path $env:SystemDrive 'temp' 31 | } 32 | $chocTempDir = Join-Path $env:TEMP "chocolatey" 33 | $tempDir = Join-Path $chocTempDir "chocInstall" 34 | if (![System.IO.Directory]::Exists($tempDir)) {[System.IO.Directory]::CreateDirectory($tempDir)} 35 | $file = Join-Path $tempDir "chocolatey.zip" 36 | Copy-Item $chocolateyPackageFilePath $file -Force 37 | 38 | # unzip the package 39 | Write-Output "Extracting $file to $tempDir..." 40 | $shellApplication = new-object -com shell.application 41 | $zipPackage = $shellApplication.NameSpace($file) 42 | $destinationFolder = $shellApplication.NameSpace($tempDir) 43 | $destinationFolder.CopyHere($zipPackage.Items(),0x10) 44 | 45 | # Call chocolatey install 46 | Write-Output "Installing chocolatey on this machine" 47 | $toolsFolder = Join-Path $tempDir "tools" 48 | $chocInstallPS1 = Join-Path $toolsFolder "chocolateyInstall.ps1" 49 | 50 | & $chocInstallPS1 51 | 52 | Write-Output 'Ensuring chocolatey commands are on the path' 53 | $chocInstallVariableName = "ChocolateyInstall" 54 | $chocoPath = [Environment]::GetEnvironmentVariable($chocInstallVariableName) 55 | if ($chocoPath -eq $null -or $chocoPath -eq '') { 56 | $chocoPath = 'C:\ProgramData\Chocolatey' 57 | } 58 | 59 | $chocoExePath = Join-Path $chocoPath 'bin' 60 | 61 | if ($($env:Path).ToLower().Contains($($chocoExePath).ToLower()) -eq $false) { 62 | $env:Path = [Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine); 63 | } 64 | } 65 | 66 | if (!(Test-Path $ChocoInstallPath)) { 67 | # Install Chocolatey 68 | if ($installLocalFile) { 69 | Install-LocalChocolateyPackage $localChocolateyPackageFilePath 70 | } else { 71 | if ($installLatestBeta) { 72 | Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/installabsolutelatest.ps1')) 73 | } else { 74 | Invoke-Expression ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /demo/shell/NotifyGuiAppsOfEnvironmentChanges.ps1: -------------------------------------------------------------------------------- 1 | Write-Host "Sometimes explorer.exe just doesn't get the message that it should update environment variables" 2 | setx trigger 1 3 | -------------------------------------------------------------------------------- /demo/shell/PrepareWindows.ps1: -------------------------------------------------------------------------------- 1 | $licenseFile = 'c:\vagrant\resources\licenses\chocolatey.license.xml' 2 | $licenseDirectory = 'c:\ProgramData\chocolatey\license' 3 | 4 | if ((Test-Path $licenseFile) -and !(Test-Path $licenseDirectory)) { 5 | Write-Host "Copying license file" 6 | $null = New-Item -Path "$licenseDirectory" -ItemType Directory -Force 7 | Copy-Item $licenseFile $licenseDirectory -Force 8 | } 9 | 10 | if (!(Test-Path ('c:\vagrant\packages'))) { New-Item 'c:\vagrant\packages' -ItemType 'Directory' } 11 | 12 | if (!(Test-Path ('c:\packages'))) { New-Item 'c:\packages' -ItemType 'Directory' } 13 | -------------------------------------------------------------------------------- /presentations/Chocolatey-KCDC2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chocolatey/chocolatey-workshop/bd43f260c6136d519c0cf2bd565d511bd7d9935b/presentations/Chocolatey-KCDC2017.pdf -------------------------------------------------------------------------------- /presentations/ChocolateyWorkshop-WinOpsLondon2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chocolatey/chocolatey-workshop/bd43f260c6136d519c0cf2bd565d511bd7d9935b/presentations/ChocolateyWorkshop-WinOpsLondon2017.pdf -------------------------------------------------------------------------------- /setup/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Offline Workshop Setup 2 | 3 | 1. Download the following and place them in this folder: 4 | * Vagrant 1.9.x MSI (Windows) / DMG (MacOS) 5 | * Vagrant 2.x MSI (Windows) / DMG (MacOS) 6 | * VirtualBox 5.x Exe (Windows) / DMG (MacOS) 7 | 1. On a machine where you have Chocolatey MSP or C4B, open a PowerShell Admin and go to the `demo\resources\installers` directory and run `.\download.ps1` - you will need a commercial edition of Chocolatey installed for it to be successful (MSP/C4B required). 8 | 1. Prepare a trial license file if necessary for folks coming to workshop. Give them about 10 days after the workshop to continue playing. Put that in the `demo\resources\licenses\` folder as `chocolatey.license.xml`. 9 | 1. All of what you have goes onto a USB key along with the vagrant boxes. 10 | 1. USB Drive: Create a directory called `chocolatey-workshop`. Copy everything here into that directory. 11 | 1. USB: Pull the setup.bat/setup.ps1 out of the setup directory and to the root directory next to chocolatey-workshop. 12 | 1. USB: Create a directory called `vagrant_boxes`. 13 | 1. USB: Copy the vagrant boxes (.box files) directly there. You may also want to put MD5 checksums there as well. 14 | -------------------------------------------------------------------------------- /setup/setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal enableextensions enabledelayedexpansion 3 | set psscript="./setup.ps1" 4 | echo ================================================== 5 | echo ============= WRAP POWERSHELL SCRIPT ============= 6 | echo ================================================== 7 | 8 | echo calling %psscript% with args %* 9 | PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%psscript%' %*" 10 | 11 | echo ================================================== 12 | endlocal 13 | -------------------------------------------------------------------------------- /setup/setup.ps1: -------------------------------------------------------------------------------- 1 | Function Get-Folder($initialDirectory) 2 | { 3 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") > $null 4 | 5 | $foldername = New-Object System.Windows.Forms.FolderBrowserDialog 6 | $foldername.rootfolder = "MyComputer" 7 | 8 | if($foldername.ShowDialog() -eq "OK") 9 | { 10 | $folder += $foldername.SelectedPath 11 | } 12 | 13 | return $folder 14 | } 15 | 16 | Function Pause ($Message = "Press any key to continue . . . ") { 17 | if ((Test-Path variable:psISE) -and $psISE) { 18 | $Shell = New-Object -ComObject "WScript.Shell" 19 | $Button = $Shell.Popup("Click OK to continue.", 0, "Script Paused", 0) 20 | } 21 | else { 22 | Write-Host -NoNewline $Message 23 | [void][System.Console]::ReadKey($true) 24 | Write-Host 25 | } 26 | } 27 | 28 | $title = "Physical or Virtual" 29 | $message = "Are you using your physical machine for the workshop, or do you want to use a Virtual Image?" 30 | 31 | $physical = New-Object System.Management.Automation.Host.ChoiceDescription "&Physical", ` 32 | "You are going to use your own machine, and have everything necessary for the Workshop" 33 | 34 | $virtual = New-Object System.Management.Automation.Host.ChoiceDescription "&Virtual", ` 35 | "You want to use a Virtual Machine for the workshop" 36 | 37 | $options = [System.Management.Automation.Host.ChoiceDescription[]]($physical, $virtual) 38 | 39 | $result = $host.ui.PromptForChoice($title, $message, $options, 0) 40 | 41 | switch ($result) 42 | { 43 | 0 44 | { 45 | "You are using a Physical Machine..." 46 | } 47 | 1 48 | { 49 | $title = "Vagrant Installed?" 50 | $message = "Do you have Vagrant installed?" 51 | 52 | $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", ` 53 | "You already have Vagrant installed, and no further action will be taken." 54 | 55 | $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", ` 56 | "You don't have Vagrant installed, and an attempt will be made to install it." 57 | 58 | $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no) 59 | 60 | $result = $host.ui.PromptForChoice($title, $message, $options, 0) 61 | 62 | switch ($result) 63 | { 64 | 0 65 | { 66 | "You said you have Vagrant installed" 67 | } 68 | 1 69 | { 70 | choco install vagrant --source "chocolatey-workshop/setup" 71 | } 72 | } 73 | 74 | $title = "Vagrant Provider" 75 | $message = "Would you like to use a pre-setup Vagrant Image? If so, which provider would you like to use?" 76 | 77 | $virtualbox = New-Object System.Management.Automation.Host.ChoiceDescription "&Virtual Box", ` 78 | "Use the Virtual Box Vagrant Provider." 79 | 80 | $hyperv = New-Object System.Management.Automation.Host.ChoiceDescription "&Hyper-V", ` 81 | "Use the Hyper-V Vagrant Provider." 82 | 83 | $none = New-Object System.Management.Automation.Host.ChoiceDescription "&None", ` 84 | "You have your own virtual machine image that you would like to use." 85 | 86 | $options = [System.Management.Automation.Host.ChoiceDescription[]]($virtualbox, $hyperv, $none) 87 | 88 | $result = $host.ui.PromptForChoice($title, $message, $options, 0) 89 | 90 | switch ($result) 91 | { 92 | 0 93 | { 94 | vagrant box add --provider virtualbox --name ferventcoder/win2012r2-x64-nocm "vagrant_boxes/win2012r2-x64-vbox4216-nocm.box" 95 | } 96 | 1 97 | { 98 | Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All 99 | vagrant box add --provider hyperv --name ferventcoder/win2012r2-x64-nocm "vagrant_boxes/win2012r2-x64-hyperv-nocm.box" 100 | } 101 | 2 102 | { 103 | "Nothing to do here :-)" 104 | } 105 | } 106 | } 107 | } 108 | 109 | Write-Host "Where do you want to copy workshop files to?" 110 | 111 | $targetFolder = Get-Folder 112 | 113 | # Only copy files if a folder is chosen 114 | if($targetFolder) { 115 | Copy-Item -Path "chocolatey-workshop/*" -Destination $targetFolder -Recurse -Verbose -ErrorAction $ErrorActionPreference 116 | } else { 117 | Write-Host "You have chosen to not copy files." 118 | } 119 | 120 | Pause 121 | -------------------------------------------------------------------------------- /setup/vagrant_2.0.txt: -------------------------------------------------------------------------------- 1 | cdd833429715c5639e28d0328881c86539e506e95eeaee9dc531c7f4b3124ffe vagrant_2.0.2_i686.deb 2 | 1e0de3a5907d38df4ad554cffb22b046649e29629302b9d09ff58f0e39982d4b vagrant_2.0.2_i686.msi 3 | 4bd044b97ebfb95657d8acbd314dd9b896ae720ad867fd4c53fc92ac073d9810 vagrant_2.0.2_i686.rpm 4 | df8dfb0176d62f0d20d11caec51e53bad57ea2bcc3877427841658702906754f vagrant_2.0.2_x86_64.deb 5 | c5dd5b8c7193844a6cc5b6f79b0c878cd144f1eebbac72ad70de0f3cfdb31d93 vagrant_2.0.2_x86_64.dmg 6 | 2ae003443732c8e2000c2c7088cead9e97411a84fe0a92f7ce8c8d2f9277e8a5 vagrant_2.0.2_x86_64.msi 7 | 3f4379d95474ec00b195a133ef2559ba1dff4354fe01e8b3b5addc2863b8b655 vagrant_2.0.2_x86_64.rpm 8 | 41c51ce192f40388d35b68d9039f9dc3470dc88a7d38380034bd3f6e56795e9d vagrant_2.0.2_x86_64.tar.xz 9 | -------------------------------------------------------------------------------- /solutions/Exercise2/googlechrome/googlechrome.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | googlechrome 7 | 60.0.3112.78 8 | 9 | 10 | 11 | 12 | googlechrome (Install) 13 | Google Chrome 14 | 15 | googlechrome admin browser 16 | Google Chrome 17 | Google Chrome description 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /solutions/Exercise2/googlechrome/tools/_ReadMe.md: -------------------------------------------------------------------------------- 1 | Please add googlechromestandaloneenterprise64.msi here in this directory. 2 | Delete this file after you do. 3 | -------------------------------------------------------------------------------- /solutions/Exercise2/googlechrome/tools/chocolateyinstall.ps1: -------------------------------------------------------------------------------- 1 | $ErrorActionPreference = 'Stop'; 2 | $toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 3 | $fileLocation = Join-Path $toolsDir 'googlechromestandaloneenterprise64.msi' 4 | 5 | $packageArgs = @{ 6 | packageName = $env:ChocolateyPackageName 7 | fileType = 'MSI' 8 | file = $fileLocation 9 | softwareName = 'Google Chrome*' 10 | silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`"" 11 | validExitCodes= @(0, 3010, 1641) 12 | } 13 | 14 | Install-ChocolateyInstallPackage @packageArgs 15 | --------------------------------------------------------------------------------