Asp.Net Core 3.1 App sets the wrong runtimeOptions - .net-core-3.1

I am developing a quick ASP.Net Core 3.1 app, and trying to push it to a Free Linux-hosted WebApp in Azure.
The app builds, runs locally, and deploys to a docker environment in Windows Azure. All the files are deployed as expected.
The challenge is this:
Upon starting the app using the command
dotnet <mywebproject>.dll
The log tells me this:
The framework 'Microsoft.WindowsDesktop.App', version '3.1.0' was not found.
First thing to check was to see if there was a missing runtime
root#4182491:~/site/wwwroot# dotnet --list-runtimes
Microsoft.AspNetCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
After some fondling, I see that there is a file named .runtimeconfig.json:
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"frameworks": [
{
"name": "Microsoft.WindowsDesktop.App",
"version": "3.1.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
}
],
"configProperties": {
"System.GC.Server": true
}
}
}
So the runtime I need is there, but dotnet does not want to select it!
From the error, I am assuming that dotnet is attempting to start the website using the first framework that it can see, however how do I get rid of it during build? I've looked up how these files get generated during build, and can see no options to prevent a framework from being put into the runtimeOptions file.
Since I am building the app using Azure DevOps, I can't simply edit the file manually and upload it to the hosted linux container that it runs in.
So I need help with either:
How to build the project and EXCLUDE "Microsoft.WindowsDesktop.App" from the list of frameworks being generated
How to START the application in the linux container with a specific target framework NAME (I can only choose version from the settings I see in dotnet exec using SSL to the container.
This is more or less driving me nuts!

I am going to answer this one myself, since I found the solution after way too much coffee:
Turns out that the options you see here:
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"frameworks": [
{
"name": "Microsoft.WindowsDesktop.App",
"version": "3.1.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
}
],
"configProperties": {
"System.GC.Server": true
}
}
}
Aren't options at all, but requirements. I found a dependency on a package designed for WPF that of course requires the Microsoft.WindowsDesktop.App runtime to be installed. Since I'm developing on a windows computer, the code had all the necessary runtimes to run in debug, but not on linux.
I'll close this for now, but since the naming led to confusion, I will leave the question up in case someone else runs into the same confusion that I did.

Related

How to automatically change lambda layer version in zappa_settings.json file while publishing a new lambda layer version?

I have a lambda layer set up, and a shell file that deploys it. I have written github workflows that triggers this shell file whenever there's a change in code in that particular repository. Since a newer version is published, I would like to change the lambda-layer-version to change in zappa-settings.json. Is there a way to automate this, or will I have to manually do it everytime?
Here's my zappa-settings.json file:
{
"dev": {
"app_function": "app.app",
"profile_name": "zappa-dev",
"project_name": "zappa-app",
"runtime": "python3.8",
"s3_bucket": "zappa-app-dev",
"aws_region": "ap-south-1",
"slim_handler": true,
"layers": ["arn:aws:lambda:ap-south-1:594519763223:layer:testapp-lambda-layer:2"]
}
}
Over here, I would like to change '2' to the latest version. I have tried using $LATEST, but it throws regex error.
It seems zappa code in https://github.com/zappa/Zappa passes this value directly to boto3 client's create_function method. So the issue is with specifying latest layer version in AWS itself.
It can be manually updated by fetching list of versions and selecting the first result, like here:
https://stackoverflow.com/a/55752188/3014044

Automatically add addon from app.json, heroku.yml or other config

I would like to provide a button from github to directly deploy an app.
Its a go application which serves some website.
Now for persistent data it requires an addon "Heroku Postgres".
I tried defining a heroku.yml with:
setup:
addons:
- plan: heroku-postgresql
I tried app.json with:
{
"addons": ["heroku-postgresql:hobby-dev"]
}
But it does nothing at all, it never adds the addon. I know I can add it manually through the website or CLI, but I want a fully automatic way - if that is possible.
It should look something like this
"addons": [
{
"plan": "heroku-postgresql",
"options": {
"version": "12"
}
}
]
Example app.json from heroku

.NET Core MVC Bundling - Is there an equivalent to System.Web.Optimization.BundleTable.EnableOptimizations = false in ASP.NET MVC Core?

I want to run my application in debug mode without any bundling or minification. In ASP.NET MVC (Framework), I could use System.Web.Optimization.BundleTable.EnableOptimizations = false and the paths to the source files were output individually.
Is there anyway to achieve the same effect in .NET Core
Alternatively, the capability to trigger bundling on file save would help as well.
There is a nuget package manager for Dotnet core available in the following url:
Nuget
Using Package Manager: Install-Package DotFramework.Core.Web.Optimization -Version 3.12.0
Using CLI: dotnet add package DotFramework.Core.Web.Optimization --version 3.12.0
You could create a bundleconfig.json file, something like this:
[
{
"outputFileName": "wwwroot/css/site.min.css",
"inputFiles": [
"wwwroot/css/site.css"
]
},
{
"outputFileName": "wwwroot/js/site.min.js",
"inputFiles": [
"wwwroot/js/site.js"
],
"minify": {
"enabled": true,
"renameLocals": true
},
"sourceMap": false
}
]
I m not completely sure about this but its probably possible set different configurations of the bundle depending on the environment.
For more details follow this tutorial:
https://learn.microsoft.com/en-us/aspnet/core/client-side/bundling-and-minification?view=aspnetcore-2.2&tabs=visual-studio
Or
If you are referring to the bundles, scripts etc in your layout view to only run in specific modes, again this can be configured to run only in certain environments.

"Error detecting buildpack" during Heroku CI Test Setup

All,
Attempting to use Heroku's new-ish Continuous Integration service but it doesn't appear to want to play well with its own framework.
I've setup my Heroku Pipeline as outlined in the CI article: https://devcenter.heroku.com/articles/heroku-ci#configuration-using-app-json.
My deployments to review apps work correctly.
But my CI tests error with the following
app.json
"buildpacks": [
{ "url": "heroku/jvm" },
{ "url": "heroku/nodejs" }
],
Results in
$ heroku ci:debug --pipeline mypipelinename
Preparing source... done
Creating test run... done
Running setup and attaching to test dyno...
~ $ ci setup && eval $(ci env)
-----> Fetching heroku/jvm buildpack...
error downloading buildpack
I'm using the JVM buildpack so that I may install liquibase which manages version control for my Postgresql DB, but I'm actually deploying a NodeJs app.
Why would my "Review App"s deploy without problems but die during "Test Setup"?
I managed to get past this by using the github url for the node buildpack
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-nodejs"
}
],
I imagine it will work the same for jvm

Error: the template "phonegap-template-push" was not found

I have Cordova 5.0.0, and PhoneGap CLI 5.0.0-0.27.1, and I'm on a Mac OS X 10.10.5. I've been attempting to follow the directions of http://docs.phonegap.com/develop/push-notifications/ but every time I put in the first command phonegap create CLIMobile --template phonegap-template-push it kicks back to me with the error: [error] the template "phonegap-template-push" was not found
I've repeated the same steps at my home computer which is windows 10, and it worked fine.
Help?
I found your recent unanswered question because I was searching for a solution to this exact error. Apparently we are the only two people to encounter it. I just figured out a solution, so here it is.
First, you need to open up the package.json file in your phonegap installation, which is probably at /usr/local/lib/node_modules/phonegap/. Once you've opened that up (for editing), scroll down until you see the templates section.
This is where PhoneGap is referencing it's template list. Notice the template you are trying to use isn't listed. You'll need to add it and point to where PhoneGap can find it.
Below is an example of what that section should look like after you've done that.
"templates": {
"blank": {
"description": "A blank and empty PhoneGap app.",
"url": "https://github.com/phonegap/phonegap-app-blank/archive/master.tar.gz"
},
"hello-world": {
"description": "Default hello world app for PhoneGap.",
"url": "https://github.com/phonegap/phonegap-app-hello-world/archive/master.tar.gz"
},
"hello-cordova": {
"description": "Default hello world app for Cordova.",
"url": "https://github.com/apache/cordova-app-hello-world/archive/master.tar.gz"
},
"jquery-mobile-starter": {
"description": "Starter PhoneGap project using jQuery Mobile.",
"url": "https://github.com/cfjedimaster/jQuery-Mobile-Starter/archive/master.tar.gz"
},
"phonegap-template-push": {
"description": "phonegap-template-push",
"url": "https://github.com/phonegap/phonegap-template-push/archive/master.tar.gz"
}
},
Save and close that, then retry the command:
phonegap create myApp --template phonegap-template-push
Hopefully you will see this output:
Downloading phonegap-template-push-template library for www...
Download complete

Resources