Skip to content

Commit

Permalink
Update ASP.NET docs #7
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonZiminSaritasa committed Aug 28, 2018
1 parent 7703d23 commit 00995c8
Showing 1 changed file with 173 additions and 2 deletions.
175 changes: 173 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,173 @@
# dotnet-deploy
Sample .NET projects and scripts to deploy them.
ASP.NET Deployment
==================

Set up Server
-------------

### Enable WinRM

Enable WinRM over HTTPS on server, generate certificate, add firewall rule:

```powershell
Install-PackageProvider NuGet -Force; Install-Module Saritasa.WinRM -Force; Install-WinrmHttps
```

More details: [WinRM Configuration](https://github.com/Saritasa/PSGallery/blob/master/docs/WinRMConfiguration.md)

### Trust Server

Add client to trusted certificate authorities list on build server or developer PC:

```powershell
Install-Module Saritasa.Web -Force
Import-TrustedSslCertificate web.saritasa.local 5986
```

### Configure Server

Edit `inventory.yml`. Set correct values:

- hostname
- deploy_username
- deploy_password
- ansible_username
- ansible_password

Execute Ansible playbook:

```sh
cd ansible
ansible-playbook -i inventory.yml web.yml -v
```

Scaffold Scripts
----------------

Install Yeoman.

```powershell
npm i -g yo
```

Install generator.

```powershell
npm i -g generator-psgallery
```

Go to project directory and run generator.

```powershell
yo psgallery
```

Choose following options:

```
? Where are project source files located (relative to BuildTasks.ps1)? ..\src
? Select all used project types: Web
? Is .NET Core used? No
? Do you need GitFlow helper tasks? No
? Do you need to run NUnit or xUnit tests? No
? Do you need admin tasks, remote management capabilities? No
? Select services which you want to control from PowerShell:
```

Execute suggested commands to update `.gitignore` and add scripts to Git stage. Edit generated `BuildTasks.ps1`, `PublishTasks.ps1` scripts.

Required Software
-----------------

You need following software installed:

- [Visual Studio 2017](https://www.visualstudio.com/downloads/)
- [psake](https://github.com/psake/psake)
- [Git](https://git-scm.com/)
- [GitVersion](https://gitversion.readthedocs.io/)
- [NuGet](https://www.nuget.org/)

You can easily install most software with Chocolatey package manager. To do that run `PowerShell` as administrator and type commands:

```
PS> iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
PS> choco install psake git gitversion.portable nuget.commandline
```

Build Project
-------------

Make sure you have [psake](https://chocolatey.org/packages/psake) task runner installed.

Copy `Config.Development.ps1.template` to `Config.Development.ps1`. Edit properties. Execute command in repository root:

```powershell
psake build
```

Clean
-----

Execute command to remove build artifacts and temporary files:

```powershell
psake clean
```

Publish
-------

### Development

Edit properties in `Config.Development.ps1`. Execute command:

```powershell
psake publish-web
```

### Staging

Edit properties in `Config.Staging.ps1`. Execute command:

```powershell
psake publish-web -properties "@{Environment='Staging'}"
```

### Production

Edit properties in `Config.Production.ps1`. Execute command:

```powershell
psake publish-web -properties "@{Environment='Production'}"
```

Add any additional properties.

You may use environment variable also:

```powershell
$env:Environment = 'Production'
psake publish-service
```

Use Secret Config
-----------------

### Local Run

Copy `SecretConfig.Production.ps1.template` somewhere. Edit properties. Execute command:

```powershell
$env:Environment = 'Production'
$env:SecretConfigPath = 'C:\Path\To\SecretConfig.Production.ps1'
psake publish-web
```

### Jenkins

Create a credential with **secret file** type. Add credential parameter to job with `SecretConfig` name. Add following code to pipeline:

```groovy
environment {
SecretConfigPath = credentials("${env.SecretConfig}")
}
```

0 comments on commit 00995c8

Please sign in to comment.