AspNetCore.deps.json including runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll reference - asp.net-core

I have been chasing an issue with a AspNetCore web api project running on an Azure app service for a few days.
Basically I have a very small api project that when deployed / started - I get a 500.30 ANCM error. Cryptic enough - I pulled the event log from the app service and I find this:
<Data>Could not find inprocess request handler.
Captured output from invoking hostfxr: Error:
An assembly specified in the application dependencies manifest
(SampleApp.Api.deps.json) was not found:
package: 'System.Data.SqlClient', version: '4.6.1'
path: 'runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll'
</Data>
Looking at the SampleApp.deps.json - sure enough I see this:
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.5.0.1",
"fileVersion": "4.6.27618.1"
},
"runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.5.0.1",
"fileVersion": "4.6.27618.1"
}
},
I have a similar (almost identical) project that is running fine on another app service. If run the
dotnet publish -c release /property:PublishWithAspNetCoreTargetManifest=true
(the same publish command I am running with the app I am having an issue with)
I do not see this section in the runtime targets section at all in the otherapp.deps.json file.
Where is this coming from and how do I get rid of it?

I had a similar situation
a aspnetcore webapp that worked
and a dotnet cli app that failed with an almost identical error as above
What worked for me was running dotnet publish cli-proj -r win-x64. This creates a self-contained bundle, which does not rely on any installed runtime. Then my deployment was taking all the files from bin/debug/netcoreapp3.1/win-x64/publish and pushing them to my webserver.
I'm sure the installed runtime is supposed to supply these files, but it doesn't seem to work well. This "fixed" my issue.

I had a similar issue, where most projects were .Net 5.0 and one class library was .NetStandard, upgrading the .NetStandard Library to .Net 5.0 fixed the issue.
I think the issue is re;ated to not having the correct runtimes for multiple platforms, ideally run with a single platform, or install all the required runtimes.

I forgot to publish the /runtime/ folder when I published on the iis server.

Just ran into the same issue. In my case, the publish profile had target runtime set to win-x64.
Changing this to portable got the publish command to generate the runtime directory and resolve the problem.

Related

Network calls not working in EXE distribution build of Compose for Desktop Application

I have used Ktor JVM Client for doing network calls in Compose for Desktop Application.
Network calls are working fine in Debug build means when I am just running the application it's working fine.
But when I create the EXE distribution file, by executing the packageExe task in Gradle, it's creating an EXE file. I have installed it on my machine. Then I am running the application and I am seeing that network calls are not working. I have checked internet is working properly.
Please provide a solution to fix this issue. Thanks in advance.
Your question doesn't leave any details about the failure type (compile error? runtime exception? Empty data? etc.).
But if I had to speculate based on such limited information, I'd guess it's probably this: https://github.com/JetBrains/compose-jb/issues/429
Specifically, when packaging, you need to specify which JVM modules you want to be packed into your distributable app, and likely you are missing your crypto module. Try something like this:
compose.desktop {
application {
mainClass = "MainKt"
nativeDistributions {
modules("jdk.crypto.ec")
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "untitled"
}
}
}

SpaTemplate angular - Publish to Azure - Error: Cannot find module 'aspnet-webpack'

I use the asp.net core angular spatemplate. The project is running without problems on my local machine. However, when I publish it to azure I run into an internal server error.
After setting the aspnetcore_environment to development in the azure portal, I can see a the error:
Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
I found some hints here https://github.com/sgbj/generator-aspnetcore-angular2/issues/23
Basically it says the node_modules folder is missing in the production environment. And it describes a way to add it manually to the project.json file. But the spatemplate didn't create such a file... it contains a classic *.proj
I am very new to web development and I don't know how to add the missing dependency to the proj file. And I am not sure if this is really the issue, because the sample I am following on the web https://channel9.msdn.com/events/Visual-Studio/Visual-Studio-2017-Launch/WEB-103 is not setting anything in this direction.
If I create a plain new project with
dotnet new angular
and I publish it everything works fine without any issues?! So I have the feeling I destroyed something in the solution?! Any idea?
My question is how can I set the node_modules for publishing?
In Startup.cs you probably have the below in Configure() method:
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
}
This enables hot module replacement with webpack. When you make a change and save a file, webpack automatically re compiles the angular app so your browser picks up the changes without you reloading the page. You don't want this functionality when publishing.
"env.IsDevelopment()" will check for an environment variable on your PC = ASPNETCORE_ENVIRONMENT=Development
In the app service, add an app setting like below:
Alternatively you could comment the hot module replacement out.
Finally I found a solution for this problem. I removed the Publish Profile in my VS2017 solution and to delete the related app service on Azure. After creating everything new again the publishing works well again. I hope this will never ever happen in production.

How to create an aurelia 1.0 app that can be deployed at any root location

I am trying to work out how to deploy an aurelia app, it runs in development with au run. but I need to deploy it into a path which is not the root of the web-site. ie at '/site' not '/'
when I deploy I get an exception from the router: ERROR [app-router] Error: Route not found: /site/
I think it may be that I need to specify a baseURL in one or more places?
but can't see how I can:
make it work in the development environment at /
make it work in the deployed environment at /[any-site-path]
avoid building in knowledge of '/[any-site-path]' to my development environment or bundles, as the path wont be known until someone comes to deploy the code?
i found this question but that seems to apply to an out of date version of the code.
I am using Aurelia 1.0 and building using the au-cli
Any pointers would be useful.
Looks like this is a bug that has been fixed in a more recent version.
I have just gone through and applied the latest versions of:
"aurelia-bootstrapper": "^1.0.0" -> "^2.1.1"
"aurelia-cli": "^0.24.0" -> "^0.26.1"
"aurelia-tools": "^0.2.2" -> "^1.0.0"
And i can now deploy my application to a site sub folder without specifying any url content in the code or html files!
So I can satisfy all 3 of the criteria in my question.
Note the aurelia-cli update (0.25.0) requires a change to the main.(ts/js) as mentioned in the release notes.

Deploy .Net Core as DLL to IIS - Failed to start process with commandline '"dotnet" site.dll'

I have a .Net Core web application targeting net461 Framework. It was originally producing an .EXE and working fine when deploying to IIS. I want to change to a portable app, so I changed "buildOptions" in ProjectJson as follows:
"buildOptions": {
"emitEntryPoint": false,
"preserveCompilationContext": true,
"debugType": "portable"
},
Now when I compile I get a DLL and it runs fine in IIS Express, but when I publish to IIS and change the web.config aspnetcore element to:
<aspNetCore processPath="dotnet" arguments=".\myWebApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false" />
The project fails to run and I see "Failed to start process with commandline '"dotnet" MyWebApp.dll', ErrorCode = '0x80004005'" in the application event log.
Attempting to run from command line with "dotnet mywebapp.dll" results in:
A fatal error was encountered. The library 'hostpolicy.dll' required to
execute the application was not found in 'C:\inetpub\wwwroot\ETimeCore2'.
So I found and copied hostpolicy.dll to the directory and now get:
Could not resolve CoreCLR path. For more details, enable tracing by setting
CORE HOST_TRACE environment variable to 1
I did set the CORE HOST_TRACE to 1 and got a verbose response of all the dlls being loaded with just that one error (above) at the end so it added no value.
Any idea what I am doing wrong?? I prefer a DLL to an EXE because to publish changes when an .EXE, you have to recycle the app pool first which is a real pain.
You cannot use dotnet mywebapp.dll if disable "emitEntryPoint".
emitEntryPoint indicates whether the project is a console application vs. a library. From sources:
if (framework.IsDesktop() && compilerOptions.EmitEntryPoint.GetValueOrDefault())
{
OutputExtension = FileNameSuffixes.DotNet.Exe;
}
In your case the framework.IsDesktop() is true, as your target framework is net461, that is .NET Framework , not .NET Core. That's way you get .exe as output if enable emitEntryPoint.
Actually error "The library 'hostpolicy.dll' required to execute the application was not found in " right now means the following (see http://github.com/dotnet/cli/issues/2859 issue):
dotnet.exe cannot find the entry point in mywebapp.dll

Worklight 6.2 common environment deployment issue since last fix pack : WL is not defined

I recently installed the latest Worklight fix pack update, and am now running v6.2.0.01.20141027-1531
Since that, I've noticed a blocking bug about my common environment deployment on the WL server.
Now when I deploy my app ("Run as > Build all environments" and then "Run on Worklight development server"), running my app in the "Preview as common resources" or in the iPad / Android mobile web environments give me the following Javascript error :
WL is not defined
When I inspect the source code, I realize that the "Worklight generated" Javascript source code is missing in the head tag. I'm supposed to see something like this :
<script>
// Define WL namespace.
var WL = WL ? WL : {};
/**
* WLClient configuration variables.
* Values are injected by the deployer that packs the gadget.
*/
WL.StaticAppProps = {
"APP_DISPLAY_NAME": "appname",
"APP_ID": "project",
"APP_SERVICES_URL": "\/project\/apps\/services\/",
"APP_VERSION": "1.0",
"ENVIRONMENT": "preview",
"LOGIN_DISPLAY_TYPE": "popup",
"LOGIN_POPUP_HEIGHT": 610,
"LOGIN_POPUP_WIDTH": 920,
"PREVIEW_ENVIRONMENT": "common",
"WORKLIGHT_PLATFORM_VERSION": "6.2.0.01.20141027-1531",
"WORKLIGHT_ROOT_URL": "\/project\/apps\/services\/api\/app\/common\/"
};
</script>
...but there's nothing like this in my page's source code (that's why the WL is not found).
Moreover, it does not include the worklight.js and wljq.js files that are supposed to be dynamically added during the build phase (as far as I know). My index.html content is "vanilla", and it explains why nothing works.
So I decided to check in the bin archives that are generated during the build phase. It happens that the app-common.wlapp archive contains the correctly generated source code, with all the Worklight generated stuff inside. It looks like something wrong is happening during the deployment step. I tried to import it manually in the WL Console, but it's unfortunately not working either (same result).
I did not manage to reproduce the problem creating a new project, it looks like it only happens after an update of Worklight to the latest fix pack version. Thus, it's complicated to provide a sample project.
NB : everything works fine once running on an actual device. Only the common environment is broken in my case. But a colleague of mine also noticed this issue for the other environments so... I'll let you know if I manage to reproduce it for the other environments.
Thank you for you help, please ask if you need more inputs from me.
You are not required to do "build all..." and then "run on...". That's just repeating the same step, as "Run on Worklight Development Server" means "build the project artifacts (.wlapp file, .war file) and then deploy them".
A vanilla index.html contains references to initoptions.js, main.js, main.css and messeages.js. You are kinda confusing in your wording as to what is expected and where is it expected.
Anyway, try the following:
Close Eclipse
Go to your tmp folder and delete the wlBuildResources folder
Open Eclipse and try the following two paths:
Right-click the app folder > Run As > Run on Worklight Developer Server > Open Worklight Console > preview as common web resources
Right-click the app folder > Run As > Preview
Tell me which of the two fails, if at all.