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.
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.
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:
Why does publishing fail from Visual Studio when I have prepublish
tasks defined?
Most importantly, how can I publish a bundled Aurelia app to azure?
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
.
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.
Right-click on the project in Solution Explorer and select Publish. In the Publish dialog: Select Azure. Select Next.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With