无法使用Visual Studio for Mac对.app文件进行代码签名

问题描述

我正在Visual Studio for Mac中开发C#应用程序。
我已将其设置为使用开发人员ID签名进行签名,以便由Apple进行公证。
但这不起作用。

这是步骤。

(1)。使用Visual Studio for Mac对代码进行签名。
(2)。但是,此.app文件将崩溃。
(3)。创建dmg并使用 xcrun altool 命令请求公证时,出现以下错误

{
  "logFormatVersion": 1,"jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","status": "Invalid","statusSummary": "Archive contains critical validation errors","statusCode": 4000,"archiveFilename": "MyApp.dmg","uploadDate": "2020-08-18T08:29:55Z","sha256": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","ticketContents": null,"issues": [
    {
      "severity": "error","code": null,"path": "MyApp.dmg/MyApp.app/Contents/MonoBundle/sqlite.Interop.dll","message": "The signature of the binary is invalid.","docUrl": null,"architecture": "x86_64"
    }
  ]
}

即使成功,也没关系,因为它会崩溃...
考虑到 sqlite.Interop.dll 是原因,我在步骤(1)之后直接对代码进行了签名,并成功启动了该代码

$ codesign --force --verify --verbose \
    --sign "Developer ID Application: MyCompany (XXXXXXXXX)" \
    "sqlite.Interop.dll" \
    --deep \
    --options runtime \
    --timestamp

但是,使用 xcrun altool 命令请求公证会返回如下错误

{
  "logFormatVersion": 1,"path": "MyApp.dmg/MyApp.app/Contents/MacOS/MyApp","architecture": "x86_64"
    }
  ]
}

我认为这是由于依赖项 sqlite.Interop.dll 的签名发生了变化,导致MyApp中的签名不正确。
我该如何解决

这就是我已经尝试过的。

  • 再次手动签名 MyApp.dmg / MyApp.app / Contents / MacOS / MyApp
  • 在步骤(1)之前,手动
  • 签名 sqlite.Interop.dll

以下是一些有用的信息

  • .csproj文件签名的设置
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Anycpu' ">
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <EnableCodeSigning>true</EnableCodeSigning>
    <CreatePackage>false</CreatePackage>
    <EnablePackageSigning>false</EnablePackageSigning>
    <IncludeMonoruntime>true</IncludeMonoruntime>
    <UseSGen>true</UseSGen>
    <UseRefCounting>true</UseRefCounting>
    <LinkMode>SdkOnly</LinkMode>
    <AOTMode>None</AOTMode>
    <CodeSigningKey>Developer ID Application: MyCompany (XXXXXXXXXXX)</CodeSigningKey>
    <PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
    <UseHardenedRuntime>true</UseHardenedRuntime>
    <CodeSignEntitlements>Entitlements.plist</CodeSignEntitlements>
    <CodeSignExtraArgs>--deep</CodeSignExtraArgs>
  </PropertyGroup>
  • Entitlements.plist
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>com.apple.security.cs.allow-jit</key>
    <true/>
</dict>
</plist>

我正在使用 System.Data.sqlite.Core 中的 sqlite.Interop.dll ,这是我从NuGet获得的。

packages/System.Data.sqlite.Core.1.0.111.0/runtimes/osx-x64/native/netstandard2.0/sqlite.Interop.dll

后记2020/08/31 15:52: Visual Studio for Mac构建日志的一部分:

Target GenerateSatelliteAssemblies:
    Creating directory "obj/Release/en".
    /Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5/al.exe /culture:en /out:obj/Release/en/MyApp.resources.dll /template:obj/Release/MyApp.exe /embed:obj/Release/improvementproductivityforMac.Resources.AppResources.en.resources
Target _copyFilesMarkedcopyLocal:
    copying file from "/Users/tomityu/Gits/my-app/packages/NLog.4.6.6/lib/netstandard2.0/NLog.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/NLog.dll".
    copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.sqlite.Core.1.0.111.0/lib/netstandard2.0/System.Data.sqlite.xml" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.sqlite.xml".
    copying file from "/Users/tomityu/Gits/my-app/packages/NLog.4.6.6/lib/netstandard2.0/NLog.xml" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/NLog.xml".
    copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.sqlite.Core.1.0.111.0/lib/netstandard2.0/System.Data.sqlite.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.sqlite.dll".
    copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.sqlite.Core.1.0.111.0/lib/netstandard2.0/System.Data.sqlite.dll.config" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.sqlite.dll.config".
    Creating "/Users/tomityu/Gits/my-app/MyApp/obj/Release/MyApp.csproj.Copycomplete" because "AlwaysCreate" was specified.
Target copyFilesToOutputDirectory:
    copying file from "/Users/tomityu/Gits/my-app/MyApp/obj/Release/MyApp.exe" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.exe".
    MyApp -> /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.exe
    copying file from "/Users/tomityu/Gits/my-app/MyApp/obj/Release/en/MyApp.resources.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/en/MyApp.resources.dll".
Target _DetectSigningIdentity:
    Detected signing identity:
            
      Code Signing Key: "Developer ID Application: MYCOMPANY (7LM65QQ5VR)" (C34D25E1BBB78996C6A0257E78A87C103A320815)
      Bundle Id: jp.mycompany
      App Id: jp.mycompany
Target _copyContentToBundle:
    Creating directory '/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/Resources'
            
    ~
            
    copying file from '/Users/tomityu/Gits/my-app/MyApp/Resources/update.png' to '/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/Resources/update.png'
            
Target _CompiletoNative:
    /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp @/Users/tomityu/Gits/my-app/MyApp/obj/Release/response-file.rsp 
    MMP : warning MM0079: The recommended Xcode version for Xamarin.Mac 6.20.2 is Xcode 11.6 or later. The current Xcode version (found in /Applications/Xcode.app/Contents/Developer) is 11.2.
            
    MMP : warning MM2006: Native library 'libdl' was referenced but Could not be found.
            
    MMP : warning MM2009: Referenced by System.Data.sqlite.UnsafeNativeMethodsPosix.dlopen
            
Done building target "_CompiletoNative" in project "MyApp.csproj".
Target copyOurFiles:
    This is us copying a file into resources!
    copying file from "/Users/tomityu/Gits/my-app/MyApp/NLog.config" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/NLog.config".
Target _CodesignNativeLibraries:
    Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/libmono-native.dylib
            
    Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/libmonoposixHelper.dylib
            
Target _CodesignAppBundle:
    Tool /usr/bin/codesign execution started with arguments: -v --force -o runtime --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --entitlements /Users/tomityu/Gits/my-app/MyApp/obj/Release/Entitlements.xcent --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app
            
Target _CodesignVerify:
    /usr/bin/codesign --verify -vvvv --deep bin/Release/MyApp.app 
    bin/Release/MyApp.app: valid on disk
    bin/Release/MyApp.app: satisfies its Designated Requirement

Done building project "MyApp.csproj".

Build succeeded.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...