VS2012 で Windows サービス プロジェクトの発行オプションを試しています。
私は NLog を使用しており、NLog.config ファイルがあります。また、SlowCheetah を使用して、各ビルド構成の構成ファイルを変換します。
結果のsetup.exeを実行しようとすると、エラーが発生します
ファイル NLog.config には、マニフェストで指定されたものとは異なる計算されたハッシュがあります。
ハッシュは NLog.config の変換前のバージョンで計算されたと思います。パブリッシュ ウィザードで正しい、変換されたバージョンの NLog.config を使用するにはどうすればよいですか?
更新(詳細についての Sayed の要求に基づく)
私の Windows サービス プロジェクトでは NLog を使用しています。NLog.config ファイルは、Contentの Build Action でマークされています。こんな感じです(短縮版)
<?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.config を取得するために、NLog.QA.config で定義されている変換ルールが元の NLog.config に適用されます)。 )。
[発行] オプションを使用して setup.exe と関連ファイルを作成し、それらのファイルをすべて新しい QA マシンにコピーして、setup.exe を実行しようとすると、エラーが発生します。
ファイル NLog.config には、マニフェストで指定されたものとは異なる計算されたハッシュがあります。
エラーメッセージに基づいて、マニフェストで指定された計算されたハッシュは、ビルド出力によって生成された変換された最終バージョンではなく、元のプロジェクトに表示される NLog.config ファイルに基づいていると思われます。
app.config にも変換があることに注意してください。変換された app.config で同様のエラーは発生しませんでした。ただし、それが app.config に到達する前に setup.exe があきらめたからなのか、それとも 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は期待どおりに変換されたファイルではなく、元の*NLog.configと同じ内容になっています。NLog.QA.configで指定された変換は適用されませんでした。
NLog.config.deployのファイル サイズは 1353 バイトです。ただし、マニフェスト () は、ファイル サイズが 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 が再び適用されなくなりました。パブリッシュ設定の何かが、変換を NLog.config に適用する SlowCheetah の機能を台無しにしています。
残念ながら、この時点で、Publish の要素がまったく含まれていなかった以前のバージョンのプロジェクトにロールバックして、コードの完成に取りかかる必要があります。これが問題を追跡するのに十分な情報であることを願っています.