├── .gitattributes ├── .gitignore ├── FluentMigrator.Generator.nuspec ├── FluentMigrator.psd1 ├── FluentMigrator.psm1 ├── LICENSE.txt ├── README.md ├── appveyor.yml ├── build.cake ├── build.cmd ├── build.ps1 └── init.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.bat text=auto eol=crlf 4 | *.cmd text=auto eol=crlf 5 | *.config text=auto 6 | *.cs text=auto diff=csharp 7 | *.cshtml text=auto 8 | *.css text=auto 9 | *.htm text=auto 10 | *.html text=auto 11 | *.js text=auto 12 | *.msbuild text=auto 13 | *.nuspec text=auto 14 | *.resx text=auto 15 | *.props text=auto 16 | *.ps text=auto eol=crlf 17 | *.psm1 text=auto eol=crlf 18 | *.pubxml text=auto 19 | *.ruleset text=auto 20 | *.StyleCop text=auto 21 | *.sql text=auto 22 | *.svg text=auto 23 | *.txt text=auto 24 | *.xml text=auto 25 | *.targets text=auto 26 | 27 | *.proj text=auto merge=union 28 | *.csproj text=auto merge=union 29 | *.vbproj text=auto merge=union 30 | *.fsproj text=auto merge=union 31 | *.dbproj text=auto merge=union 32 | *.sln text=auto merge=union eol=crlf 33 | 34 | *.jpg binary 35 | *.png binary 36 | *.gif binary 37 | *.ico binary 38 | *.otf binary 39 | *.eot binary 40 | *.ttf binary 41 | *.woff binary 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | .vs/ 9 | 10 | # Build results 11 | [Dd]ebug/ 12 | [Dd]ebugPublic/ 13 | [Rr]elease/ 14 | [Rr]eleases/ 15 | x64/ 16 | artifacts/ 17 | bld/ 18 | [Bb]in/ 19 | [Oo]bj/ 20 | App_Data/ 21 | tools/ 22 | 23 | # Roslyn cache directories 24 | pingme.txt 25 | *.ide/ 26 | 27 | # MSTest test Results 28 | [Tt]est[Rr]esult*/ 29 | [Bb]uild[Ll]og.* 30 | 31 | #NUNIT 32 | *.VisualState.xml 33 | TestResult.xml 34 | 35 | # Build Results of an ATL Project 36 | [Dd]ebugPS/ 37 | [Rr]eleasePS/ 38 | dlldata.c 39 | 40 | *_i.c 41 | *_p.c 42 | *_i.h 43 | *.ilk 44 | *.meta 45 | *.obj 46 | *.pch 47 | *.pdb 48 | *.pgc 49 | *.pgd 50 | *.rsp 51 | *.sbr 52 | *.tlb 53 | *.tli 54 | *.tlh 55 | *.tmp 56 | *.tmp_proj 57 | *.log 58 | *.vspscc 59 | *.vssscc 60 | .builds 61 | *.pidb 62 | *.svclog 63 | *.scc 64 | *.exe 65 | *.dll 66 | *.pdb 67 | 68 | # Chutzpah Test files 69 | _Chutzpah* 70 | 71 | # Visual C++ cache files 72 | ipch/ 73 | *.aps 74 | *.ncb 75 | *.opensdf 76 | *.sdf 77 | *.cachefile 78 | 79 | # Visual Studio profiler 80 | *.psess 81 | *.vsp 82 | *.vspx 83 | 84 | # TFS 2012 Local Workspace 85 | $tf/ 86 | 87 | # Guidance Automation Toolkit 88 | *.gpState 89 | 90 | # ReSharper is a .NET coding add-in 91 | _ReSharper*/ 92 | *.[Rr]e[Ss]harper 93 | *.DotSettings.user 94 | 95 | # JustCode is a .NET coding addin-in 96 | .JustCode 97 | 98 | # TeamCity is a build add-in 99 | _TeamCity* 100 | 101 | # DotCover is a Code Coverage Tool 102 | *.dotCover 103 | 104 | # NCrunch 105 | _NCrunch_* 106 | .*crunch*.local.xml 107 | *.ncrunchproject 108 | *.ncrunchsolution 109 | 110 | # MightyMoose 111 | *.mm.* 112 | AutoTest.Net/ 113 | 114 | # Web workbench (sass) 115 | .sass-cache/ 116 | 117 | # Installshield output folder 118 | [Ee]xpress/ 119 | 120 | # DocProject is a documentation generator add-in 121 | DocProject/buildhelp/ 122 | DocProject/Help/*.HxT 123 | DocProject/Help/*.HxC 124 | DocProject/Help/*.hhc 125 | DocProject/Help/*.hhk 126 | DocProject/Help/*.hhp 127 | DocProject/Help/Html2 128 | DocProject/Help/html 129 | 130 | # Click-Once directory 131 | publish/ 132 | 133 | # Publish Web Output 134 | *.[Pp]ublish.xml 135 | *.azurePubxml 136 | 137 | # NuGet Packages 138 | .nuget/ 139 | packages/* 140 | *.nupkg 141 | 142 | # Enable "build/" folder in the NuGet Packages folder since 143 | # NuGet packages use it for MSBuild targets. 144 | # This line needs to be after the ignore of the build folder 145 | # (and the packages folder if the line above has been uncommented) 146 | !packages/build/ 147 | 148 | # Windows Azure Build Output 149 | csx/ 150 | *.build.csdef 151 | 152 | # Windows Store app package directory 153 | AppPackages/ 154 | 155 | # Others 156 | sql/ 157 | *.Cache 158 | ClientBin/ 159 | [Ss]tyle[Cc]op.* 160 | ~$* 161 | *~ 162 | *.dbmdl 163 | *.dbproj.schemaview 164 | *.pfx 165 | *.publishsettings 166 | node_modules/ 167 | 168 | # RIA/Silverlight projects 169 | Generated_Code/ 170 | 171 | # Backup & report files from converting an old project file 172 | # to a newer Visual Studio version. Backup files are not needed, 173 | # because we have git ;-) 174 | _UpgradeReport_Files/ 175 | Backup*/ 176 | UpgradeLog*.XML 177 | UpgradeLog*.htm 178 | 179 | # SQL Server files 180 | *.mdf 181 | *.ldf 182 | 183 | # Business Intelligence projects 184 | *.rdl.data 185 | *.bim.layout 186 | *.bim_*.settings 187 | 188 | # Microsoft Fakes 189 | FakesAssemblies/ 190 | -------------------------------------------------------------------------------- /FluentMigrator.Generator.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FluentMigrator.Generator 5 | 1.0.5 6 | Ritter Insurance Marketing, LLC 7 | https://github.com/ritterim/fluentmigrator-generator 8 | https://raw.githubusercontent.com/ritterim/fluentmigrator-generator/master/LICENSE 9 | https://github.com/ritterim/fluentmigrator-generator/releases 10 | Adds a command to the package manager console to generate migrations for FluentMigrator. 11 | Copyright 2018 Ritter Insurance Marketing, LLC 12 | false 13 | true 14 | en-US 15 | fluentmigrator migrations 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /FluentMigrator.psd1: -------------------------------------------------------------------------------- 1 | @{ 2 | # Script module or binary module file associated with this manifest 3 | ModuleToProcess = 'FluentMigrator.psm1' 4 | 5 | # Version number of this module. 6 | ModuleVersion = '1.0.0.0' 7 | 8 | # ID used to uniquely identify this module 9 | GUID = '01820234-1d7c-4b25-8d01-a9d5e108f77b' 10 | 11 | # Author of this module 12 | Author = 'Ritter Insurance Marketing' 13 | 14 | # Company or vendor of this module 15 | CompanyName = 'Ritter Insurance Marketing' 16 | 17 | # Copyright statement for this module 18 | Copyright = '(c) Ritter Insurance Marketing, LLC. All rights reserved.' 19 | 20 | # Description of the functionality provided by this module 21 | Description = 'FluentMigrator PowerShell module for use within NuGet''s Package Manager Console' 22 | 23 | # Minimum version of the Windows PowerShell engine required by this module 24 | PowerShellVersion = '2.0' 25 | 26 | # Name of the Windows PowerShell host required by this module 27 | PowerShellHostName = 'Package Manager Host' 28 | 29 | # Minimum version of the Windows PowerShell host required by this module 30 | PowerShellHostVersion = '1.2' 31 | 32 | # Minimum version of the .NET Framework required by this module 33 | DotNetFrameworkVersion = '4.0' 34 | 35 | # Minimum version of the common language runtime (CLR) required by this module 36 | CLRVersion = '' 37 | 38 | # Processor architecture (None, X86, Amd64, IA64) required by this module 39 | ProcessorArchitecture = '' 40 | 41 | # Modules that must be imported into the global environment prior to importing this module 42 | RequiredModules = @() 43 | 44 | # Assemblies that must be loaded prior to importing this module 45 | RequiredAssemblies = @() 46 | 47 | # Script files (.ps1) that are run in the caller's environment prior to importing this module 48 | ScriptsToProcess = @() 49 | 50 | # Type files (.ps1xml) to be loaded when importing this module 51 | TypesToProcess = @() 52 | 53 | # Format files (.ps1xml) to be loaded when importing this module 54 | FormatsToProcess = @() 55 | 56 | # Modules to import as nested modules of the module specified in ModuleToProcess 57 | NestedModules = @() 58 | 59 | # Functions to export from this module 60 | FunctionsToExport = '*' 61 | 62 | # Cmdlets to export from this module 63 | CmdletsToExport = '' 64 | 65 | # Variables to export from this module 66 | VariablesToExport = '*' 67 | 68 | # Aliases to export from this module 69 | AliasesToExport = '' 70 | 71 | # List of all modules packaged with this module 72 | ModuleList = @() 73 | 74 | # List of all files packaged with this module 75 | FileList = @() 76 | 77 | # Private data to pass to the module specified in ModuleToProcess 78 | PrivateData = '' 79 | } 80 | -------------------------------------------------------------------------------- /FluentMigrator.psm1: -------------------------------------------------------------------------------- 1 | function Add-FluentMigration 2 | { 3 | [CmdletBinding(DefaultParameterSetName = 'Name')] 4 | param ( 5 | [parameter(Position = 0, 6 | Mandatory = $true)] 7 | [string] $Name, 8 | [string] $ProjectName, 9 | [switch] $AddTimeStampToClassName) 10 | $timestamp = (Get-Date -Format yyyyMMddHHmmss) 11 | $class_name_timestamp = (Get-Date -Format yyyyMMdd_HHmmss) 12 | 13 | if ($ProjectName) { 14 | $project = Get-Project $ProjectName 15 | if ($project -is [array]) 16 | { 17 | throw "More than one project '$ProjectName' was found. Please specify the full name of the one to use." 18 | } 19 | } 20 | else { 21 | $project = Get-Project 22 | } 23 | 24 | # if the $name parameter contains a string '{T}', then replace it with the timestamp but with a underscore between the 25 | # yyyyMMdd part and the HHmmss part 26 | if ($AddTimeStampToClassName) { 27 | $name = [System.String]::Replace($name, "{T}", $class_name_timestamp) 28 | } 29 | 30 | $namespace = $project.Properties.Item("DefaultNamespace").Value.ToString() + ".Migrations" 31 | $projectPath = [System.IO.Path]::GetDirectoryName($project.FullName) 32 | $migrationsPath = [System.IO.Path]::Combine($projectPath, "Migrations") 33 | $outputPath = [System.IO.Path]::Combine($migrationsPath, "$timestamp" + "_$name.cs") 34 | 35 | if (-not (Test-Path $migrationsPath)) 36 | { 37 | [System.IO.Directory]::CreateDirectory($migrationsPath) 38 | } 39 | 40 | "using FluentMigrator; 41 | 42 | namespace $namespace 43 | { 44 | [Migration($timestamp)] 45 | public class $name : Migration 46 | { 47 | public override void Up() 48 | { 49 | } 50 | 51 | public override void Down() 52 | { 53 | } 54 | } 55 | }" | Out-File -Encoding "UTF8" -Force $outputPath 56 | 57 | $project.ProjectItems.AddFromFile($outputPath) 58 | $project.Save($null) 59 | } 60 | 61 | Export-ModuleMember @( 'Add-FluentMigration' ) 62 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2018 Ritter Insurance Marketing, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FluentMigrator.Generator 2 | 3 | [FluentMigrator](https://github.com/schambers/fluentmigrator) is a SQL migration framework designed to help version an application's database. This package allows a developer to quickly create a new migration from within Visual Studio's Package Manager console. 4 | 5 | A few notable features: 6 | 7 | - Timestamp generation 8 | - Migration file named correctly with timestamp 9 | - Migration added to `Migrations` folder under current active project 10 | 11 | It couldn't be easier! 12 | 13 | ## Getting Started 14 | 15 | ```console 16 | PM > Install-Package FluentMigrator.Generator 17 | ``` 18 | 19 | Once installed, open the `Package Manager Console` in Visual Studio. To get there, go to `View > Other Windows > Package Manager Console`. **Remember to select the active project via the `Default Project` dropdown.** 20 | 21 | In the new window, type `Add-FluentMigration` followed by the name of your migration. 22 | 23 | ```console 24 | Add-FluentMigration InitialMigration 25 | ``` 26 | 27 | You should see the following structure in the `Default Project` project. 28 | 29 | ``` 30 | ConsoleApplication1 31 | |- /Migrations 32 | |- 20160219141436_InitialMigration.cs 33 | ``` 34 | 35 | The migration file contents should look like the following. 36 | 37 | ```csharp 38 | using FluentMigrator; 39 | 40 | namespace ConsoleApplication1.Migrations 41 | { 42 | [Migration(20160219141436)] 43 | public class InitialMigration : Migration 44 | { 45 | public override void Up() 46 | { 47 | } 48 | 49 | public override void Down() 50 | { 51 | } 52 | } 53 | } 54 | ``` 55 | 56 | Fill in the migration appropriately. -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | 3 | cache: 4 | - tools -> build.cake 5 | 6 | build_script: 7 | - ps: ./build.ps1 8 | 9 | test: off 10 | 11 | artifacts: 12 | - path: ./artifacts/*.nupkg 13 | 14 | deploy: 15 | - provider: Environment 16 | name: NuGet 17 | on: 18 | branch: master 19 | -------------------------------------------------------------------------------- /build.cake: -------------------------------------------------------------------------------- 1 | var target = Argument("target", "Default"); 2 | 3 | var artifactsDir = Directory("./artifacts"); 4 | 5 | Task("Clean") 6 | .Does(() => 7 | { 8 | CleanDirectory(artifactsDir); 9 | }); 10 | 11 | Task("Package") 12 | .IsDependentOn("Clean") 13 | .Does(() => 14 | { 15 | NuGetPack("./FluentMigrator.Generator.nuspec", new NuGetPackSettings 16 | { 17 | OutputDirectory = artifactsDir, 18 | }); 19 | }); 20 | 21 | Task("Default") 22 | .IsDependentOn("Package"); 23 | 24 | RunTarget(target); 25 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | powershell -ExecutionPolicy Unrestricted -File build.ps1 4 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This is the Cake bootstrapper script for PowerShell. 3 | # This file was downloaded from https://github.com/cake-build/resources 4 | # Feel free to change this file to fit your needs. 5 | ########################################################################## 6 | 7 | <# 8 | 9 | .SYNOPSIS 10 | This is a Powershell script to bootstrap a Cake build. 11 | 12 | .DESCRIPTION 13 | This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) 14 | and execute your Cake build script with the parameters you provide. 15 | 16 | .PARAMETER Script 17 | The build script to execute. 18 | .PARAMETER Target 19 | The build script target to run. 20 | .PARAMETER Configuration 21 | The build configuration to use. 22 | .PARAMETER Verbosity 23 | Specifies the amount of information to be displayed. 24 | .PARAMETER ShowDescription 25 | Shows description about tasks. 26 | .PARAMETER DryRun 27 | Performs a dry run. 28 | .PARAMETER Experimental 29 | Uses the nightly builds of the Roslyn script engine. 30 | .PARAMETER Mono 31 | Uses the Mono Compiler rather than the Roslyn script engine. 32 | .PARAMETER SkipToolPackageRestore 33 | Skips restoring of packages. 34 | .PARAMETER ScriptArgs 35 | Remaining arguments are added here. 36 | 37 | .LINK 38 | https://cakebuild.net 39 | 40 | #> 41 | 42 | [CmdletBinding()] 43 | Param( 44 | [string]$Script = "build.cake", 45 | [string]$Target, 46 | [string]$Configuration, 47 | [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] 48 | [string]$Verbosity, 49 | [switch]$ShowDescription, 50 | [Alias("WhatIf", "Noop")] 51 | [switch]$DryRun, 52 | [switch]$Experimental, 53 | [switch]$Mono, 54 | [switch]$SkipToolPackageRestore, 55 | [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] 56 | [string[]]$ScriptArgs 57 | ) 58 | 59 | [Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null 60 | function MD5HashFile([string] $filePath) 61 | { 62 | if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) 63 | { 64 | return $null 65 | } 66 | 67 | [System.IO.Stream] $file = $null; 68 | [System.Security.Cryptography.MD5] $md5 = $null; 69 | try 70 | { 71 | $md5 = [System.Security.Cryptography.MD5]::Create() 72 | $file = [System.IO.File]::OpenRead($filePath) 73 | return [System.BitConverter]::ToString($md5.ComputeHash($file)) 74 | } 75 | finally 76 | { 77 | if ($file -ne $null) 78 | { 79 | $file.Dispose() 80 | } 81 | } 82 | } 83 | 84 | function GetProxyEnabledWebClient 85 | { 86 | $wc = New-Object System.Net.WebClient 87 | $proxy = [System.Net.WebRequest]::GetSystemWebProxy() 88 | $proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials 89 | $wc.Proxy = $proxy 90 | return $wc 91 | } 92 | 93 | Write-Host "Preparing to run build script..." 94 | 95 | if(!$PSScriptRoot){ 96 | $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent 97 | } 98 | 99 | $TOOLS_DIR = Join-Path $PSScriptRoot "tools" 100 | $ADDINS_DIR = Join-Path $TOOLS_DIR "Addins" 101 | $MODULES_DIR = Join-Path $TOOLS_DIR "Modules" 102 | $NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" 103 | $CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" 104 | $NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" 105 | $PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" 106 | $PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" 107 | $ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" 108 | $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" 109 | 110 | # Make sure tools folder exists 111 | if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { 112 | Write-Verbose -Message "Creating tools directory..." 113 | New-Item -Path $TOOLS_DIR -Type directory | out-null 114 | } 115 | 116 | # Make sure that packages.config exist. 117 | if (!(Test-Path $PACKAGES_CONFIG)) { 118 | Write-Verbose -Message "Downloading packages.config..." 119 | try { 120 | $wc = GetProxyEnabledWebClient 121 | $wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) 122 | } catch { 123 | Throw "Could not download packages.config." 124 | } 125 | } 126 | 127 | # Try find NuGet.exe in path if not exists 128 | if (!(Test-Path $NUGET_EXE)) { 129 | Write-Verbose -Message "Trying to find nuget.exe in PATH..." 130 | $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } 131 | $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 132 | if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { 133 | Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." 134 | $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName 135 | } 136 | } 137 | 138 | # Try download NuGet.exe if not exists 139 | if (!(Test-Path $NUGET_EXE)) { 140 | Write-Verbose -Message "Downloading NuGet.exe..." 141 | try { 142 | $wc = GetProxyEnabledWebClient 143 | $wc.DownloadFile($NUGET_URL, $NUGET_EXE) 144 | } catch { 145 | Throw "Could not download NuGet.exe." 146 | } 147 | } 148 | 149 | # Save nuget.exe path to environment to be available to child processed 150 | $ENV:NUGET_EXE = $NUGET_EXE 151 | 152 | # Restore tools from NuGet? 153 | if(-Not $SkipToolPackageRestore.IsPresent) { 154 | Push-Location 155 | Set-Location $TOOLS_DIR 156 | 157 | # Check for changes in packages.config and remove installed tools if true. 158 | [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) 159 | if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or 160 | ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { 161 | Write-Verbose -Message "Missing or changed package.config hash..." 162 | Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery | 163 | Remove-Item -Recurse 164 | } 165 | 166 | Write-Verbose -Message "Restoring tools from NuGet..." 167 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" 168 | 169 | if ($LASTEXITCODE -ne 0) { 170 | Throw "An error occurred while restoring NuGet tools." 171 | } 172 | else 173 | { 174 | $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" 175 | } 176 | Write-Verbose -Message ($NuGetOutput | out-string) 177 | 178 | Pop-Location 179 | } 180 | 181 | # Restore addins from NuGet 182 | if (Test-Path $ADDINS_PACKAGES_CONFIG) { 183 | Push-Location 184 | Set-Location $ADDINS_DIR 185 | 186 | Write-Verbose -Message "Restoring addins from NuGet..." 187 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" 188 | 189 | if ($LASTEXITCODE -ne 0) { 190 | Throw "An error occurred while restoring NuGet addins." 191 | } 192 | 193 | Write-Verbose -Message ($NuGetOutput | out-string) 194 | 195 | Pop-Location 196 | } 197 | 198 | # Restore modules from NuGet 199 | if (Test-Path $MODULES_PACKAGES_CONFIG) { 200 | Push-Location 201 | Set-Location $MODULES_DIR 202 | 203 | Write-Verbose -Message "Restoring modules from NuGet..." 204 | $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" 205 | 206 | if ($LASTEXITCODE -ne 0) { 207 | Throw "An error occurred while restoring NuGet modules." 208 | } 209 | 210 | Write-Verbose -Message ($NuGetOutput | out-string) 211 | 212 | Pop-Location 213 | } 214 | 215 | # Make sure that Cake has been installed. 216 | if (!(Test-Path $CAKE_EXE)) { 217 | Throw "Could not find Cake.exe at $CAKE_EXE" 218 | } 219 | 220 | 221 | 222 | # Build Cake arguments 223 | $cakeArguments = @("$Script"); 224 | if ($Target) { $cakeArguments += "-target=$Target" } 225 | if ($Configuration) { $cakeArguments += "-configuration=$Configuration" } 226 | if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" } 227 | if ($ShowDescription) { $cakeArguments += "-showdescription" } 228 | if ($DryRun) { $cakeArguments += "-dryrun" } 229 | if ($Experimental) { $cakeArguments += "-experimental" } 230 | if ($Mono) { $cakeArguments += "-mono" } 231 | $cakeArguments += $ScriptArgs 232 | 233 | # Start Cake 234 | Write-Host "Running build script..." 235 | &$CAKE_EXE $cakeArguments 236 | exit $LASTEXITCODE 237 | -------------------------------------------------------------------------------- /init.ps1: -------------------------------------------------------------------------------- 1 | param($installPath, $toolsPath, $package) 2 | 3 | if (Get-Module | ?{ $_.Name -eq "FluentMigrator" }) 4 | { 5 | Remove-Module FluentMigrator 6 | } 7 | 8 | Import-Module (Join-Path $toolsPath "FluentMigrator.psd1") 9 | --------------------------------------------------------------------------------