gpt4 book ai didi

c# - 如何将 .NET Core 项目部署到 Windows Server 2012 R2

转载 作者:行者123 更新时间:2023-12-02 09:36:58 25 4
gpt4 key购买 nike

我将 .NET Core 项目部署到 Windows Server 2012 R2 64 位,并且发生了这种情况:

enter image description hereHTTP Error 502.5 - Process Failure 根据 Microsoft 指南,他们说这是因为平台与 RID 冲突。

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

我已经完成了该指南中的每一步,但无法修复它。那么有人知道如何解决这个问题吗?如果您能的话,我将不胜感激。谢谢。

注意:我已经授予了发布文件夹完全权限,并且还安装了 ASPNetCoreModule v2.0、net core sdk 2.0。我的IIS版本是8.5。

这是我的 .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>

构建后的 web.config:

<?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-->

我遇到了这个:IIS fails to run ASP.NET Core site - HTTP Error 502.5

似乎正是我的问题。但我在任何地方都找不到 .exe 文件

最佳答案

有些人可能会从我所做的以下步骤中获得帮助。

确保(在 Windows 服务器中托管 .net core 应用程序时):

  1. 启用 IIS
  2. 安装.net core SDK - 相应的包(2.0/2.1/etc)
  3. 安装.net core运行时 - 相应的包(2.0/2.1/etc)
  4. 安装.net core windows服务器托管 - 相应的软件包(2.0/2.1/etc)
  5. 安装与 Visual Studio 版本对应的 C++ 可再发行文件
  6. 在inetpub/wwwroot/下创建文件夹
  7. 将您发布的文件粘贴到该文件夹​​中
  8. 在 IIS 中的默认网站下添加应用程序,并提供别名和物理路径。

就是这样。您可以使用项目的服务器 IP/别名浏览您的应用程序 http://192.168.100.10/samplesite

关于c# - 如何将 .NET Core 项目部署到 Windows Server 2012 R2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46722647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com