Browse Source

Always generate checksums as last part of publish job (#20367)

* Always generate checksums as last part of publish job

* Initialize props correctly

* Fix wildcard

* Import Arcade SDK

* Add NoWarn MSB4011

* Make import conditional on GenerateChecksums

* Select specific files to checksum

* Respond to feedback

* AfterTargets -> BeforeTargets
William Godbe 6 years ago
parent
commit
2d6827a678

+ 1 - 0
.azure/pipelines/ci.yml

@@ -67,6 +67,7 @@ variables:
     # The following extra properties are not set when testing. Use with final build.[cmd,sh] of asset-producing jobs.
     - name: _PublishArgs
       value: /p:Publish=true
+             /p:GenerateChecksums=true
              /p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1)
              /p:DotNetPublishBlobFeedUrl=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
              /p:DotNetPublishToBlobFeed=$(_DotNetPublishToBlobFeed)

+ 0 - 1
Directory.Build.props

@@ -170,7 +170,6 @@
 
     <ArchiveExtension>.tar.gz</ArchiveExtension>
     <ArchiveExtension Condition="'$(TargetOsName)' == 'win'">.zip</ArchiveExtension>
-    <ChecksumExtension>.sha512</ChecksumExtension>
   </PropertyGroup>
 
   <Import Project="eng\Workarounds.props" />

+ 33 - 0
eng/AfterSigning.targets

@@ -0,0 +1,33 @@
+<Project>
+
+  <Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(GenerateChecksums)' == 'true'" />
+
+  <PropertyGroup Condition="'$(GenerateChecksums)' == 'true'">
+    <!-- The one use of ArtifactsDir in Publish.proj adds an additional slash, confusing itself. -->
+    <ArtifactsDir Condition=" HasTrailingSlash('$(ArtifactsDir)') ">$(ArtifactsDir.Substring(0, $([MSBuild]::Subtract($(ArtifactsDir.Length), 1))))</ArtifactsDir>
+    <!-- $(InstallersOutputPath) is not defined. Root Directory.Build.props is not imported. -->
+    <InstallersOutputPath>$(ArtifactsDir)\installers\</InstallersOutputPath>
+  </PropertyGroup>
+
+  <Target Name="PopulateGenerateChecksumItems"
+          Condition="'$(GenerateChecksums)' == 'true'"
+          AfterTargets="Build"
+          BeforeTargets="GenerateChecksums" >
+
+    <ItemGroup>
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.msi" />
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.exe" />
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.zip" />
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.tar.gz" />
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.wixlib" />
+      <InstallerFiles Include="$(InstallersOutputPath)**\*.rpm" />
+      <GenerateChecksumItems Include="%(InstallerFiles.Identity)" >
+        <DestinationPath>%(FullPath).sha512</DestinationPath>
+      </GenerateChecksumItems>
+    </ItemGroup>
+
+  </Target>
+
+  <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" Condition="'$(GenerateChecksums)' == 'true'" />
+
+</Project>

+ 2 - 4
eng/Publishing.props

@@ -1,7 +1,7 @@
 <Project>
-  <PropertyGroup Condition=" HasTrailingSlash('$(ArtifactsDir)') ">
+  <PropertyGroup>
     <!-- The one use of ArtifactsDir in Publish.proj adds an additional slash, confusing itself. -->
-    <ArtifactsDir>$(ArtifactsDir.Substring(0, $([MSBuild]::Subtract($(ArtifactsDir.Length), 1))))</ArtifactsDir>
+    <ArtifactsDir Condition=" HasTrailingSlash('$(ArtifactsDir)') ">$(ArtifactsDir.Substring(0, $([MSBuild]::Subtract($(ArtifactsDir.Length), 1))))</ArtifactsDir>
 
     <PublishDependsOnTargets>$(PublishDependsOnTargets);_PublishInstallersAndChecksums</PublishDependsOnTargets>
 
@@ -49,12 +49,10 @@
       <!-- Do not push .nupkg files from Linux and macOS builds. They'll be packed up separately and signed on Windows. -->
       <ItemsToPushToBlobFeed Remove="@(ItemsToPushToBlobFeed)" Condition="'$(OS)' != 'Windows_NT'" />
 
-      <!-- Skip publishing checksums for now - the checksums for the .zip files don't match (https://github.com/dotnet/aspnetcore/issues/18792)
       <ItemsToPushToBlobFeed Include="@(_ChecksumsToPublish)">
         <PublishFlatContainer>true</PublishFlatContainer>
         <RelativeBlobPath>$(_UploadPathRoot)/Runtime/$(_PackageVersion)/%(Filename)%(Extension)</RelativeBlobPath>
       </ItemsToPushToBlobFeed>
-      -->
 
       <ItemsToPushToBlobFeed Include="@(_InstallersToPublish)">
         <IsShipping>true</IsShipping>

+ 0 - 6
src/Framework/src/Microsoft.AspNetCore.App.Runtime.csproj

@@ -154,12 +154,6 @@ This package is an internal implementation of the .NET Core SDK and is not meant
     <RedistArchiveOutputPath>$(InstallersOutputPath)$(RedistArchiveOutputFileName)</RedistArchiveOutputPath>
   </PropertyGroup>
 
-  <ItemGroup Condition="'$(DotNetBuildFromSource)' != 'true'">
-    <GenerateChecksumItems Include="$(RedistArchiveOutputPath)">
-      <DestinationPath>$(RedistArchiveOutputPath)$(ChecksumExtension)</DestinationPath>
-    </GenerateChecksumItems>
-  </ItemGroup>
-
   <!-- Target chain -->
   <PropertyGroup>
     <ResolveReferencesDependsOn>

+ 1 - 7
src/Installers/Windows/Wix.targets

@@ -64,7 +64,7 @@
 
   <Target Name="CopyToArtifactsDirectory"
           Condition=" '$(IsShipping)' == 'true' AND '$(SkipCopyToArtifactsDirectory)' != 'true' "
-          AfterTargets="Build" BeforeTargets="GenerateChecksums">
+          BeforeTargets="Build">
     <Copy SourceFiles="$(TargetPath)" DestinationFiles="$(InstallersOutputPath)$(PackageFileName)" />
     <ItemGroup>
       <_cabs Include="$(TargetDir)**/*.cab" />
@@ -72,10 +72,4 @@
     <Copy SourceFiles="@(_cabs)" DestinationFolder="$(InstallersOutputPath)" />
   </Target>
 
-  <ItemGroup Condition=" '$(IsShipping)' == 'true' AND '$(SkipCopyToArtifactsDirectory)' != 'true' ">
-    <GenerateChecksumItems Include="$(InstallersOutputPath)$(PackageFileName)">
-      <DestinationPath>$(InstallersOutputPath)$(PackageFileName)$(ChecksumExtension)</DestinationPath>
-    </GenerateChecksumItems>
-  </ItemGroup>
-
 </Project>