重新签名 ClickOnce 发布清单后,.exe 文件无法识别

3
我正在使用带有 .Net Framework 4.5 的 MVS 2015。 我已经发布了我的C# WF应用程序,一切正常,但是我必须混淆应用程序文件中的 .exe 文件。 在我这样做之后,显然设置不再识别 .exe 文件,哈希值也不同等等。
我用提供必要的 .pfx 和密码的 Signtool 重新签署了新的 .exe 添加文件,然后使用 Mage 更新了 .manifest 和 .application 根据此 MSDN 文档的第二部分
一切都成功了,但当我运行安装程序并点击安装后,过了一会儿(安装进度约为80%),我收到一个错误消息,说新的 .exe 文件出了问题:
PLATFORM VERSION INFO
    Windows             : 10.0.16299.0 (Win32NT)
    Common Language Runtime     : 4.0.30319.42000
    System.Deployment.dll       : 4.7.2556.0 built by: NET471REL1
    clr.dll             : 4.7.2633.0 built by: NET471REL1LAST_C
    dfdll.dll           : 4.7.2556.0 built by: NET471REL1
    dfshim.dll          : 10.0.16299.15 (WinBuild.160101.0800)

SOURCES
    Deployment url          : file:///E:/share/myApp.application
    Application url         : file:///E:/share/myApp.exe.manifest

IDENTITIES
    Deployment Identity     : myApp.exe.application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil
    Application Identity        : myApp.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil, type=win32

APPLICATION SUMMARY
    * Installable application.

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * Activation of E:\share\myApp.application resulted in exception. Following failure messages were detected:
        + Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened. 
        + Cannot load internal manifest from component file.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    * [24.03.2018 11:03:32] : Activation of E:\share\myApp.application has started.
    * [24.03.2018 11:03:32] : Processing of deployment manifest has successfully completed.
    * [24.03.2018 11:03:32] : Installation of the application has started.
    * [24.03.2018 11:03:33] : Processing of application manifest has successfully completed.
    * [24.03.2018 11:03:35] : Found compatible runtime version 4.0.30319.
    * [24.03.2018 11:03:35] : Request of trust and detection of platform is complete.

ERROR DETAILS
    Following errors were detected during this operation.
    * [24.03.2018 11:03:43] System.Deployment.Application.InvalidDeploymentException (ManifestLoad)
        - Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened. 
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.Manifest.AssemblyManifest.ManifestLoadExceptionHelper(Exception exception, String filePath)
            at System.Deployment.Application.Manifest.AssemblyManifest.LoadFromInternalManifestFile(String filePath)
            at System.Deployment.Application.DownloadManager.ProcessDownloadedFile(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.FileDownloader.DownloadModifiedEventHandler.Invoke(Object sender, DownloadEventArgs e)
            at System.Deployment.Application.FileDownloader.OnModified()
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
            at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
            at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState, X509Certificate2 clientCertificate)
            at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
            at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
            at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri)
            at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)

我做错了什么?我错过了什么? :(
1个回答

2
我已经调查了Marko应用程序,如果您正在使用.NET Refactor并且遇到上述问题,则可以使用以下解决方法使其正常工作:

无论如何,如果您要在发布后修改您的程序集,您仍然需要重新计算哈希值。如何实现:

  1. 不要使用Visual Studio发布引擎,而是通过“mage.exe”生成应用程序。它会让你先准备好源应用程序,然后再创建ClickOnce应用程序。
  2. 从第二个下载链接[这里]下载实用程序。执行并[选择]您的文件夹>将操作更改为[更新]>和[构建]。不需要其他操作。更新操作将重新计算哈希值。
  3. 如果您的混淆器软件支持命令行参数,则可以在.exe VS项目属性中添加“后生成事件”脚本,并在ClickOnce构建之前执行它。

您可以在“部署混淆程序集”文章中找到:Securing ClickOnce Applications


使用您的工具重新签名应用程序后,当我安装它时收到的错误与主线程中呈现的相同。:( - Marko
当然可以。无论如何,您可以尝试下面的三个建议中的前两个。 - Sergey Vaulin
是的,我知道,我已经意识到了。我将我的脚本放在 post-build 事件中,混淆后的 .exe 在构建结束时应该在 /bin 和 /obj 中,但生成的发布设置仍然包含旧的 .exe(未混淆的)。这就是为什么我在问发布者从哪里获取它的文件? - Marko
1
是的,谢谢,我做到了,发布者接受混淆的.exe文件,最后,但是,当我从该发布者部署运行设置时,它显示了帖子中的初始错误。:))我简直不敢相信!这很疲惫,但我再次感谢你的参与,Sergey!如果我能成功完成这个任务,我会回答你的问题的!:D - Marko
1
没问题 :) 我认为你的应用程序有一些不典型的行为,如果你的应用程序不是私人的,能否请你提供你的 ClickOnce 文件夹进行测试,或者如果它已经发布在某个地方,请在 xyliman[A]gmail 上告诉我。这对我来说非常有趣。谢谢。 - Sergey Vaulin
显示剩余9条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接