Konda.eu

Tag Archives: dnvm

No comments

ASP.NET 5 install and build script

I really like ASP.NET 5, but hate it when I'm left without Visual Studio to deploy it or am doing continuous integration from Visual Studio Team Services or other tools (such as vscode). To ease my pain I came up with a simple powershell script that does everything for me. By everything I mean install dot net execution environment, install required packages for selected project, build it and publish it.

# bootstrap DNVM into this session.
&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}

# load up the global.json so we can find the DNX version
$globalJson = Get-Content -Path $PSScriptRoot\global.json -Raw -ErrorAction Ignore | ConvertFrom-Json -ErrorAction Ignore

if($globalJson)
{
    $dnxVersion = $globalJson.sdk.version
}
else
{
    Write-Warning "Unable to locate global.json to determine using 'latest'"
    $dnxVersion = "latest"
}

# install DNX
# only installs the default (x86, clr) runtime of the framework.
# If you need additional architectures or runtimes you should add additional calls
# ex: & $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -r coreclr
& $env:USERPROFILE\.dnx\bin\dnvm install $dnxVersion -Persistent

 # run DNU restore on all project.json files in the src folder including 2>1 to redirect stderr to stdout for badly behaved tools
Get-ChildItem -Path $PSScriptRoot\src -Filter project.json -Recurse | ForEach-Object { & dnu restore $_.FullName 2>1 }

# Restore packages
dnu restore

# Build to check for errors
dnu build

# Pack 
dnu publish --runtime active

Usage, extremely simple. Open powershell and run it!