Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy an ASP.NET 5 Aurelia app to Azure from VS2015

I'm trying to deploy an Aurelia application based on the ASP.NET 5 ES2016 navigation skeleton to Microsoft Azure using Web Deploy ([right-click] -> publish) from within Visual Studio 2015.

But I can't get the depolyment to work.

I've changed the prepublish settings in the project.json file to:

"prepublish": [ "npm install", "gulp bundle" ]

but this only makes the Publish process fail within Visual Studio. Running gulp bundle from the console works fine.

So my next attempt has been to remove all prepublish tasks, run gulp bundle manually and then publish. This allows the publish process to complete, but the web application on azure never loads and end up giving me a timeout.

Thinking that it might have something to do with the jspm_packages folder I've tried including those in the Web.xproj file based on this github thread, but this results in the following error:

502 - Web server received an invalid response while acting as a gateway or proxy server.

Update

I've tried setting the prepublish scripts back and running dnu publish from the console. That runs without a problem ad generates all the necessary output in the \bin\output\wwwroot folder. This same process fail however when run from the Publish contect-menu action in Visual Studio; no output is generated.

Just adding it here in case it sheds some light into the issue.

Update 2

Ok, I noticed that the dnu publish command's closing message is

Using command 'web' as entry point for web.config

And then a penny dropped. The Aurelia Skeleton Navigation solution defines the following command in `project.json:

"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:9000/",

which of course will not work in Azure. So, I removed the --server.urls options, removed prepublish scripts again form the project.json and lo and behold, the app runs...

...unbundled.

Anyhow, a lot has changed since starting to type this question, but I am still wondering:

  1. Why does publishing fail from Visual Studio when I have prepublish tasks defined?

  2. Most importantly, how can I publish a bundled Aurelia app to azure?

Update 3

The bundling works when runt from the console apparently. I think I never tried publishing the bundled app after removing the --server.urls setting from project.json.

So where are we at?

Publishing to Azure with "prepublish": [ "gulp bundle" ] still fails. This is the gulpfile.js that comes with the Aurelia Navigation Skeleton:

require('require-dir')('build/tasks');

And Visual Studio throws an error on the following line of watch.js when running prepublish tasks:

console.log(`File ${event.path} was ${event.type}, running tasks...`);  

Which is quite incomprehensible because the bundle task does not call watch. Ever. And running gulp bundle from the console works as expected.

So it looks like VS2015 is loading every task from the build/tasks folder. I've tried commenting out the watch.js file completely, but then I only the the following error: prepublish failed with code 1.

Any help or ideas on why I can't Publish with prepublish tasks would be much appreciated.

like image 845
Sergi Papaseit Avatar asked Mar 31 '16 13:03

Sergi Papaseit


People also ask

How do I publish a Visual Studio code to Azure?

Right-click on the project in Solution Explorer and select Publish. In the Publish dialog: Select Azure. Select Next.


1 Answers

To publish the Aurelia ASP.NET 5 ES2016 navigation skeleton to Azure with Web Deploy (Right-click > publish), we must make two changes to project.json.

Add a prepublish entry that will install NPM dependencies (otherwise gulp with fail), install JSPM packages, and bundle with gulp.

"prepublish": [ "npm install", "jspm install -y", "gulp bundle" ]

Delete --server.urls=http://*:9000/ from the web command, because that address is not supported in Azure. This is the correct entry:

"web": "Microsoft.AspNet.Server.Kestrel"

With those two changes, Web Deploy is working to both local IIS and to an Azure Web App using Visual Studio Community 2015 Update 2.

like image 154
Shaun Luttin Avatar answered Oct 13 '22 00:10

Shaun Luttin