"File has... changed... or may be corrupt" error when you publish a ClickOnce application in Visual Studio 2010 and the .NET Framework 4.5 with custom prerequisites

Symptoms
When you publish a ClickOnce application by using Microsoft Visual Studio 2010 on a computer that has the .NET Framework 4.5, the .NET Framework 4.5.1, the .NET Framework 4.5.2 or a newer version installed, the redistributable prerequisite packages are not packaged correctly if they are not signed. Therefore, the user receives the following error message when Setup.exe runs:

An error occurred while installing system components for <Application_Name>. Setup cannot continue until all system components have been successfully installed.

Setup has detected that the file <path to a temporary location of the MSI file> has either changed since it was initially published or may be corrupt.

See the setup log file located at <path to the Install.log file in the temporary directory under the user's profile> for more information.
Additionally, the following entry is logged in the Install.log file to indicate that hash verification has failed for the unsigned prerequisite file:

Verifying file integrity of <path to a temporary location of the MSI file> Verifying file hashError: Setup has detected that the file <path to a temporary location of the MSI file> has either changed since it was initially published or may be corrupt.
Cause
This problem occurs because the build process generates the prerequisite file’s digest by using the SHA2 hashing algorithm when it packages the prerequisite file. However, Setup.exe file tries to read the digest by using the SHA1 algorithm. Therefore, a mismatch occurs between the expected digests and the actual digests, and Setup.exe determines the .msi file to be either missing or corrupted.
Resolution
To resolve this issue, make sure that the custom prerequisite (.msi) file is signed so that the problematic digest is not generated.

Alternatively, use Microsoft Visual Studio 2012 or a later version. These program versions do not experience this problem.
More information
Visual Studio 2010 runs MSBUILD tasks that are distributed with the .NET Framework in the Microsoft.Build.Tasks.v4.0.dll assembly. If the .NET Framework 4.5 or a later version is installed on the development computer, this build task generates an SHA2 hash of the prerequisite file if that file is not signed. During installation on the user's computer, that hash cannot be verified by the bootstrapper engine (Setup.exe) that is generated by Visual Studio 2010.
Properties

Article ID: 3072421 - Last Review: 06/19/2015 21:29:00 - Revision: 1.0

Microsoft Visual Studio 2010 Service Pack 1, Microsoft .NET Framework 4.5.2, Microsoft .NET Framework 4.5.1, Microsoft .NET Framework 4.5

  • kbprb kbexpertiseadvanced kbsurveynew KB3072421
Feedback