Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
106 lines (75 sloc) 5.13 KB
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" xmlns:n="urn:schemas-microsoft-com:asm.v2" xmlns:xmu="urn:msbuildcommunitytasks-xmlmassupdate" ToolsVersion="14.0">
<PropertyGroup>
<WindowsSDKBinPath>$(WindowsSdkDir)bin</WindowsSDKBinPath>
<SigningKeySignFile>$(SigningKeyPath)\$(SigningKeyName).pfx</SigningKeySignFile>
<SigningKeySignFilePasswordFile>$(SigningKeyPath)\$(SigningKeyName).pfx.password</SigningKeySignFilePasswordFile>
<!-- <SigningKeyTimestampUrl>http://timestamp.verisign.com/scripts/timstamp.dll</SigningKeyTimestampUrl>-->
<!-- Alternate timestamp location because sometimes verisign goes down without warning -->
<SigningKeyTimestampUrl>http://timestamp.comodoca.com/authenticode</SigningKeyTimestampUrl>
<SignToolPath>$(WindowsSDKBinPath)\signtool.exe</SignToolPath>
<MageToolPath>$(WindowsSDK_ExecutablePath_x86)\mage.exe</MageToolPath>
</PropertyGroup>
<PropertyGroup Condition="!Exists($(SignToolPath))">
<SignToolPath>$(WindowsSDKBinPath)\x86\signtool.exe</SignToolPath>
</PropertyGroup>
<Target
Name="CheckSigningKeyPrerequisites">
<Error Condition="!Exists('$(SigningKeyPath)')" Text="Signing key Path is not avialable" />
<Error Condition="'$(ProductName)' == '' "
Text="ProductName property not set for SignApplicationFiles Target"/>
<Error Condition="'$(ProductUrl)' == '' "
Text="ProductUrl property not set for SignApplicationFiles Target"/>
<Error Condition="!Exists('$(SignToolPath)')"
Text="Could not verify path to SignTool.exe $(SignToolPath)"/>
<Message Text="Signing with '$(SigningKeySignFile)'" />
</Target>
<Target Name="SignApplicationFiles" Condition="Exists('$(SigningKeyPath)')">
<CallTarget Targets="CheckSigningKeyPrerequisites" />
<Message Text="Signing Application Files" />
<ReadLinesFromFile File="$(SigningKeySignFilePasswordFile)">
<Output TaskParameter="Lines" PropertyName="SigningKeySignFilePassword"/>
</ReadLinesFromFile>
<Exec Command="&quot;$(SignToolPath)&quot; sign /f $(SigningKeySignFile) /p &quot;$(SigningKeySignFilePassword)&quot; /t $(SigningKeyTimestampUrl) /d &quot;$(ProductName)&quot; /du $(ProductUrl) @(ApplicationFilesToSign, ' ')"/>
</Target>
<Target Name="SignMsi" Condition="Exists('$(SigningKeyPath)')">
<CallTarget Targets="CheckSigningKeyPrerequisites" />
<Message Text="Signing Msi File" />
<ReadLinesFromFile File="$(SigningKeySignFilePasswordFile)">
<Output TaskParameter="Lines" PropertyName="SigningKeySignFilePassword"/>
</ReadLinesFromFile>
<Exec Command="&quot;$(SignToolPath)&quot; sign /f $(SigningKeySignFile) /p &quot;$(SigningKeySignFilePassword)&quot; /t $(SigningKeyTimestampUrl) /d &quot;$(ProductName)&quot; /du $(ProductUrl) @(MsiFilesToSign, ' ')"/>
</Target>
<Target Name="SignSFX" Condition="Exists('$(SigningKeyPath)')">
<CallTarget Targets="CheckSigningKeyPrerequisites" />
<Message Text="Signing Sfx File" />
<ReadLinesFromFile File="$(SigningKeySignFilePasswordFile)">
<Output TaskParameter="Lines" PropertyName="SigningKeySignFilePassword"/>
</ReadLinesFromFile>
<Exec Command="&quot;$(SignToolPath)&quot; sign /f $(SigningKeySignFile) /p &quot;$(SigningKeySignFilePassword)&quot; /t $(SigningKeyTimestampUrl) /d &quot;$(ProductName)&quot; /du $(ProductUrl) @(SFXFilesToSign, ' ')"/>
</Target>
<ProjectExtensions>
<ManifestIdentity>
<n:publisherIdentity xmu:action="remove" />
<trace xmu:action="remove" />
</ManifestIdentity>
</ProjectExtensions>
<Target Name="SignVSTO3Manifest">
<CallTarget Targets="CheckSigningKeyPrerequisites" />
<Message Text="Signing Manifest File" />
<ReadLinesFromFile File="$(SigningKeySignFilePasswordFile)">
<Output TaskParameter="Lines" PropertyName="SigningKeySignFilePassword"/>
</ReadLinesFromFile>
<XmlMassUpdate
ContentFile="$(Vsto3ManifestFile)" ContentRoot="/asmv1:assembly"
NamespaceDefinitions="msb=http://schemas.microsoft.com/developer/msbuild/2003;n=urn:schemas-microsoft-com:asm.v2;asmv1=urn:schemas-microsoft-com:asm.v1"
SubstitutionsFile="$(MSBuildProjectDirectory)\CodeSigning.targets"
SubstitutionsRoot="/msb:Project/msb:ProjectExtensions/msb:ManifestIdentity" />
<XmlMassUpdate
ContentFile="$(Vsto3VstoFile)" ContentRoot="/asmv1:assembly"
NamespaceDefinitions="msb=http://schemas.microsoft.com/developer/msbuild/2003;n=urn:schemas-microsoft-com:asm.v2;asmv1=urn:schemas-microsoft-com:asm.v1"
SubstitutionsFile="$(MSBuildProjectDirectory)\CodeSigning.targets"
SubstitutionsRoot="/msb:Project/msb:ProjectExtensions/msb:ManifestIdentity" />
<Exec Command="&quot;$(MageToolPath)&quot; -update &quot;$(Vsto3ManifestFile)&quot; -Certfile &quot;$(SigningKeySignFile)&quot; -Password &quot;$(SigningKeySignFilePassword)&quot; -name &quot;$(ProductName)&quot; "/>
<Exec Command="&quot;$(MageToolPath)&quot; -update &quot;$(Vsto3VstoFile)&quot; -appmanifest &quot;$(Vsto3ManifestFile)&quot; -Certfile &quot;$(SigningKeySignFile)&quot; -Password &quot;$(SigningKeySignFilePassword)&quot; "/>
</Target>
</Project>