Tomas Karban
Tomas Karban

Reputation: 1174

How do I sign APPX file for WP81 using MSBuild?

I need to sign a LOB/enterprise app (built as APPX) for Windows Phone 8.1 for internal distribution. I tried to use MSBuild SignFile task:

<Target Name="SignAppxPhone" AfterTargets="_CreateAppxPackage">
    <SignFile
        CertificateThumbprint="$(CertificateThumbprint)"
        SigningTarget="$(AppxPackageOutput)"
        TargetFrameworkVersion="v4.5" />
</Target>

I am getting the following error:

error MSB3482: An error occurred while signing: Data at the root level is invalid. Line 1, position 1.

What's wrong?

Upvotes: 2

Views: 765

Answers (1)

Tomas Karban
Tomas Karban

Reputation: 1174

MSBuild SignFile task only supports PE files (*.exe, *.dll) and XML, unfortunately. APPX files or CAB files are not supported. I looked in Reflector at the latest version of Microsoft.Build.Tasks.v12.0.dll -- shipped with Visual Studio 2013 Update 3 RC, built on 6/25/2014. It's been reported to Microsoft 6 years ago.

https://connect.microsoft.com/VisualStudio/feedback/details/347731/msbuild-signfile-task-fails-with-cab-files

A reasonable workaround is to <Exec> signtool.exe directly:

<Target Name="SignAppxPhone" AfterTargets="_CreateAppxPackage">
    <Exec Command="&quot;$(SignAppxPackageExeFullPath)&quot; sign /fd SHA256 /sha1 $(CertificateThumbprint) /t http://timestamp.verisign.com/scripts/timstamp.dll &quot;$(AppxPackageOutput)&quot;" />
</Target>

Upvotes: 1

Related Questions