dotnet发布在Ubuntu Server上没有生成正确的程序集

时间:2018-02-02 09:19:49

标签: c# ubuntu .net-core command-line-interface

过去7天我在服务器上发布dotnet核心项目时遇到了一些麻烦。以前,它突然工作正常,它停止工作。以下是我使用的cli:

dotnet publish -c release -o <directory>

发布时,没有错误,但是当我通过dotnet projectname.dll运行生成的dll时。

它使文件程序集不匹配:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference.

此命名空间中的此文件和许多文件都会产生问题,我正在做的是在本地系统上发布,然后复制粘贴这些文件。

我尝试了很多来自不同来源的解决方案,但没有一个对我有用,下面就是其中之一:

https://github.com/dotnet/core/issues/987

我的csproj内容是这样的:

    <Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <UserSecretsId>aspnet-Jwt-9EB56A08-EA05FF-4EEF-B339-DEE0A5CA1545</UserSecretsId>
    <TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>  
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
  <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
  <ItemGroup>
    <Compile Remove="Myproj\**" />
    <Compile Remove="publish\**" />
    <Compile Remove="wwwrootold\**" />
    <Content Remove="Myproj\**" />
    <Content Remove="publish\**" />
    <Content Remove="wwwrootold\**" />
    <EmbeddedResource Remove="Myproj\**" />
    <EmbeddedResource Remove="publish\**" />
    <EmbeddedResource Remove="wwwrootold\**" />
    <None Remove="Myproj\**" />
    <None Remove="publish\**" />
    <None Remove="wwwrootold\**" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="BlockchainAPI" Version="4.0.0" />
    <PackageReference Include="Cryptography.ECDSA.Secp256k1" Version="1.0.1" />
    <PackageReference Include="HBitcoin" Version="0.1.8.2" />
    <PackageReference Include="MailKit" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
    <PackageReference Include="Microsoft.AspNetCore.Proxy" Version="0.2.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
    <PackageReference Include="MySql.Data.Core" Version="7.0.4-IR-191" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" PrivateAssets="All" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
    <PackageReference Include="NBitcoin.Litecoin" Version="1.0.0.9" />
    <PackageReference Include="NBitcoin.Zcash" Version="1.0.4" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.0.1" />
    <PackageReference Include="secp256k1_vc120" Version="0.1.0.16" />
    <PackageReference Include="stellar-dotnetcore-sdk" Version="1.0.3" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\MyProj.core\MyProj.Core.csproj" />
    <ProjectReference Include="..\MyProj.Data\MyProj.Data.csproj" />
  </ItemGroup>

</Project>

0 个答案:

没有答案