Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy .net core project to Windows Server 2012 r2

I deployed my .NET Core project to Windows Server 2012 R2 64-bit and this happened:

enter image description here HTTP Error 502.5 - Process Failure according to Microsoft guide, they said that it is because of platform conflicts with RID.

(https://learn.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x#common-errors)

I had already come through every step in that guide but can not fix it. So anyone knows how to fix this? I would be appreciated if you could. Thank you.

Note: I had already give publish folder full permission and also installed ASPNetCoreModule v2.0, net core sdk 2.0. My IIS version is 8.5.

Here is my .csproj:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RootNamespace>_MyAppAPI</RootNamespace>
    <AssemblyName>_MyAppAPI</AssemblyName>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile></DocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <Content Remove="wwwroot\swagger\authen\basic-auth.js" />
    <Content Remove="wwwroot\swagger\ui\custome.css" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="Middleware\" />
    <Folder Include="Logs\" />
    <Folder Include="Models\appapi\" />
    <Folder Include="wwwroot\lib\" />
    <Folder Include="wwwroot\logs\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
    <PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="wwwroot\swagger\authen\basic-auth.js" />
    <EmbeddedResource Include="wwwroot\swagger\ui\custome.css" />
  </ItemGroup>

</Project>

And web.config after build:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\_MyAppAPI.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>
<!--ProjectGuid: 2510f4bb-368b-4ab2-96e1-5d06b14d677e-->

I ran into this: IIS fails to run ASP.NET Core site - HTTP Error 502.5

Seem to be exactly my problem. But I cannot find an .exe file anywhere

like image 623
Truong Tran Avatar asked Oct 18 '22 04:10

Truong Tran


1 Answers

Some one may get help from following steps which i have done.

Ensure(while hosting .net core applications in windows server):

  1. Enable IIS
  2. install .net core SDK - corresponding package(2.0/2.1/etc)
  3. install .net core runtime - corresponding package(2.0/2.1/etc)
  4. install .net core windows server hosting - corresponding package(2.0/2.1/etc)
  5. install c++ redistributable file corresponding to visual studio version
  6. create folder under inetpub/wwwroot/
  7. paste your published files into that folder
  8. add application under your Default Website in IIS and give alias and physical path.

Thats it. you can browse your application using server ip/alias name of your project http://192.168.100.10/samplesite

like image 96
Aniyan Kolathur Avatar answered Oct 21 '22 00:10

Aniyan Kolathur