【问题标题】:VS2012 Installer and SlowCheetah XML TransformsVS2012 安装程序和 SlowCheetah XML 转换
【发布时间】:2012-08-22 05:11:54
【问题描述】:

我正在尝试 VS2012 中 Windows 服务项目的发布选项。

我使用 NLog,并且有一个 NLog.config 文件。我还使用 SlowCheetah 为每个构建配置转换该配置文件。

当我尝试运行生成的 setup.exe 时,出现错误

文件 NLog.config 的计算哈希值与清单中指定的不同。

我想哈希是在 NLog.config 的预转换版本上计算的。如何让发布向导使用正确的、转换后的 NLog.config 版本?

更新(根据 Sayed 要求提供更多细节)

我的 Windows 服务项目使用 NLog。 NLog.config 文件标有 Content 的构建操作。它看起来像这样(缩略版)

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <targets>
    <target xsi:type="File" name="ferr" fileName="C:/MyPath/Error.log"
        archiveFileName="C:/MyPath/Error.{#}.txt"
        archiveEvery="Day"
        archiveNumbering="Rolling"
        maxArchiveFiles="28"
        layout="${longdate} ${uppercase:${level}} ${message}" />
  </targets>

  <rules>
    <logger name="*" minlevel="Error" writeTo="ferr" />
  </rules>
</nlog>

我正在使用Slow Cheetah 为该文件添加转换。解决方案配置 QA 的转换如下所示:

NLog.QA.config

<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="http://www.nlog-project.org/schemas/NLog.xsd">
  <targets>
    <target xsi:type="Mail" name="m"
            to="me@not.really" from="notify@not.really" html="True"
            subject="QA ERROR on ${machinename}"
            smtpServer="127.0.0.1"
            layout="${longdate} ${uppercase:${level}} ${message}" xdt:Transform="Insert" />
  </targets>
  <rules>
    <logger name="*" minlevel="Fatal" writeTo="m" xdt:Transform="Insert" />
  </rules>
</nlog>

转换导致构建输出中最终的 NLog.config 与项目中的 NLog.config 不同(将 NLog.QA.config 中定义的转换规则应用于原始 NLog.config 以获得最终NLog.config)。

当我使用“发布”选项创建 setup.exe 和相关文件,将所有这些文件复制到新的 QA 计算机并尝试运行 setup.exe 时,我收到错误

文件 NLog.config 的计算哈希值与清单中指定的不同。

根据错误消息,我怀疑 清单中指定的计算哈希是基于原始项目中出现的 NLog.config 文件,而不是基于由构建输出。

请注意,我的 app.config 也有一个转换。我没有收到转换后的 app.config 的类似错误。但是,我不知道这是因为 setup.exe 在进入 app.config 之前就放弃了,还是因为 app.config 案例处理正确。

更新 2

这是完整的错误信息

PLATFORM VERSION INFO
    Windows             : 6.0.6002.131072 (Win32NT)
    Common Language Runtime     : 4.0.30319.17929
    System.Deployment.dll       : 4.0.30319.17929 built by: FX45RTMREL
    clr.dll             : 4.0.30319.17929 built by: FX45RTMREL
    dfdll.dll           : 4.0.30319.17929 built by: FX45RTMREL
    dfshim.dll          : 4.0.41209.0 (Main.041209-0000)

SOURCES
    Deployment url          : file:///C:/Xfer/MyService/MyService.application
    Application url         : file:///C:/Xfer/MyService/Application%20Files/MyService_1_0_0_3/MyService.exe.manifest

IDENTITIES
    Deployment Identity     : MyService.application, Version=1.0.0.3, Culture=neutral, PublicKeyToken=56e62aa7113b4840, processorArchitecture=msil
    Application Identity        : MyService.exe, Version=1.0.0.3, Culture=neutral, PublicKeyToken=56e62aa7113b4840, 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 C:\Xfer\MyService\MyService.application resulted in exception. Following failure messages were detected:
        + File, NLog.config, has a different computed hash than specified in manifest.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    * [8/22/2012 11:10:55 PM] : Activation of C:\Xfer\MyService\MyService.application has started.
    * [8/22/2012 11:10:55 PM] : Processing of deployment manifest has successfully completed.
    * [8/22/2012 11:10:55 PM] : Installation of the application has started.
    * [8/22/2012 11:10:55 PM] : Processing of application manifest has successfully completed.
    * [8/22/2012 11:10:57 PM] : Found compatible runtime version 4.0.30319.
    * [8/22/2012 11:10:57 PM] : Request of trust and detection of platform is complete.

ERROR DETAILS
    Following errors were detected during this operation.
    * [8/22/2012 11:10:58 PM] System.Deployment.Application.InvalidDeploymentException (HashValidation)
        - File, NLog.config, has a different computed hash than specified in manifest.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.ComponentVerifier.VerifyFileHash(String filePath, Hash hash)
            at System.Deployment.Application.ComponentVerifier.VerifyFileHash(String filePath, HashCollection hashCollection)
            at System.Deployment.Application.ComponentVerifier.FileComponent.Verify()
            at System.Deployment.Application.ComponentVerifier.VerifyComponents()
            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)
            at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

COMPONENT STORE TRANSACTION DETAILS
    No transaction information is available.

更新 3

查看 Publish 创建的文件,NLog.config.deploy 不是我期望的转换文件,而是与 具有相同的内容original *NLog.config"。NLog.QA.config 中指定的转换未应用。

NLog.config.deploy 的文件大小为 1353 字节。然而,manifest() 断言文件大小应该是 1696 字节(这正是正确的转换后大小)

  <file name="NLog.config" size="1696">
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
      <dsig:DigestValue>IbzW1PndPFYBt59Yrcl6Ax8F5GFX3VVco7wIdDrV6Fo=</dsig:DigestValue>
    </hash>
  </file>

该文件位于写入setup.exe的文件夹下,在

应用程序文件\MyService_1_0_0_0\NLog.config.deploy

另外,我注意到

C:...\MyProject\obj\QA\SlowCheetah

有一个文件 app.config 但没有文件 NLog.config

更新 4

现在,当我进行正常构建时,解决方案设置为 QA,NLog.config 不再被转换。但是,app.config 正在 被转换。然后,我转到项目设置的发布选项卡。我没有做任何更改,但是 .csproj 无论如何都被更改了(名称旁边有一个 * ......我没有确认更改是什么)。保存、构建并突然应用了 NLog.config 转换。再次发布,突然又应用了 NLog.config。发布设置的某些东西影响了 SlowCheetah 将转换应用于 NLog.config 的能力。

不幸的是,在这一点上,我将不得不回滚到没有任何发布内容的项目的先前版本并继续完成代码。我希望这是足够的信息来追踪问题。

【问题讨论】:

  • 您能在这里提供更多信息吗?根据当前的内容,我不知道发生了什么。
  • @SayedIbrahimHashimi:我添加了更多细节。如果您需要更多上下文来理解问题,请尽可能具体地告诉我哪些信息会对您有所帮助。
  • 这就是我所做的。创建 Win Svc 项目。添加 QA sln/proj 配置。添加 app.config 并为调试/发布/QA 添加转换。添加 nlog.config,为 Debug/Release/QA 添加转换。右键单击 win svc 项目上的发布。将该文件夹复制到另一台计算机并启动 setup.exe。它安装并运行良好,我收到一个错误,因为它是 Windows 服务。这是我的示例dl.dropbox.com/u/40134810/stackoverflow/12066623.zip。你能分享一个失败的吗?
  • @SayedIbrahimHashimi:嗯。我无法用全新的简单项目重现错误。不幸的是,我无法分享完整的项目。我确实添加了整个错误消息。如果有什么具体的我可以检查,我很高兴这样做。 Publish 是否应该不适用于 Windows 服务项目?

标签: publish visual-studio-2012 slowcheetah


【解决方案1】:

回答有点晚了,但最近我遇到了类似的问题,当转换未应用于我的配置和 xml 时,我收到“文件,SomeConfig.xml,具有与清单中指定的不同的计算哈希值。”错误。

在我的情况下,原因是这两个文件的属性复制到输出目录设置为 始终复制,当我将其更改为 不复制(即我理解的默认值)一切都开始正常工作以及 ClickOnce 安装。

【讨论】:

    【解决方案2】:

    这为我解决了:

    right-click on your config file(对我来说问题在于 app.config,而不是 nlog.config)和select properties

    在属性窗格中,set Copy to Output Directory = Copy Always(我的默认为不复制)。

    有趣的是,这与 Max Viazovskyi 的回答完全相反。但经过近一整天的论坛筛选,这是唯一对我有用的东西。

    这是一个带有配置转换和 ClickOnce 部署的 Windows 窗体项目。

    【讨论】:

      猜你喜欢
      • 2015-02-07
      • 2012-02-20
      • 2015-11-13
      • 1970-01-01
      • 2012-04-30
      • 1970-01-01
      • 2016-08-11
      • 2015-06-18
      • 1970-01-01
      相关资源
      最近更新 更多