Using Msbuild to build Windows Store Application without signing the AppxPackage

The msdn article provides you an efficient way to build your windows store applications using MSbuild. There are times when you will require Appxpackage not to be signed , rather to be signed by some one else. Visual Studio internally uses msbuild to build applications . MakeAppx.exe and Signtool are used to create appxpackages and to sign it. We were recently approached by a client to build the AppxPackage from msbuild with out signing it. Visual Studio by default signs the AppxPackage.

                                          While the answer is very easy i.e to use the command line msbuild app2.csproj /p:AppxPackageSigningEnabled=false but I wanted to share with you as to how we came to this command line. The key here is to find the property condition. Firstly I got a Diagnostic Build log from Visual Studio{Go to Tools->options->Projects and Solutions->Build and Run->Msbuild Project Build Output Verbosity-->Diagnostic) and searched the entire log to see which target files are involved . Most of the target files were part of C:\Program Files (x86)\MSBuild\Microsoft\WindowsXaml\v12.0 and C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage folders. I scouted through each one of these target files to see if there were any interesting property conditions . Finally after looking at couple of files , I hit the nail . The target file C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppxPackage.Targets looked promising. I scouted through the entire file to check if there was any thing regarding signing and there it is ,

 <!-- Adjust AppxPackage to be true Boolean flag. -->
        <AppxPackage Condition="'$(AppxPackage)' != 'true'">false</AppxPackage>

    <!-- Flags controlling certain features -->
        <AppxUseHardlinksIfPossible Condition="'$(AppxUseHardlinksIfPossible)' == ''">true</AppxUseHardlinksIfPossible>
        <AppxSkipUnchangedFiles Condition="'$(AppxSkipUnchangedFiles)' == ''">true</AppxSkipUnchangedFiles>
        <AppxGeneratePriEnabled Condition="'$(AppxGeneratePriEnabled)' == ''">true</AppxGeneratePriEnabled>
        <AppxPackageSigningEnabled Condition="'$(AppxPackageSigningEnabled)' == ''">true</AppxPackageSigningEnabled>
        <AppxPackageIncludePrivateSymbols Condition="'$(AppxPackageIncludePrivateSymbols)' == ''">false</AppxPackageIncludePrivateSymbols>
        <AppxSymbolPackageEnabled Condition="'$(AppxSymbolPackageEnabled)' == ''">true</AppxSymbolPackageEnabled>
        <AppxTestLayoutEnabled Condition="'$(AppxTestLayoutEnabled)' == ''">true</AppxTestLayoutEnabled>
        <AppxPackageValidationEnabled Condition="'$(AppxPackageValidationEnabled)' == ''">true</AppxPackageValidationEnabled>
        <AppxHarvestWinmdRegistration Condition="'$(AppxHarvestWinmdRegistration)' == ''">true</AppxHarvestWinmdRegistration>
        <AutoIncrementPackageRevision Condition="'$(AutoIncrementPackageRevision)' == ''">true</AutoIncrementPackageRevision>
        <AppxPrependPriInitialPath Condition="'$(AppxPrependPriInitialPath)' == ''">true</AppxPrependPriInitialPath>
        <EnableSigningChecks Condition=" '$(EnableSigningChecks)' == '' ">true</EnableSigningChecks>
        <AppxStrictManifestValidationEnabled Condition="'$(AppxStrictManifestValidationEnabled)' == ''">true</AppxStrictManifestValidationEnabled>
        <AppxFilterOutUnusedLanguagesResourceFileMaps Condition="'$(AppxFilterOutUnusedLanguagesResourceFileMaps)' == ''">true</AppxFilterOutUnusedLanguagesResourceFileMaps>

 From the above it was quite clear to me that we will have to make this property false. To verify I searched inside the build log and found the below,

1>Task "Message" skipped, due to false condition; ('$(AppxPackageSigningEnabled)' != 'true') was evaluated as ('true' != 'true').
1>Done building target "_GenerateAppxPackageFile" in project "App2.csproj".: (TargetId:121)

Now I tried my hands at the command msbuild app2.csproj /p:AppxPackageSigningEnabled=false and voila there it is the Appxpackage was not signed . I verified this by going inside C:\Users\nsuhas\Documents\visual studio 2012\Projects\App2\App2\AppPackages\app2_1.0.0.0_AnyCPU_Debug_Test and there was no security certificate file and also there was no Digital Signatures tab in the appx file.


 You can also do this outside msbuild and sign it using signtool. Here is a great blog about it .

Keep Coding ,
Nandeesh Swami
Visual Studio languages and Runtime