* Generate checksums for NuGet packages after signing.
* Generate package checksums only after that Pack task.
During publish, collect checksum files and calculate blob path.
Have official build publish checksum files.
* Set PublishFlatContainer to true
* Specify if checksum corresponds to shipping package.
* Fix type
* Only generate checksums for packages that declare a blob group.
Upload checksums to blob storage with blob group in relative blob path.
* Use target batching for CollectPackageChecksumFiles to correctly read blob group files.
# The variables get imported from group dotnet-diagnostics-sdl-params
enableSourceLinkValidation: true
symbolPublishingAdditionalParameters: '/p:PublishSpecialClrFiles=false'
+ publishInstallersAndChecksums: true
SDLValidationParameters:
enable: true
continueOnError: false
--- /dev/null
+<Project>
+
+ <PropertyGroup>
+ <!-- Since Arcade SDK's AfterSigning.proj file does not import the Arcard SDK, this
+ setting is necessary because we are manually importing the Arcade SDK targets
+ below in order to get the GenerateChecksums target. -->
+ <_SuppressSdkImports>false</_SuppressSdkImports>
+ </PropertyGroup>
+
+ <Target Name="CollectGenerateChecksumItems">
+ <ItemGroup>
+ <NuGetPackageFile Include="$(ArtifactsPackagesDir)**\*.nupkg" />
+ <GenerateChecksumItems Include="%(NuGetPackageFile.Identity)"
+ Condition="$([System.IO.File]::Exists('%(NugetPackageFile.Identity).blobgroup'))" >
+ <DestinationPath>%(FullPath).sha512</DestinationPath>
+ </GenerateChecksumItems>
+ </ItemGroup>
+ </Target>
+
+ <Target Name="GenerateSignedPackageChecksums"
+ AfterTargets="Pack"
+ DependsOnTargets="CollectGenerateChecksumItems;GenerateChecksums" />
+
+ <Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
+
+</Project>
\ No newline at end of file
--- /dev/null
+<Project>
+
+ <PropertyGroup>
+ <PublishDependsOnTargets>$(PublishDependsOnTargets);CollectPackageChecksumFiles</PublishDependsOnTargets>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageChecksumFile Include="$(ArtifactsShippingPackagesDir)**\*.sha512" IsShipping="true" />
+ <PackageChecksumFile Include="$(ArtifactsNonShippingPackagesDir)**\*.sha512" IsShipping="false" />
+ </ItemGroup>
+
+ <!-- Run the CollectPackageChecksumFiles target on each PackageChecksunFile by target batching on a non-existing file.
+ This allows using the ReadLinesFromFile task to read the blob group file, which was written with WriteLinesToFile,
+ thus avoiding erroneously reading in the newline at the end of the blob group file. -->
+ <Target Name="CollectPackageChecksumFiles"
+ Inputs="@(PackageChecksumFile)"
+ Outputs="%(PackageChecksumFile.Identity).notexist">
+ <!-- Find the blob group file next to the checksum file. -->
+ <PropertyGroup>
+ <_BlobGroupFilePath>%(PackageChecksumFile.RootDir)%(PackageChecksumFile.Directory)%(PackageChecksumFile.Filename).blobgroup</_BlobGroupFilePath>
+ </PropertyGroup>
+ <Error Message="Blob group file '$(_BlobGroupFilePath)' does not exist."
+ Condition="!Exists('$(_BlobGroupFilePath)')" />
+ <!-- Read in blob group name -->
+ <ReadLinesFromFile File="$(_BlobGroupFilePath)">
+ <Output TaskParameter="Lines" PropertyName="_BlobGroupName"/>
+ </ReadLinesFromFile>
+ <!-- Add ItemsToPushToBlobFeed for checksum file using blob group in relative blob path. -->
+ <ItemGroup>
+ <ItemsToPushToBlobFeed Include="%(PackageChecksumFile.Identity)">
+ <RelativeBlobPath>diagnostics/$(_BlobGroupName)/%(PackageChecksumFile.Filename)%(PackageChecksumFile.Extension)</RelativeBlobPath>
+ <ManifestArtifactData Condition="'%(PackageChecksumFile.IsShipping)' != 'true'">NonShipping=true</ManifestArtifactData>
+ <PublishFlatContainer>true</PublishFlatContainer>
+ </ItemsToPushToBlobFeed>
+ </ItemGroup>
+ </Target>
+
+</Project>
\ No newline at end of file
AfterTargets="PostBuildEvent"
Condition="$(NeedsPublishing) == 'true'"
DependsOnTargets="$(_BeforePublishNoBuildTargets);$(_CorePublishTargets)" />
+
+ <!-- Creates a file for packaged projects that declare a blog group prefix so that
+ publishing can use it in the blob path calculation. -->
+ <Target Name="GenerateBlobGroupFile"
+ AfterTargets="Pack"
+ Condition="'$(IsPackable)' == 'true' and '$(BlobGroupPrefix)' != ''">
+ <PropertyGroup>
+ <_BlobGroupVersionMajor>$(PackageVersion.Split('.')[0])</_BlobGroupVersionMajor>
+ <_BlobGroupVersionMinor>$(PackageVersion.Split('.')[1])</_BlobGroupVersionMinor>
+ <_BlobGroupName>$(BlobGroupPrefix)$(_BlobGroupVersionMajor).$(_BlobGroupVersionMinor)</_BlobGroupName>
+ </PropertyGroup>
+ <WriteLinesToFile File="$(PackageOutputPath)\$(PackageId).$(PackageVersion).nupkg.blobgroup"
+ Lines="$(_BlobGroupName)"
+ Overwrite="true" />
+ </Target>
</Project>
<PackageTags>Diagnostic</PackageTags>
<IsShipping>false</IsShipping>
<PackageReleaseNotes>$(Description)</PackageReleaseNotes>
+ <!-- This forces the creation of a checksum file and uploads it to blob storage
+ using this name as part of the blob relative path. -->
+ <BlobGroupPrefix>monitor</BlobGroupPrefix>
</PropertyGroup>
<ItemGroup>