ASP.Net Core MVC 网站在Windows服务器跑不起来

1.vs远程发布到服务器,浏览器访问,报错502

2.打开错误提示提供的网址参考

3.安装runtime,sdk,Hosting Bundle Installer,其他操作 .....发现并没有什么用(后续操作发现还是环境问题...这里重点记一下,有空再研究一下)

4.打开windos日志,发现有错误提示

Application 'MACHINE/WEBROOT/APPHOST/MYWEB' with physical root 'C:\IIS\MyWeb\' failed to start process with commandline 'dotnet .\Sky.HelloCore.Web.dll', ErrorCode = '0x80004005 : 8000808c.

5.到网站目录打开cmd窗口,运行“dotnet Sky.HelloCore.Web.dll”,发现报错...

6.直接百度错误信息,有答案是说asp.net 没有把服务器需要的包全部发布出来,它认为是目标系统带着有,而实际上目标系统中没有。

7.最后,给项目文件(csjproj文件)加上一行代码。中文翻译貌似是发布带上AspNetCore目标清单?

<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> 

完整的项目文件xml

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
	<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AngleSharp" Version="0.9.9.2" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
  </ItemGroup>

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

  <ItemGroup>
    <Reference Include="NewLife.Core">
      <HintPath>..\DLL\NewLife.Core.dll</HintPath>
    </Reference>
    <Reference Include="Sky.Gallery">
      <HintPath>..\DLL\Sky.Gallery.dll</HintPath>
    </Reference>
    <Reference Include="XCode">
      <HintPath>..\DLL\XCode.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

8.问题是解决了,但是!!!发布把所有的包都发布了,整个文件夹40多兆,所以这个方法不太好


待研究,服务器已经安装上了runtime,就不应该还有报某个包不存在...

待排查是不是GAC没有这个包....


终结此贴,网站是基于nc2.0,也许我装的2.1不行,于是重新安装2.0的两个包就可以了

posted @ 2018-05-31 23:52  ismatch  阅读(879)  评论(2编辑  收藏  举报