Ciao Riccardo,
ma tu sai per certo che ASP.NET Core può funzionare in hosting condiviso su Aruba?
A naso direi che non funzionerebbe lo stesso, neanche compilando per il .NET Framework 4.7. Infatti, su IIS sarebbe comunque necessario installare l'ASP.NET Core Module, in modo che le richieste vengano inoltrate a Kestrel. Ti hanno confermato che il modulo è installato?
Comunque, il vantaggio di usare .NET Core è che lo puoi distribuire insieme all'applicazione, quindi non devi dipendere da nessuno dato che non è necessario installarlo a livello di sistema. Il problema però sussiste: hai sempre bisogno che IIS avvii l'applicazione e inoltri le richieste a Kestrel, cosa che non può funzionare se manca il modulo di IIS per ASP.NET Core.
Comunque, per compilare l'applicazione usando .NET Framework, modifica il target in questo modo (in questo esempio uso la 471).
<TargetFramework>net471</TargetFramework>
E non puoi tenere il riferimento al pacchetto Microsoft.AspNetCore.App perché, come puoi vedere dalla
pagina Nuget, non è compilato per .NET Standard 2.0 ma per ".NETCoreApp 2.1".
Tuttavia, Microsoft.AspNetCore.App è solo un metapacchetto, quindi puoi toglierlo e referenziare invece tuuuuutti i pacchetti da cui dipende (o almeno quelli che usi).
Esempio:
<PackageReference Include="Microsoft.AspNet.WebApi.Client" />
<PackageReference Include="Microsoft.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.WsFederation" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" />
<PackageReference Include="Microsoft.AspNetCore.Authorization.Policy" />
<PackageReference Include="Microsoft.AspNetCore.Connections.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" />
<PackageReference Include="Microsoft.AspNetCore.Cors" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.Internal" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Extensions" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.HostFiltering" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Http" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Http.Connections" />
<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Common" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" />
<PackageReference Include="Microsoft.AspNetCore.Identity" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" />
<PackageReference Include="Microsoft.AspNetCore.Localization" />
<PackageReference Include="Microsoft.AspNetCore.Localization.Routing" />
<PackageReference Include="Microsoft.AspNetCore.MiddlewareAnalysis" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Analyzers" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ApiExplorer" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" />
<PackageReference Include="Microsoft.AspNetCore.NodeServices" />
<PackageReference Include="Microsoft.AspNetCore.Owin" />
<PackageReference Include="Microsoft.AspNetCore.Razor" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" />
<PackageReference Include="Microsoft.AspNetCore.Routing" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Server.HttpSys" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" />
<PackageReference Include="Microsoft.AspNetCore.Session" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Common" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.Json" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" />
<PackageReference Include="Microsoft.CodeAnalysis.Razor" />
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" />
<PackageReference Include="Microsoft.Extensions.Caching.SqlServer" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
<PackageReference Include="Microsoft.Extensions.Configuration.KeyPerFile" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" />
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Http" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" />
<PackageReference Include="Microsoft.Extensions.Localization" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" />
<PackageReference Include="Microsoft.Extensions.Logging.TraceSource" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Microsoft.Extensions.Primitives" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" />
<PackageReference Include="Microsoft.Net.Http.Headers" />
<PackageReference Include="System.IO.Pipelines" />
A questo punto io però ho avuto un problema nel metodo che restituisce il webhostbuilder. Sembra mancare l'extension method che costruisce il webhostbuilder di default. L'ho modificato così e a quel punto ha funzionato. Ovviamente tu costruisci il webhostbuilder secondo le tue esigenze.
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
new WebHostBuilder()
.UseKestrel()
.UseStartup<Startup>();
}
Onestamente non so perché l'hanno reso così complicato.
ciao,
Moreno
Modificato da BrightSoul il 13 novembre 2018 21.15 -