You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 4.8项目MyOTPWebService发布时X509Certificates.dll复制失败求助

解决.NET 4.8 ASP.NET项目发布时的文件复制错误

针对你的MyOTPWebService项目发布时出现的找不到unix路径下System.Security.Cryptography.X509Certificates.dll的问题,可尝试以下方案:

  • 检查并修复NuGet包
    确认本地项目的packages文件夹中是否存在System.Security.Cryptography.X509Certificates.4.3.0\runtimes\unix\lib\netstandard1.6路径及对应文件。若缺失,执行以下操作:

    • 在NuGet包管理器控制台运行:Update-Package -reinstall System.Security.Cryptography.X509Certificates
    • 或删除项目根目录的packages文件夹,再运行nuget restore重新还原所有包
  • 排除不必要的运行时文件
    由于发布目标是Windows环境,无需包含unix平台的运行时文件,可在项目文件(.csproj)中添加配置排除:

    <ItemGroup>
      <Content Remove="packages\System.Security.Cryptography.X509Certificates.4.3.0\runtimes\unix\**" />
      <None Include="packages\System.Security.Cryptography.X509Certificates.4.3.0\runtimes\unix\**">
        <CopyToOutputDirectory>Never</CopyToOutputDirectory>
      </None>
    </ItemGroup>
    

    也可在发布配置文件(.pubxml)中加入排除规则:

    <ExcludeFilesFromDeployment>packages\System.Security.Cryptography.X509Certificates.4.3.0\runtimes\unix\**</ExcludeFilesFromDeployment>
    
  • 清理临时发布缓存
    手动删除错误提示中的临时目录:C:\Users\me\AppData\Local\Temp\WebSitePublish\MyWebService--676085791,之后重新尝试发布。

  • 升级NuGet包版本
    将System.Security.Cryptography.X509Certificates包升级到兼容.NET 4.8的更高版本(如4.7.0及以上),新版本通常会优化跨平台文件的发布逻辑。

内容的提问来源于stack exchange,提问作者Ayobamilaye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 11:06:11