<PackageCertificateKeyFile> not set?

Sep 6, 2014 at 9:26 PM
I know my automated build script used to work, so the cert file used to be set in the project file. However, I don't think my cmakelists ever explicitly stated what file was the certificate for signing. This is most likely a case of 'user error'.

Using Sept 2nd build (AFAIK), the generated vcproj no longer has <PackageCertificateKeyFile> or PackageCertificateThumbprint> defined. When you open it in the VS GUI and build, everything's fine; I think VS is editing the vcproj file. When you build it on the command line without ever opening it in the VS GUI, you get:
"<vcxproj path>" (default target) (28) ->
(_GenerateAppxPackageFile target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\AppxPackage\Microsoft.AppXPackag
e.Targets(1772,9): error APPX0101: A signing key is required in order to package this project.
Please specify a PackageCertificateKeyFile or PackageCertificateThumbprint value in the proje
ct file. [<vcxproj path>]
Coordinator
Sep 6, 2014 at 10:58 PM
Hi Ted

You should look at the tests\VSWinStorePhone to see how to add the certificate file to the package.

Did you recently add an app manifest to your project? We made it such that if you don't have an app manifest in your project we'll put in some default manifest, icons and certificate. This is why perhaps you didn't have the issue before.

~Gilles
Sep 7, 2014 at 12:21 AM
I figured out more, and it doesn't make sense. I add the key file and manifest file to a list of files, SRC_FILES, that I use for all source files. It gets passed to add_executable(). But the key file isn't in the project. I just did a clean&rebuild. I tried message(STATUS ${SRC_FILES}) right after add_executable to make sure the pfx file is still in SRC_FILES.

Any ideas?

Looking in Multiplatform/tests/VSWinStorePhone I see:
set(RESOURCE_FILES
${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES}
Direct3DApp1/Direct3DApp1_TemporaryKey.pfx)

So the key file is just included in the project, right?
Coordinator
Sep 8, 2014 at 8:09 PM
That is strange, the certificate file is just included in the project. If you're up to it, I can point you to the place in CMake where the certificate gets processed and we can debug or if you have something that's shareable, I can take a look.

~Gilles
Sep 14, 2014 at 11:40 PM
I guess point me to where the certificate is being handled in source. I won't be compiling & debugging cmake, but hopefully I can inspect the code and figure out what's happening.

What I have isn't feasibly shared.
Coordinator
Sep 16, 2014 at 6:49 PM
Hi Ted,

The code is located in source\cmVisualStudio10TargetGenerator,cxx

You can see certificate file handling in the following metods:

void cmVisualStudio10TargetGenerator::WriteGroups() (this sets the grouping of your sources)

void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() (this is where the certificate gets added to the csproj file, if the pfxfile was found then it should be added as a PackageCertificateKeyFile element).

~Gilles
Sep 18, 2014 at 7:17 PM
I don't have a solution for this yet. For now, I'll be adding code to my build to inject the PackageCertificateKeyFile so I can automate things. The following is just in case reading it leads you quickly to a solution, as I know you have your own work to complete.


I'm just code reviewing, not debugging cmake code. I've also tried a few things to get clues & hints as to what's happening.
  1. IsMissingFiles is set to true if the manifest is missing, but then it's used to determine if the certificate file is missing.
    I have a manifest set, so IsMissingFiles==false.
if(this->IsMissingFiles &&
   !(this->GlobalGenerator->TargetsWindowsPhone() &&
     this->GlobalGenerator->GetSystemVersion() == "8.0"))
  1. Somehow the code either can't find the pfx or it 'loses' it
    If "pfxFile = this->ConvertPath((*si)->GetFullPath(), false);" sets pfxFile to "" then the later "if (!pfxFile.empty())" would get skipped and due to #1 there would be no pfx file for the project.
  2. If I misspell my pfx, I get a default project with a default appxmanifest & pfx
  3. If I have a manifest but no pfx specified, I get the manifest I specify and it seems like no pfx.
  4. If I set HEADER_FILE_ONLY on the pfx file, it gets included in the project.
    So, I know it's mostly setup correctly. And the path is right:
    <ClInclude Include="C:\Users\Ted\Documents\GitHub\App\build\winrt\App_TemporaryKey.pfx" />
Coordinator
Sep 18, 2014 at 10:23 PM
The missing files section is really only there for the projects built by CMake to validate the compiler. They aren't there to replace to provide things to the developer.

I finally understand the issue. The certificate gets written to the project file, but not included in the sources in the project. I've make the changes and will publish new builds this afternoon.

Thanks.
Coordinator
Sep 19, 2014 at 12:57 AM
Please try the new release. BTW we've changed the installer to be installed in CMakeMS instead of CMake so that you are able to have both installs side-by-side

~Gilles
Sep 19, 2014 at 3:30 AM
Worked like a charm. Thanks for the great bug-fix response time!