tag:help.appveyor.com,2012-11-13:/discussions/problems/922-build-office-adding-project-failsAppVeyor: Discussion 2018-08-25T01:49:50Ztag:help.appveyor.com,2012-11-13:Comment/350295922014-10-22T17:41:16Z2014-10-22T17:41:16ZBuild Office Adding Project fails<div><p>Will take a look!</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/350295922014-10-23T00:28:49Z2014-10-23T00:28:49ZBuild Office Adding Project fails<div><p>I Confirm it happes with every Oulook Addind Certificate like
this<br>
<a href=
"https://github.com/ricardopolo/OutlookAddin">https://github.com/ricardopolo/OutlookAddin</a></p>
<p>I found that it happens because the certificate used for the
ClickOne manifest of the project is not present in the AppVeyor
server. Do you Know how can we include a PFX in the project?</p></div>ricardo.polotag:help.appveyor.com,2012-11-13:Comment/350295922014-10-23T00:49:26Z2014-10-23T00:49:26ZBuild Office Adding Project fails<div><p>You can put PFX certificate into repo then use PowerShell to
import it: <a href=
"http://technet.microsoft.com/en-us/library/hh848625.aspx">http://technet.microsoft.com/en-us/library/hh848625.aspx</a></p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/350295922014-10-24T05:02:46Z2014-10-24T05:02:46ZBuild Office Adding Project fails<div><p>Ricardo,</p>
<p>I've made a simple Outlook add-in project to demonstrate how to
install certificate: <a href=
"https://ci.appveyor.com/project/appvyr/office-addins-test">https://ci.appveyor.com/project/appvyr/office-addins-test</a></p>
<p>The repository: <a href=
"https://github.com/FeodorFitsner/office-addins-test">https://github.com/FeodorFitsner/office-addins-test</a></p>
<p><code>appveyor.yml</code>: <a href=
"https://github.com/FeodorFitsner/office-addins-test/blob/master/appveyor.yml">
https://github.com/FeodorFitsner/office-addins-test/blob/master/app...</a></p>
<p>Let me know if you have any questions.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/350295922014-10-27T02:22:19Z2014-10-27T02:22:21ZBuild Office Adding Project fails<div><p>Thank you Feodor. I'll take a look.</p>
<p>One last thing, how do you ensure that for public project not
every one gets the private key of the certificate?</p>
<p>In your AppVeyore.yml you are not specifying a password for the
PFX. Is this a file without password or you are storing it in
another place?<br>
I think I could store the password in the Encrypt configuration
data of Appveyor, but it wont compile for the developers in their
computer? Do you have any idea?</p>
<p>Thanks and best regards</p></div>ricardo.polotag:help.appveyor.com,2012-11-13:Comment/350295922014-10-27T23:19:26Z2014-10-27T23:19:26ZBuild Office Adding Project fails<div><p>Right, in the example above I used default PFX without
password.</p>
<p>You can Encrypt environment variable on AppVeyor UI (<a href=
"http://www.appveyor.com/docs/build-configuration#secure-variables">http://www.appveyor.com/docs/build-configuration#secure-variables</a>),
put encrypted value to <code>appveyor.yml</code> then use this
variable in cmdlet call:</p>
<pre>
<code>before_build:
- ps: $psw = ConvertTo-SecureString $env:my_secure_var -AsPlainText
- ps: Import-PfxCertificate -FilePath .\BasicOutlookAddIn\BasicOutlookAddIn_TemporaryKey.pfx -CertStoreLocation cert:\CurrentUser\My -Password $psw</code>
</pre>
<p>If you want to put this in a build script and then use the same
script on both AppVeyor and developer machines you can store any
sensitive data in their registries, so in your build script you
have:</p>
<pre>
<code>$psw = (Get-ItemProperty -path HKCU:\SOFTWARE\MyCompany\MyProject).PfxPassword
Import-PfxCertificate -FilePath .\BasicOutlookAddIn\BasicOutlookAddIn_TemporaryKey.pfx -CertStoreLocation cert:\CurrentUser\My -Password $psw</code>
</pre>
<p>where <code>HKCU:\SOFTWARE\MyCompany\MyProject</code> is your
custom key with project build settings (keys, connection string,
passwords, etc.) and <code>PfxPassword</code> is string value with
PFX password.</p>
<p>To use the same script in AV environment you should put
PfxPassword before the build:</p>
<pre>
<code>New-ItemProperty -path HKCU:\SOFTWARE\MyCompany\MyProject -Name PfxPassword -Value $env:my_secure_var</code>
</pre>
<p>Do you get the idea?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/350295922014-10-30T03:13:44Z2014-10-30T03:13:46ZBuild Office Adding Project fails<div><p>Hello. I tried my self and works as expected.<br>
Would be great if from the AppVeyor console you can instal digital
certificates.</p>
<p>Meanwhile this work:<br>
In AppVeyor.yaml:</p>
<p>environment:<br>
pfx_password: secure: yfky3xGsKE0Kwe2xOHB2sQ==</p>
<p>before_build:<br>
- ps: New-Item -path HKCU:\SOFTWARE\Company - ps: New-ItemProperty
-path HKCU:\SOFTWARE\Company -Name PfxPassword -Value
$env:pfx_password - ps: .\build.ps1</p>
<hr>
<p>In build.ps1<br>
$psw = (Get-ItemProperty -path HKCU:\SOFTWARE\Tulpep).PfxPassword
if(!$psw)<br>
{ throw "HKCU\Software\Company\PfxPassword does not exist"<br>
} $psw = ConvertTo-SecureString $psw -AsPlainText -Force
Import-PfxCertificate -FilePath .\Certificate.pfx
-CertStoreLocation cert:\CurrentUser\My -Password $psw</p></div>ricardo.polotag:help.appveyor.com,2012-11-13:Comment/350295922014-10-30T03:26:59Z2014-10-30T03:26:59ZBuild Office Adding Project fails<div><p>Cool, thanks for the update!</p>
<p>Installing certificates from UI could be something we can do in
the future provided there are more project types that could benefit
from that.</p></div>Feodor Fitsner