Skip to content

Commit 60a9bbb

Browse files
committed
Update signing commands
1 parent 11d0002 commit 60a9bbb

File tree

1 file changed

+7
-56
lines changed

1 file changed

+7
-56
lines changed

build/Signing.targets

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,16 @@
77
<SignToolPath Condition="!Exists($(SignToolPath))">$(MSBuildProgramFiles32)\Windows Kits\10\bin\x64\signtool.exe</SignToolPath>
88
<SignToolPath Condition="!Exists($(SignToolPath))">$(MSBuildProgramFiles32)\Windows Kits\10\bin\10.0.22000.0\x64\signtool.exe</SignToolPath>
99
<SignToolPath Condition="!Exists($(SignToolPath))">$(MSBuildProgramFiles32)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe</SignToolPath>
10-
<SignToolPath Condition="!Exists($(SignToolPath))">$(WindowsSDK80Path)bin\x64\signtool.exe</SignToolPath>
10+
<SignToolPath Condition="!Exists($(SignToolPath))">$(WindowsSDK80Path)bin\x64\signtool.exe</SignToolPath>
1111
<SignToolPath Condition="!Exists($(SignToolPath))">signtool.exe</SignToolPath> <!-- fallback to use PATH environment -->
1212

1313
<CodeSignCertificateStore Condition="'$(CodeSignCertificateStore)'==''">LocalMachine</CodeSignCertificateStore>
14-
<CodeSignCertificateName Condition="'$(THUMBPRINT)'==''"></CodeSignCertificateName>
15-
<SignOutput Condition="'$(THUMBPRINT)'!=''">true</SignOutput>
16-
<SignAssemblyCommand Condition="'$(SignOutput)' == 'true'">"$(SignToolPath)" sign /fd SHA256 /sha1 $(THUMBPRINT) /sm /tr $(CertificateTimeStampService) /td SHA256</SignAssemblyCommand>
14+
<SignAssemblyCommand>"$(SignToolPath)" sign /fd SHA256 /sha1 $(THUMBPRINT_SHA1) /sm /tr $(CertificateTimeStampService) /td SHA256</SignAssemblyCommand>
1715
<NuGetExePath>$(MSBuildThisFileDirectory)..\.tools\NuGet.exe</NuGetExePath>
18-
<SignNugetCommand>--certificate-fingerprint $(THUMBPRINT) --certificate-store-name My --certificate-store-location $(CodeSignCertificateStore) --timestamper $(CertificateTimeStampService) --overwrite</SignNugetCommand>
16+
<SignNugetCommand>--certificate-fingerprint $(THUMBPRINT_SHA256) --certificate-store-name My --certificate-store-location $(CodeSignCertificateStore) --timestamper $(CertificateTimeStampService) --overwrite</SignNugetCommand>
1917
</PropertyGroup>
2018

21-
<Target Name="SignAssembly" Condition="'$(SignOutput)' == 'true'" BeforeTargets="CopyFilesToOutputDirectory" DependsOnTargets="ComputeIntermediateSatelliteAssemblies">
19+
<Target Name="SignAssembly" Condition="'$(THUMBPRINT_SHA1)' != ''" BeforeTargets="CopyFilesToOutputDirectory" DependsOnTargets="ComputeIntermediateSatelliteAssemblies">
2220
<ItemGroup>
2321
<FilesToSign Include="@(IntermediateAssembly)" />
2422
<FilesToSign Include="@(IntermediateRefAssembly)" />
@@ -32,60 +30,13 @@
3230
WorkingDirectory="$(ProjectDir)" EchoOff="true" />
3331
</Target>
3432

35-
<Target Name="SignNuGet" Condition="'$(SignOutput)' == 'true' AND '$(IsPackable)'=='true'" AfterTargets="Pack">
33+
<Target Name="SignNuGet" Condition="'$(THUMBPRINT_SHA256)' != '' AND '$(IsPackable)'=='true'" AfterTargets="Pack">
3634
<PropertyGroup>
3735
<NugetPackageFileName>$(PackageOutputPath)\$(PackageId).$(PackageVersion).nupkg</NugetPackageFileName>
3836
<SNugetPackageFileName>$(PackageOutputPath)\$(PackageId).$(PackageVersion).snupkg</SNugetPackageFileName>
3937
</PropertyGroup>
40-
<Exec Command="dotnet nuget sign &quot;$(NugetPackageFileName)&quot; $(SignNugetCommand)" />
41-
<Exec Command="dotnet nuget sign &quot;$(SNugetPackageFileName)&quot; $(SignNugetCommand)" />
38+
<Exec Command="$(DOTNET_HOST_PATH) nuget sign &quot;$(NugetPackageFileName)&quot; $(SignNugetCommand)" />
39+
<Exec Command="$(DOTNET_HOST_PATH) nuget sign &quot;$(SNugetPackageFileName)&quot; $(SignNugetCommand)" />
4240
</Target>
43-
44-
<Target Name="DownloadNuGetExe">
45-
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition="!Exists('$(NuGetExePath)')" />
46-
</Target>
47-
48-
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
49-
<ParameterGroup>
50-
<OutputFilename ParameterType="System.String" Required="true" />
51-
</ParameterGroup>
52-
<Task>
53-
<Reference Include="System.Core" />
54-
<Reference Include="System.Xml" />
55-
<Reference Include="WindowsBase" />
56-
<Using Namespace="System" />
57-
<Using Namespace="System.IO" />
58-
<Using Namespace="System.IO.Packaging" />
59-
<Using Namespace="System.Linq" />
60-
<Using Namespace="System.Net" />
61-
<Using Namespace="System.Xml" />
62-
<Using Namespace="Microsoft.Build.Framework" />
63-
<Using Namespace="Microsoft.Build.Utilities" />
64-
<Code Type="Fragment" Language="cs">
65-
<![CDATA[
66-
string zipTempPath = null;
67-
try {
68-
OutputFilename = Path.GetFullPath(OutputFilename);
69-
if (File.Exists(OutputFilename)) {
70-
Log.LogMessage("NuGet command line utility already present at " + OutputFilename);
71-
return true;
72-
}
73-
var info = new FileInfo(OutputFilename);
74-
if(!info.Directory.Exists)
75-
info.Directory.Create();
76-
WebClient webClient = new WebClient();
77-
Log.LogMessage("Downloading NuGet.CommandLine");
78-
webClient.DownloadFile("https://dist.nuget.org/win-x86-commandline/v5.7.0/nuget.exe", OutputFilename);
79-
return true;
80-
}
81-
catch (Exception ex) {
82-
Log.LogErrorFromException(ex);
83-
return false;
84-
}
85-
]]>
86-
</Code>
87-
</Task>
88-
</UsingTask>
89-
9041

9142
</Project>

0 commit comments

Comments
 (0)