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
Download ConfigureEnvironment.zip.
Extract the contents into C:\Users\[User]\Documents\WindowsPowerShell\modules\ConfigureEnvironment
or a location relative to your project.
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.
Save-Module -Name ConfigureEnvironment -Path <path>
Install-Module -Name ConfigureEnvironment -Scope CurrentUser
See the PowerShell Gallery for the complete details and instructions.
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.
- Create a DNX project (see included Example)
- Install the ASP.NET 5 Scripts Task Runner by Mads Kristensen to enable DNX Script discovery
- 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.