我使用NetCore 2.2
开发的应用程序遇到了问题,
当我在以下设置中使用VS2017的发布后部署应用程序时:
- 发布
-netcoreapp2.2
-框架相关
-Win-x64
到IIS服务器时,当应用程序尝试启动时显示:
Application startup exception
System.IO.FileNotFoundException: Could not load file or assembly 'Jump.Shared.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Impossible to find specified file.
File name: 'Jump.Shared.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
现在问题似乎是我的引用结构。
我有一个主要项目Scan.Web
,它引用了Scan.Core
和Scan.Infrastructure
,这是.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Scan.Core\Scan.Core.csproj" />
<ProjectReference Include="..\Scan.Infrastructure\Scan.Infrastructure.csproj" />
</ItemGroup>
</Project>
然后Scan.Infrastructure
引用有问题的Jump.Shared.Infrastructure
,这里是csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\JumpShared\Jump.Shared.Infrastructure\Jump.Shared.Infrastructure.csproj" />
<ProjectReference Include="..\Scan.Core\Scan.Core.csproj" />
</ItemGroup>
</Project>
最后是罪魁祸首的.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="MongoDB.Driver" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Jump.Shared.Core\Jump.Shared.Core.csproj" />
</ItemGroup>
</Project>
我无法弄清楚为什么在VS2017的Debug中一切正常,当在IIS上发布它时,找不到此引用。
该版本给了我Jump.Shared.Infrastructure.dll