ASP.NET 5 beta8, CI and Azure

This is the fourth post in a series about building Wedding Planner Tools Web App with ASP.NET 5, MVC 6 and Entity Framework 7. The previous post was about updating the project to use beta8 and the coreCLR runtime. This is the first post of the series.

I then tried to deploy to azure and see what happens (by pushing to VSO and letting the CI do it’s magic) and I got this error: The project being published does not support the run time ‘dnx-clr-win-x86.1.0.0-beta8’. This is apparently a known issue https://github.com/aspnet/Tooling/blob/master/known-issues.md. The workaround is to specifically set the target DNX version in the settings tab of the publish dialog. This helps with the problem when you publish from Visual Studio.

I then added the specific runtime and architecture int prebuild.ps1 file for dnvm install to ensure the correct sdk gets installed on the build agent vm. I wanted to remove the Visual Studio build step and replace it with executing dnu build as a command line step. The step was failing because of missing dnx. I then added -g to dnvm install to install it globally. https://github.com/aspnet/dnx/issues/2239 but this didn’t work either. It seems that changes to the path just aren’t carried over to the next execution step (this is weird but I don’t have the time to understand why it is so). So then I ran into this post and tried building and deploying via power shell script only in one step. I added the build and publish commands to Prebuild.ps1. http://www.brandonmartinez.com/2015/09/16/deploying-asp-net-5-beta-7-through-vso/. Power shell arguments for build step ended up looking like this:

-vsoProjectName "WeddingPlannerTools" -projectName "WeddingPlannerTools" -BuildConfiguration $(BuildConfiguration) -buildSourcesDirectory $(Build.SourcesDirectory)

Prebuild.ps1

param([string]$projectName="", [string]$BuildConfiguration="", [string]$vsoProjectName="", [string]$buildSourcesDirectory="")
# bootstrap DNVM into this session.
# 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
	$dnxRuntime = $globalJson.sdk.runtime
	$dnxArchitecture = $globalJson.sdk.architecture
}
else
{
    Write-Warning "Unable to locate global.json to determine using 'latest'"
    $dnxVersion = "latest"
	$dnxRuntime = "coreclr"
	$dnxArchitecture ="x86"
}

$env:DNX_HOME="$ENV:USERPROFILE\.dnx"
$env:DNX_GLOBAL_HOME="$ENV:USERPROFILE\.dnx"

# 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 -a $dnxArchitecture -r $dnxRuntime -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 }

& "dnu" "build" "$PSScriptRoot\src\$projectName" "--configuration" "$BuildConfiguration"
 
& "dnu" "publish" "$PSScriptRoot\src\$projectName" "--configuration" "$BuildConfiguration" "--out" "$buildSourcesDirectory\$vsoProjectName\artifacts\bin\$BuildConfiguration\Publish" "--runtime" "active"

Dnu publish is logging npm warnings as errors for some reason so I’ve set continue on error for this step for now. I just want to see it published!

npm WARN package.json ASP.NET@0.0.0 No description
npm WARN package.json ASP.NET@0.0.0 No repository field.
npm WARN package.json ASP.NET@0.0.0 No README data
npm WARN package.json ASP.NET@0.0.0 No license field.

This is how the build steps look on VSO:
Build steps

Finally follow this guide to make the up run on azure: https://github.com/aspnet/Hosting/issues/364#issuecomment-148567294, http://www.elanderson.net/2015/10/migration-from-asp-net-5-beta-7-to-beta-8/. With this changes you should be able o run the app in IISExpress also but for me it does not seem to work (HTTP Error 500.19 – Internal Server Error but I don’t have the energy to fight it:) ). It does however work in Azure! Success!
Success

links

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s