0
votes

I, have migrated from Asp.net core 1.x to 2.0. The application was working perfectly on 1.x with Azure Hosting. Now when I published the application I am getting an errors as

Errors Details

When I, check the Logs I am getting an errors as

Unhandled Exception: System.FormatException: The short switch '-argFile' is not defined in the switch mappings. at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at FalconWebsite.Program.BuildWebHost(String[] args) in D:\Ecommerce\FalconWebsite\FalconWebsite\Program.cs:line 14 at FalconWebsite.Program.Main(String[] args) in D:\Ecommerce\FalconWebsite\FalconWebsite\Program.cs:line 10

Here is my Program.cs file

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace FalconWebsite
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .Build();
    }


}

Web.config File

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
  Configure your application settings in appsettings.json. Learn more at https://go.microsoft.com/fwlink/?LinkId=786380

  <appSettings>
      appSettings in web.config is no longer used in ASP.NET Core, instead use appsettings.json
  </appSettings>
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="bin\IISSupport\VSIISExeLauncher.exe"  arguments="-argFile IISExeLauncherArgs.txt" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

I did, some research from these HTTP Error 502.5 - Process Failure asp.net core 2.0 https://github.com/aspnet/IISIntegration/issues/406 Asp.Net Core 2.0 on Azure results in a 502.5 https://github.com/dotnet/cli/issues/7741

From the link the solution was to remove arguments="-argFile IISExeLauncherArgs.txt" But this doesn't solve my problem and no new errors in the logs files.

xx.csproj file

<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
  </PropertyGroup>
  <PropertyGroup>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
  </PropertyGroup>
  <ItemGroup>
    <Compile Remove="node_modules\**" />
    <Compile Remove="wwwroot\node_modules\**" />
    <Content Remove="node_modules\**" />
    <Content Remove="wwwroot\node_modules\**" />
    <EmbeddedResource Remove="node_modules\**" />
    <EmbeddedResource Remove="wwwroot\node_modules\**" />
    <None Remove="node_modules\**" />
    <None Remove="wwwroot\node_modules\**" />
  </ItemGroup>
  <ItemGroup>
    <None Remove="Properties\PublishProfiles\FalconWebsite20170204094000 - Web Deploy.pubxml" />
    <None Remove="Properties\PublishProfiles\FalconWebsiteDev - Web Deploy.pubxml" />
    <None Remove="Properties\PublishProfiles\FeteBird - Web Deploy.pubxml" />
  </ItemGroup>
  <ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
</ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Areas\Admin\Controllers\" />
    <Folder Include="Areas\Admin\Views\Admin\" />
    <Folder Include="Properties\PublishProfiles\" />
    <Folder Include="Views\Account\" />
    <Folder Include="Views\Checkout\" />
    <Folder Include="wwwroot\app\" />
  </ItemGroup>

    <None Include="wwwroot\fonts\fontawesome-webfont.svg" />
    <None Include="wwwroot\fonts\fontawesome-webfont.woff2" />
    <None Include="wwwroot\js\KnockoutViewModel\CategoryViewModel.js" />
    <None Include="wwwroot\js\KnockoutViewModel\ItemColorsViewModel.js" />
    <None Include="wwwroot\js\KnockoutViewModel\ItemsViewModel.js" />
    <None Include="wwwroot\js\KnockoutViewModel\LoginAuthentication.js" />
    <None Include="wwwroot\js\KnockoutViewModel\SubCategoryTwoViewModel.js" />
    <None Include="wwwroot\js\KnockoutViewModel\SubCategoryViewModal.js" />
    <None Include="wwwroot\js\ProjectJquery\SingleItemJquery.js" />
    <None Include="wwwroot\js\site.js" />
    <None Include="wwwroot\js\site.min.js" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-colorpicker.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-colorpicker.min.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-theme.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap-theme.min.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\css\bootstrap.min.css.map" />
    <None Include="wwwroot\lib\bootstrap\dist\fonts\glyphicons-halflings-regular.svg" />
    <None Include="wwwroot\lib\bootstrap\dist\fonts\glyphicons-halflings-regular.woff2" />
    <None Include="wwwroot\lib\bootstrap\dist\js\bootstrap-colorpicker.min.js" />
    <None Include="wwwroot\lib\bootstrap\dist\js\bootstrap-select.min.js" />
    <None Include="wwwroot\lib\bootstrap\dist\js\bootstrap-toggle.min.js" />
    <None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.js" />
    <None Include="wwwroot\lib\bootstrap\dist\js\bootstrap.min.js" />
    <None Include="wwwroot\lib\bootstrap\dist\js\npm.js" />
    <None Include="wwwroot\lib\bootstrap\LICENSE" />
    <None Include="wwwroot\lib\Color\color_classifier.js" />
    <None Include="wwwroot\lib\Color\dataset.js" />
    <None Include="wwwroot\lib\googleMaterialDesignLite\material.min.js" />
    <None Include="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.js" />
    <None Include="wwwroot\lib\jquery-validation-unobtrusive\jquery.validate.unobtrusive.min.js" />
    <None Include="wwwroot\lib\jquery-validation\dist\additional-methods.js" />
    <None Include="wwwroot\lib\jquery-validation\dist\additional-methods.min.js" />
    <None Include="wwwroot\lib\jquery-validation\dist\jquery.validate.js" />
    <None Include="wwwroot\lib\jquery-validation\dist\jquery.validate.min.js" />
    <None Include="wwwroot\lib\jquery-validation\LICENSE.md" />
    <None Include="wwwroot\lib\jquery\dist\jquery.js" />
    <None Include="wwwroot\lib\jquery\dist\jquery.min.js" />
    <None Include="wwwroot\lib\jquery\dist\jquery.min.map" />
    <None Include="wwwroot\lib\jquery\dist\Jquerymask.js" />
    <None Include="wwwroot\lib\knockout\KnockoutFileUpload.js" />
    <None Include="wwwroot\lib\knockout\Knockoutv3.4.1.js" />
  </ItemGroup>
</Project>

I, am not able to solve this issue from 2 days. Can anyone please let me know whats wrongs.

1

1 Answers

1
votes

Can anyone please let me know whats wrongs

I assume that the issue is that with asp.net core 2.0, it does not do that anymore with 1.x do. As the DLL are picked up from a global store. However, Visual Studio does not clean the destination folder before a publish. So you could remove the addional files at destination.

enter image description here

Update:

In order to catch the detail exception on the azure, add the following code in the Startup.cs file.

enter image description here

After publish to azure then I got the following exception.

enter image description here

It seems a known issue and I resolve it by add the following code in the Startup.cs file

services.AddApplicationInsightsTelemetry(Configuration);

enter image description here