Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

A PowerShell module that bootstraps your development environment to use Internet Information Servies (IIS), configurable with a terse script

License

Notifications You must be signed in to change notification settings

dennisroche/ConfigureEnvironment

Repository files navigation

Configure Environment Build status

A PowerShell module that bootstraps your development environment to use Internet Information Servies (IIS), configurable with a terse script

Example

As a WebSite

# Setup Environment
$BasePath = Resolve-Path "$PSScriptRoot\.."

Invoke-ConfigureWebEnvironment {

    $Website = @{
        HostName = "mysite.yourcompany.local"
        WebSiteName = "MyWebsite"
        WebSiteLocation = "$BasePath\src\MySite.Web"
        AppPool = "MyWebsite Local"
    }
    Add-WebSite @Website
    Add-LocalhostDnsEntryToHostsFile $($Website.HostName)
}

As a Web Application (includes parent site)

# Setup Environment
$BasePath = Resolve-Path "$PSScriptRoot\.."

Invoke-ConfigureWebEnvironment {

    $ApiLocal = @{
        HostName = "api-local.yourcompany.local"
        WebSiteName = "API Local"
        WebSiteLocation = "C:\inetpub\api-local"
        AppPool = "API Local"
    }
    Add-WebSite @ApiLocal
    Add-LocalhostDnsEntryToHostsFile $($ApiLocal.HostName)

    $ServiceApi = @{
        WebApplicationName = "Service"
        WebApplicationLocation = "$BasePath\src\Service.WebApi"
        AppPool = "API Local Service"
        ParentSite = "$($ApiLocal.WebSiteName)"
        EnableAnonymousAuthentication = "true"
        EnableWindowsAuthentication = "true"
    }
    Add-WebApplication @ServiceApi
}

If you need the script to self bootstrap, then add the following to the top.

Powershell v5

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name ConfigureEnvironment -Scope CurrentUser

GitHub Releases

if (-Not (Get-Module -ListAvailable -Name ConfigureEnvironment)) {
    iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/dennisroche/ConfigureEnvironment/master/Install.ps1'))
}

Import-Module ConfigureEnvironment -Force

Installation

Manual Install

Download ConfigureEnvironment.zip. Extract the contents into C:\Users\[User]\Documents\WindowsPowerShell\modules\ConfigureEnvironment or a location relative to your project.

Scripted Install

Open a PowerShell console or the PowerShell ISE and run the following:

iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/dennisroche/ConfigureEnvironment/master/Install.ps1'))

This will download the latest release from GitHub and unpack it in your PowerShell modules directory.

To run the above script, Execution Policy should be set to at least Bypass. See about_Execution_Policies for more details.

PowerShell Gallery Install (Requires PowerShell v5)

Save-Module -Name ConfigureEnvironment -Path <path>
Install-Module -Name ConfigureEnvironment -Scope CurrentUser

See the PowerShell Gallery for the complete details and instructions.

Autorun in Visual Studio

Want to automatically execute the environment script on project load in Visual Studio 2015?

This can be achieved using a combination of a DNX Project (i.e. new project.json format) and the Task Runner Explorer.

  1. Create a DNX project (see included Example)
  2. Install the ASP.NET 5 Scripts Task Runner by Mads Kristensen to enable DNX Script discovery
  3. Add a DNX Script to the project.json

Once you have DNX Scripts, you can use "Task Runner Explorer" View > Other Windows > Task Runner Explorer to bind a script to run at project load.

About

A PowerShell module that bootstraps your development environment to use Internet Information Servies (IIS), configurable with a terse script

Resources

License

Stars

Watchers

Forks

Packages

No packages published