mirror of https://github.com/dotnet/runtime
Unify dotnet/runtime on using Arcade -publish (#108990)
* Unify dotnet/runtime on using Arcade -publish Fixes https://github.com/dotnet/source-build/issues/4239 Replaces https://github.com/dotnet/runtime/pull/100004 Co-authored By: Viktor Hofer <viktor.hofer@microsoft.com> * Use DotNetBuildOrchestrator to avoid executing in a repo source-build context. * Actually, we want this logic to run only when we're running in a non-VMR-like context, even repo build. * Restore, but only restore the toolset in the publish job * Fix Exists check and do the "restore toolset only" check one degree away from the Arcade SDK. * Set the "publish using pipelines" global property when publishing * Don't produce the product version files on repo source build.
This commit is contained in:
parent
e11b86724f
commit
9e59acb298
|
@ -1,6 +1,6 @@
|
|||
<Project Sdk="Microsoft.Build.Traversal">
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup Condition="'$(RestoreToolsetOnly)' != 'true'">
|
||||
<!-- Subsets are already imported by Directory.Build.props. -->
|
||||
<ProjectReference Include="@(ProjectToBuild)" />
|
||||
<!-- Only include tasks.proj during restore and build incrementally via a target. -->
|
||||
|
|
|
@ -194,30 +194,4 @@
|
|||
<Analyzer Remove="@(_targetingPackExcludedAnalyzerReferenceWithProjectName->Metadata('OriginalIdentity'))" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Arcade SDK versioning is defined by static properties in a targets file: work around this by
|
||||
moving properties based on versioning into a target.
|
||||
-->
|
||||
<Target Name="GetProductVersions">
|
||||
<PropertyGroup>
|
||||
<IncludePreReleaseLabelInPackageVersion Condition="'$(DotNetFinalVersionKind)' != 'release'">true</IncludePreReleaseLabelInPackageVersion>
|
||||
<IncludePreReleaseLabelInPackageVersion Condition="'$(SuppressFinalPackageVersion)' == 'true'">true</IncludePreReleaseLabelInPackageVersion>
|
||||
<IncludePreReleaseLabelInPackageVersion Condition="'$(IsShipping)' != 'true'">true</IncludePreReleaseLabelInPackageVersion>
|
||||
|
||||
<IncludeBuildNumberInPackageVersion Condition="'$(StabilizePackageVersion)' != 'true'">true</IncludeBuildNumberInPackageVersion>
|
||||
<IncludeBuildNumberInPackageVersion Condition="'$(SuppressFinalPackageVersion)' == 'true'">true</IncludeBuildNumberInPackageVersion>
|
||||
<IncludeBuildNumberInPackageVersion Condition="'$(IsShipping)' != 'true'">true</IncludeBuildNumberInPackageVersion>
|
||||
|
||||
<ProductVersionSuffix Condition="'$(IncludePreReleaseLabelInPackageVersion)' == 'true'">-$(VersionSuffix)</ProductVersionSuffix>
|
||||
<ProductBandVersion Condition="'$(ProductBandVersion)' == ''">$(MajorVersion).$(MinorVersion)</ProductBandVersion>
|
||||
<ProductionVersion Condition="'$(ProductionVersion)' == ''">$(ProductBandVersion).$(PatchVersion)</ProductionVersion>
|
||||
<ProductVersion>$(ProductionVersion)$(ProductVersionSuffix)</ProductVersion>
|
||||
|
||||
<SharedFrameworkNugetVersion>$(ProductVersion)</SharedFrameworkNugetVersion>
|
||||
<NuGetVersion>$(SharedFrameworkNugetVersion)</NuGetVersion>
|
||||
<InstallersRelativePath>Runtime/$(SharedFrameworkNugetVersion)/</InstallersRelativePath>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,39 +1,206 @@
|
|||
<Project>
|
||||
<Project InitialTargets="ValidateDownloadedAssets">
|
||||
|
||||
<PropertyGroup>
|
||||
<ProducesDotNetReleaseShippingAssets>true</ProducesDotNetReleaseShippingAssets>
|
||||
<!-- This avoids creating VS.*.symbols.nupkg packages that are identical to the original package. -->
|
||||
<AutoGenerateSymbolPackages>false</AutoGenerateSymbolPackages>
|
||||
<!-- Set PlatformName to TargetArchitecture to create unique build manifest files. -->
|
||||
<PlatformName Condition="'$(TargetArchitecture)' != ''">$(TargetArchitecture)</PlatformName>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Include installer archives and packages which aren't globbed by default.
|
||||
Don't include Symbols archive as it is already included in Arcade's Publish.proj, with correct blob path. -->
|
||||
<Target Name="PublishRuntimeInstallers"
|
||||
BeforeTargets="BeforePublish"
|
||||
Condition="'$(DotNetBuildRepo)' == 'true'">
|
||||
<!-- Retrieve runtime's runtime pack product version.
|
||||
<!--
|
||||
Look through the downloaded artifacts to figure out how to ship them. Creates item groups for
|
||||
other types of publishing to use.
|
||||
|
||||
DownloadDirectory is expected to have some directory inside, which then contains a dir for each
|
||||
build job name. For example, this nupkg would be found:
|
||||
|
||||
$(DownloadDirectory)IntermediateArtifacts\windows_x64\Shipping\a.nupkg
|
||||
-->
|
||||
<ItemGroup Condition="'$(DotNetBuildRepo)' != 'true'">
|
||||
<DownloadedArtifactFile Include="$(DownloadDirectory)**" />
|
||||
<DownloadedSymbolNupkgFile Include="$(DownloadDirectory)**\*.symbols.nupkg" />
|
||||
<DownloadedWixPdbFile Include="$(DownloadDirectory)**\*.wixpdb" />
|
||||
<DownloadedWixpackFile Include="$(DownloadDirectory)**\*.wixpack.zip" Condition="'$(PostBuildSign)' != 'true'" />
|
||||
<DownloadedWorkloadsVSInsertionFile Include="$(DownloadDirectory)*\workloads-vs\**\*" />
|
||||
<DownloadedNupkgFile Include="$(DownloadDirectory)**\*.nupkg" Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!-- Exclude symbol packages from have a NuGet signature. These are never pushed to NuGet.org or
|
||||
other feeds (in fact, that have identical identity to their non-symbol variant) -->
|
||||
<DownloadedSymbolPackagesWithoutPaths Include="@(DownloadedSymbolNupkgFile->'%(Filename)%(Extension)')" />
|
||||
<FileSignInfo Include="@(DownloadedSymbolPackagesWithoutPaths->Distinct())" CertificateName="None" />
|
||||
|
||||
<!-- Add files that are not affected by filtering and create checksum for them. -->
|
||||
<UploadToBlobStorageFile
|
||||
Include="@(DownloadedArtifactFile)"
|
||||
Exclude="@(DownloadedSymbolNupkgFile);
|
||||
@(DownloadedNupkgFile);
|
||||
@(DownloadedWixPdbFile);
|
||||
@(DownloadedWorkloadsVSInsertionFile);
|
||||
@(DownloadedWixpackFile)" />
|
||||
|
||||
<!--
|
||||
Filter out the RID-specific (Runtime) nupkgs and RID-agnostic nupkgs. RID-specific packages
|
||||
are published from every job. RID-agnostic nupkgs are built with the same ID/version by
|
||||
every job, so one specific job's outputs must be picked to sign and publish.
|
||||
-->
|
||||
|
||||
<!-- RID-specific framework packs. -->
|
||||
<RuntimeNupkgFile
|
||||
Include="
|
||||
$(DownloadDirectory)**\Microsoft.*.Runtime.*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.*.App.Host.*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.*.App.Crossgen2.*.nupkg"
|
||||
Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!-- VS insertion packages, carrying RID-specific installers. -->
|
||||
<RuntimeNupkgFile
|
||||
Include="$(DownloadDirectory)**\VS.Redist.Common.*.nupkg"
|
||||
Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!--
|
||||
Workloads VS insertion artifacts produced by src/workloads/workloads.csproj. Only grab
|
||||
the zip artifacts as they're grouped by SDK feature band which correlates with specific VS versions.
|
||||
-->
|
||||
<WorkloadsVSInsertionFile Include="$(DownloadDirectory)*\workloads-vs\**\*.zip" />
|
||||
|
||||
<!--
|
||||
Runtime packages associated with some identity packages. Need to exclude "runtime.native.*"
|
||||
because Libraries produces some "runtime.native.Foo" packages with
|
||||
"runtime.<rid>.runtime.native.Foo" identity packages.
|
||||
-->
|
||||
<RuntimeNupkgFile
|
||||
Include="$(DownloadDirectory)**\runtime.*.nupkg"
|
||||
Exclude="
|
||||
$(DownloadDirectory)**\runtime.native.*.nupkg;
|
||||
@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!--
|
||||
Packages that aren't matched above as RID-specific are considered RID-agnostic. Also include
|
||||
the AllConfigurations packages from the Libraries build.
|
||||
-->
|
||||
<RidAgnosticNupkgToPublishFile
|
||||
Include="
|
||||
$(DownloadDirectory)**\Microsoft.NET.Workload.Mono.Toolchain.*Manifest-*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.NET.Sdk.WebAssembly.Pack.*.nupkg;
|
||||
$(DownloadDirectory)*\$(PublishRidAgnosticPackagesFromPlatform)\**\*.nupkg;
|
||||
$(DownloadDirectory)*\*AllConfigurations\**\*.nupkg"
|
||||
Exclude="@(RuntimeNupkgFile);@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<TransportPackagesToPublishFile
|
||||
Include="$(DownloadDirectory)**\*Transport*.nupkg"
|
||||
Exclude="@(RuntimeNupkgFile);@(RidAgnosticNupkgToPublishFile);@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<NupkgToPublishFile Include="@(RuntimeNupkgFile);@(RidAgnosticNupkgToPublishFile);@(TransportPackagesToPublishFile)" />
|
||||
|
||||
<!--
|
||||
Assuming all symbol packages ship and can be found by turning .nupkg => .symbols.nupkg, find
|
||||
them. Don't check for missing symbol packages here: some nupkgs don't have them for valid
|
||||
reasons, such as the VS insertion packages that transport MSIs. Symbol package validation
|
||||
will check for symbol completeness with file-by-file granularity rather than looking for
|
||||
missing symbols.nupkg files: https://github.com/dotnet/arcade/issues/2499.
|
||||
|
||||
Handles several conventions:
|
||||
* NonShipping packages have symbol nupkgs that are Shipping.
|
||||
* Shipping packages have symbol packages in a "symbols" subdirectory.
|
||||
-->
|
||||
<PotentialSymbolNupkgToPublishFile
|
||||
Include="
|
||||
@(NupkgToPublishFile->Replace('\NonShipping\', '\Shipping\')->Replace('.nupkg', '.symbols.nupkg'));
|
||||
@(NupkgToPublishFile->Replace('\NonShipping\', '\NonShipping\symbols\')->Replace('.nupkg', '.symbols.nupkg'));
|
||||
@(NupkgToPublishFile->Replace('\Shipping\', '\Shipping\symbols\')->Replace('.nupkg', '.symbols.nupkg'))" />
|
||||
|
||||
<SymbolNupkgToPublishFile Include="@(PotentialSymbolNupkgToPublishFile->Distinct()->Exists())" />
|
||||
|
||||
<!-- Packages -->
|
||||
<Artifact Include="@(NupkgToPublishFile)"
|
||||
IsShipping="$([System.String]::new('%(Identity)').Contains('\Shipping\'))"
|
||||
PublishFlatContainer="false" />
|
||||
<Artifact Include="@(SymbolNupkgToPublishFile)" PublishFlatContainer="false" />
|
||||
|
||||
<!-- Blob storage -->
|
||||
<Artifact Include="@(UploadToBlobStorageFile)"
|
||||
Exclude="@(NupkgToPublishFile);@(SymbolNupkgToPublishFile)"
|
||||
IsShipping="$([System.String]::new('%(Identity)').Contains('\Shipping\'))"
|
||||
ChecksumPath="%(FullPath).sha512" />
|
||||
<Artifact Include="@(WorkloadsVSInsertionFile)"
|
||||
SubBlobFolder="workloads/"
|
||||
IsShipping="$([System.String]::new('%(Identity)').Contains('\Shipping\'))" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="GetNonStableProductVersion">
|
||||
<!-- Retrieve the non-stable runtime pack product version.
|
||||
Don't stabilize the package version in order to retrieve the VersionSuffix. -->
|
||||
<MSBuild Projects="$(RepoRoot)src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj"
|
||||
Targets="ReturnProductVersion"
|
||||
Properties="IsShipping=false;
|
||||
Crossgen2SdkOverridePropsPath=;
|
||||
Crossgen2SdkOverrideTargetsPath=">
|
||||
<Output TaskParameter="TargetOutputs" PropertyName="RuntimeRuntimePackProductVersion" />
|
||||
<Output TaskParameter="TargetOutputs" PropertyName="NonStableProductVersion" />
|
||||
</MSBuild>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Only generate the productVersion.txt and runtime-productVersion.txt files when we're building
|
||||
either the full VMR repo or not building in the VMR infrastructure.
|
||||
This ensures that we don't produce these files in the "Repo source build" builds,
|
||||
but we do produce them in both the VMR and the runtime official build.
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<_ShouldGenerateProductVersionFiles Condition="'$(DotNetBuildRepo)' == 'true' and '$(DotNetBuildOrchestrator)' == 'true'">true</_ShouldGenerateProductVersionFiles>
|
||||
<_ShouldGenerateProductVersionFiles Condition="'$(DotNetBuildRepo)' != 'true' and '$(DotNetBuildOrchestrator)' != 'true'">true</_ShouldGenerateProductVersionFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="GenerateProductVersionFiles"
|
||||
DependsOnTargets="GetNonStableProductVersion"
|
||||
BeforeTargets="PublishToAzureDevOpsArtifacts"
|
||||
Condition="'$(_ShouldGenerateProductVersionFiles)' == 'true'">
|
||||
<!-- Retrieve the runtime pack product version. -->
|
||||
<MSBuild Projects="$(RepoRoot)src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj"
|
||||
Targets="ReturnProductVersion"
|
||||
Properties="Crossgen2SdkOverridePropsPath=;
|
||||
Crossgen2SdkOverrideTargetsPath=">
|
||||
<Output TaskParameter="TargetOutputs" PropertyName="ProductVersionForVersionsFile" />
|
||||
</MSBuild>
|
||||
|
||||
<ItemGroup>
|
||||
<InstallerToPublish Include="$(ArtifactsPackagesDir)**\*.tar.gz;
|
||||
$(ArtifactsPackagesDir)**\*.zip;
|
||||
$(ArtifactsPackagesDir)**\*.deb;
|
||||
$(ArtifactsPackagesDir)**\*.rpm;
|
||||
$(ArtifactsPackagesDir)**\*.pkg;
|
||||
$(ArtifactsPackagesDir)**\*.exe;
|
||||
$(ArtifactsPackagesDir)**\*.msi"
|
||||
Exclude="$(ArtifactsPackagesDir)**\Symbols.runtime.tar.gz" />
|
||||
<ProductVersionFile Include="$(ArtifactsShippingPackagesDir)productVersion.txt" />
|
||||
<ProductVersionFile Include="$(ArtifactsShippingPackagesDir)runtime-productVersion.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemsToPushToBlobFeed Include="@(InstallerToPublish)"
|
||||
IsShipping="$([System.String]::Copy('%(RecursiveDir)').StartsWith('Shipping'))"
|
||||
PublishFlatContainer="true"
|
||||
RelativeBlobPath="Runtime/$(RuntimeRuntimePackProductVersion)/%(Filename)%(Extension)" />
|
||||
<!-- Generate productVersion.txt file containing the product version. -->
|
||||
<WriteLinesToFile File="%(ProductVersionFile.Identity)"
|
||||
Lines="$(ProductVersionForVersionsFile)"
|
||||
Overwrite="true"
|
||||
Encoding="ASCII" />
|
||||
|
||||
<ItemGroup>
|
||||
<Artifact Include="@(ProductVersionFile)"
|
||||
RelativeBlobPath="Runtime/$(NonStableProductVersion)/%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
<Target Name="AddRelativeBlobPathToInstallerArtifacts"
|
||||
DependsOnTargets="GetNonStableProductVersion"
|
||||
BeforeTargets="PublishToAzureDevOpsArtifacts"
|
||||
AfterTargets="GenerateChecksumsFromArtifacts">
|
||||
<ItemGroup>
|
||||
<Artifact Condition="'%(Artifact.PublishFlatContainer)' == 'true' and '%(Artifact.RelativeBlobPath)' == ''"
|
||||
RelativeBlobPath="Runtime/$(NonStableProductVersion)/%(Artifact.SubBlobFolder)%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="ValidateDownloadedAssets" Condition="'$(DotNetBuildRepo)' != 'true'">
|
||||
<Error Text="DownloadDirectory is not set." Condition="'$(DownloadDirectory)' == ''" />
|
||||
<Error Condition="'@(SymbolNupkgToPublishFile)' == ''" Text="No symbol packages found." />
|
||||
|
||||
<!--
|
||||
Duplicate RuntimeNupkgFile items mean artifact upload will fail, but only after another hour
|
||||
of signing. Detect this early. It's possible to automatically "fix" this with Distinct(),
|
||||
however the patterns should be fairly specific: this is likely a build infra mistake that
|
||||
should be corrected.
|
||||
-->
|
||||
<Error Text="Duplicate RuntimeNupkgFile entries for: %(RuntimeNupkgFile.Identity)" Condition="@(RuntimeNupkgFile->Count()) > 1" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -206,7 +206,6 @@
|
|||
<SubsetName Include="Packs.Tests" Description="The framework pack tests." />
|
||||
|
||||
<!-- Utility -->
|
||||
<SubsetName Include="publish" OnDemand="true" Description="Generate asset manifests and prepare to publish to BAR." />
|
||||
<SubsetName Include="RegenerateDownloadTable" OnDemand="true" Description="Regenerates the nightly build download table" />
|
||||
<SubsetName Include="RegenerateThirdPartyNotices" OnDemand="true" Description="Regenerates the THIRD-PARTY-NOTICES.TXT file based on other repos' TPN files." />
|
||||
<SubsetName Include="tasks" OnDemand="true" Description="Build the repo local task projects." />
|
||||
|
@ -560,10 +559,6 @@
|
|||
<ProjectToBuild Include="@(TestProjectToBuild)" BuildInParallel="true" Test="true" Category="packs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="$(_subset.Contains('+publish+'))">
|
||||
<ProjectToBuild Include="$(InstallerProjectRoot)prepare-artifacts.proj" Pack="true" Category="publish" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Utility -->
|
||||
<ItemGroup Condition="$(_subset.Contains('+regeneratedownloadtable+'))">
|
||||
<ProjectToBuild Include="$(RepositoryEngineeringDir)regenerate-download-table.proj" Pack="true" />
|
||||
|
|
|
@ -43,13 +43,14 @@ jobs:
|
|||
|
||||
steps:
|
||||
- script: >-
|
||||
build.cmd -ci
|
||||
-subset publish
|
||||
-configuration Release
|
||||
build.cmd -restore -sign -publish -ci -configuration Release
|
||||
/p:RestoreToolsetOnly=true
|
||||
/p:PublishRidAgnosticPackagesFromPlatform=${{ parameters.PublishRidAgnosticPackagesFromPlatform }}
|
||||
/p:DownloadDirectory=$(Build.SourcesDirectory)\artifacts\PackageDownload\
|
||||
/p:OfficialBuildId=$(Build.BuildNumber)
|
||||
/p:SignType=$(_SignType)
|
||||
/p:DotNetSignType=$(_SignType)
|
||||
/p:DotNetPublishUsingPipelines=true
|
||||
/bl:$(Build.SourcesDirectory)\prepare-artifacts.binlog
|
||||
displayName: Prepare artifacts and upload to build
|
||||
|
||||
|
|
|
@ -14,11 +14,4 @@
|
|||
want to ensure we use the correct packages. -->
|
||||
<DisableImplicitNuGetFallbackFolder>true</DisableImplicitNuGetFallbackFolder>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Construct the path to the sign project, so that signing can be called during prepare-artifacts -->
|
||||
<PropertyGroup>
|
||||
<ArcadeSdkMSBuildProjectDir>$([System.IO.Path]::GetDirectoryName('$(ArcadeSdkBuildTasksAssembly)'))\..\</ArcadeSdkMSBuildProjectDir>
|
||||
<ArcadeSdkSignProject>$(ArcadeSdkMSBuildProjectDir)Sign.proj</ArcadeSdkSignProject>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
If we are stabilizing set the StableVersion property for the packages.
|
||||
Needs to happen in Directory.Build.targets to allow all the pkgproj's to set Version property first.
|
||||
-->
|
||||
<StableVersion Condition="'$(IncludePreReleaseLabelInPackageVersion)' != 'true'">$(Version)</StableVersion>
|
||||
<StableVersion Condition="'$(DotNetFinalVersionKind)' == 'release' and
|
||||
'$(SuppressFinalPackageVersion)' != 'true' and
|
||||
'$(IsShipping)' == 'true'">$(Version)</StableVersion>
|
||||
|
||||
<!--
|
||||
Explicitly re-set the symbol package output path. The pkgproj files here end up importing the targets from
|
||||
|
@ -16,20 +18,6 @@
|
|||
<SymbolPackageOutputPath>$(PackageOutputPath)</SymbolPackageOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="SetTargetBasedPackageVersion"
|
||||
BeforeTargets="GenerateNuSpec"
|
||||
DependsOnTargets="GetProductVersions">
|
||||
<PropertyGroup>
|
||||
<Version>$(ProductVersion)</Version>
|
||||
<!--
|
||||
PackageVersion is normally calculated using Version during static property evaluation, but
|
||||
we need some info from GetProductVersions, so it's too late to rely on that. We need to set
|
||||
both in target evaluation, here.
|
||||
-->
|
||||
<PackageVersion>$(ProductVersion)</PackageVersion>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Remove duplicate files returned by restore. The resolve task performs extra detection to pick up
|
||||
a PDB file for any file listed in the assets file. This causes duplicates if the assets file
|
||||
|
|
|
@ -1,307 +0,0 @@
|
|||
<Project Sdk="Microsoft.Build.NoTargets">
|
||||
<PropertyGroup>
|
||||
<!-- Set IsStableBuild to mimic https://github.com/dotnet/arcade/blob/694d59f090b743f894779d04a7ffe11cbaf352e7/src/Microsoft.DotNet.Arcade.Sdk/tools/Publish.proj#L30-L31 -->
|
||||
<IsStableBuild>false</IsStableBuild>
|
||||
<IsStableBuild Condition="'$(DotNetFinalVersionKind)' == 'release'">true</IsStableBuild>
|
||||
|
||||
<ChecksumExtension>.sha512</ChecksumExtension>
|
||||
<DownloadDirectory>$(ArtifactsDir)PackageDownload/</DownloadDirectory>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.DotNet.Build.Tasks.Feed" Version="$(MicrosoftDotNetBuildTasksFeedVersion)" />
|
||||
<PackageReference Include="Microsoft.DotNet.VersionTools.Tasks" Version="$(MicrosoftDotNetVersionToolsTasksVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- When doing post build sign, pull in the arcade sign.props file, which will
|
||||
create some initial sign groups and then pulls in the repo's custom Signing.props overrides.
|
||||
Before importing the signing props. Depending on context (SDK project vs. not),
|
||||
the initial imports of livebuilds.targets and Configuration.props are already imported and thus cannot
|
||||
be imported again. Without those imports, the globbing of files to sign will not work properly. -->
|
||||
<Import Project="../tools/Sign.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
|
||||
|
||||
<Import Project="$(RepositoryEngineeringDir)Publishing.props" Condition="Exists('$(RepositoryEngineeringDir)Publishing.props')" />
|
||||
|
||||
<UsingTask TaskName="GenerateChecksums" AssemblyFile="$(InstallerTasksAssemblyPath)" />
|
||||
|
||||
<PropertyGroup>
|
||||
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Pulled from arcade's publish.proj see https://github.com/dotnet/arcade/issues/5790 for
|
||||
issue on making this common in arcade so it doesn't have to be duplicated here -->
|
||||
<PropertyGroup>
|
||||
<CollectionUri>$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)</CollectionUri>
|
||||
|
||||
<!-- When we have dev.azure.com/<account>/ -->
|
||||
<AzureDevOpsAccount Condition="$(CollectionUri.IndexOf('dev.azure.com')) >= 0">$(CollectionUri.Split('/')[3])</AzureDevOpsAccount>
|
||||
|
||||
<!-- When we have <account>.visualstudio.com -->
|
||||
<AzureDevOpsAccount Condition="$(CollectionUri.IndexOf('visualstudio.com')) >= 0">$(CollectionUri.Split('.')[0].Split('/')[2])</AzureDevOpsAccount>
|
||||
</PropertyGroup>
|
||||
|
||||
<!--
|
||||
The new Maestro/BAR build model keeps separate Azure DevOps and GitHub build information.
|
||||
The GitHub information will be extracted based on the Azure DevOps repository.
|
||||
-->
|
||||
<ItemGroup>
|
||||
<ManifestBuildData Include="InitialAssetsLocation=$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$(SYSTEM_TEAMPROJECT)/_apis/build/builds/$(BUILD_BUILDID)/artifacts" />
|
||||
<ManifestBuildData Include="AzureDevOpsBuildId=$(BUILD_BUILDID)" />
|
||||
<ManifestBuildData Include="AzureDevOpsBuildDefinitionId=$(SYSTEM_DEFINITIONID)" />
|
||||
<ManifestBuildData Include="AzureDevOpsAccount=$(AzureDevOpsAccount)" />
|
||||
<ManifestBuildData Include="AzureDevOpsProject=$(SYSTEM_TEAMPROJECT)" />
|
||||
<ManifestBuildData Include="AzureDevOpsBuildNumber=$(BUILD_BUILDNUMBER)" />
|
||||
<ManifestBuildData Include="AzureDevOpsRepository=$(BUILD_REPOSITORY_URI)" />
|
||||
<ManifestBuildData Include="AzureDevOpsBranch=$(BUILD_SOURCEBRANCH)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Set metadata for assets that are not marked as NonShipping.
|
||||
This is used to determine if the asset should be shipped as part of .NET release.
|
||||
-->
|
||||
<ItemDefinitionGroup>
|
||||
<ItemsToPush>
|
||||
<ManifestArtifactData Condition="'$(ProducesDotNetReleaseShippingAssets)' == 'true'">DotNetReleaseShipping=true</ManifestArtifactData>
|
||||
</ItemsToPush>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
<Target Name="SignArtifacts"
|
||||
Condition="'$(PostBuildSign)' != 'true'" >
|
||||
<MSBuild
|
||||
Projects="$(ArcadeSdkSignProject)"
|
||||
Targets="Sign"
|
||||
Properties="
|
||||
DownloadDirectory=$(DownloadDirectory)" />
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Take assets from the build jobs, prepare them for publishing (signing, arrangement) then upload
|
||||
them to the pipeline for Arcade and custom steps to publish.
|
||||
-->
|
||||
<Target Name="PreparePublishToAzureBlobFeed"
|
||||
AfterTargets="Build"
|
||||
DependsOnTargets="GetProductVersions;FindDownloadedArtifacts;SignArtifacts;CreateChecksums">
|
||||
<PropertyGroup>
|
||||
<AssetManifestFilename>Manifest.xml</AssetManifestFilename>
|
||||
<AssetManifestFile>$(ArtifactsLogDir)AssetManifest/$(AssetManifestFilename)</AssetManifestFile>
|
||||
|
||||
<ProductVersionTxtContents Condition="'$(StabilizePackageVersion)'=='true'">$(ProductionVersion)</ProductVersionTxtContents>
|
||||
<ProductVersionTxtContents Condition="'$(StabilizePackageVersion)'!='true'">$(ProductVersion)</ProductVersionTxtContents>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Generate productVersion.txt containing the value of $(PackageVersion) -->
|
||||
<WriteLinesToFile
|
||||
File="$(ArtifactsShippingPackagesDir)productVersion.txt"
|
||||
Lines="$(ProductVersionTxtContents)"
|
||||
Overwrite="true"
|
||||
Encoding="ASCII" />
|
||||
|
||||
<!-- Generate runtime-productVersion.txt containing the value of $(PackageVersion) -->
|
||||
<WriteLinesToFile
|
||||
File="$(ArtifactsShippingPackagesDir)runtime-productVersion.txt"
|
||||
Lines="$(ProductVersionTxtContents)"
|
||||
Overwrite="true"
|
||||
Encoding="ASCII" />
|
||||
|
||||
<ItemGroup>
|
||||
<ItemsToPush Remove="@(ItemsToPush)" />
|
||||
|
||||
<ItemsToPush Include="@(ShippingNupkgToPublishFile)" />
|
||||
<ItemsToPush Include="@(NonShippingNupkgToPublishFile)" ManifestArtifactData="NonShipping=true" />
|
||||
<ItemsToPush Include="@(SymbolNupkgToPublishFile)" />
|
||||
|
||||
<ItemsToPush
|
||||
Include="@(UploadToBlobStorageFile)"
|
||||
Exclude="@(NupkgToPublishFile);@(SymbolNupkgToPublishFile)">
|
||||
<RelativeBlobPath>$(InstallersRelativePath)%(Filename)%(Extension)</RelativeBlobPath>
|
||||
<PublishFlatContainer>true</PublishFlatContainer>
|
||||
</ItemsToPush>
|
||||
|
||||
<ItemsToPush Include="@(GeneratedChecksumFile)">
|
||||
<RelativeBlobPath>$(InstallersRelativePath)%(Filename)%(Extension)</RelativeBlobPath>
|
||||
<Category>Checksum</Category>
|
||||
<PublishFlatContainer>true</PublishFlatContainer>
|
||||
</ItemsToPush>
|
||||
|
||||
<ItemsToPush Include="$(ArtifactsShippingPackagesDir)productVersion.txt">
|
||||
<RelativeBlobPath>$(InstallersRelativePath)productVersion.txt</RelativeBlobPath>
|
||||
<PublishFlatContainer>true</PublishFlatContainer>
|
||||
</ItemsToPush>
|
||||
|
||||
<ItemsToPush Include="$(ArtifactsShippingPackagesDir)runtime-productVersion.txt">
|
||||
<RelativeBlobPath>$(InstallersRelativePath)runtime-productVersion.txt</RelativeBlobPath>
|
||||
<PublishFlatContainer>true</PublishFlatContainer>
|
||||
</ItemsToPush>
|
||||
|
||||
<ItemsToPush Include="@(WorkloadsVSInsertionFile)">
|
||||
<RelativeBlobPath>$(InstallersRelativePath)workloads/%(Filename)%(Extension)</RelativeBlobPath>
|
||||
<PublishFlatContainer>true</PublishFlatContainer>
|
||||
</ItemsToPush>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Push items to AzDO as build artifacts, generating the asset manifest as a side effect. -->
|
||||
<PushToBuildStorage
|
||||
AzureDevOpsCollectionUri="$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)"
|
||||
AzureDevOpsProject="$(SYSTEM_TEAMPROJECT)"
|
||||
AzureDevOpsBuildId="$(BUILD_BUILDID)"
|
||||
ItemsToSign="@(ItemsToSignPostBuild)"
|
||||
StrongNameSignInfo="@(StrongNameSignInfo)"
|
||||
FileSignInfo="@(FileSignInfo)"
|
||||
FileExtensionSignInfo="@(FileExtensionSignInfo)"
|
||||
ItemsToPush="@(ItemsToPush)"
|
||||
ManifestBuildData="@(ManifestBuildData)"
|
||||
ManifestRepoUri="$(BUILD_REPOSITORY_NAME)"
|
||||
ManifestBranch="$(BUILD_SOURCEBRANCH)"
|
||||
ManifestBuildId="$(BUILD_BUILDNUMBER)"
|
||||
ManifestCommit="$(BUILD_SOURCEVERSION)"
|
||||
IsStableBuild="$(IsStableBuild)"
|
||||
AssetManifestPath="$(AssetManifestFile)" />
|
||||
|
||||
<Message Importance="High" Text="Complete!" />
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Look through the downloaded artifacts to figure out how to ship them. Creates item groups for
|
||||
other types of publishing to use.
|
||||
|
||||
DownloadDirectory is expected to have some directory inside, which then contains a dir for each
|
||||
build job name. For example, this nupkg would be found:
|
||||
|
||||
$(DownloadDirectory)IntermediateUnsignedArtifacts\Windows_x64\Shipping\a.nupkg
|
||||
-->
|
||||
<Target Name="FindDownloadedArtifacts">
|
||||
|
||||
<ItemGroup>
|
||||
<DownloadedArtifactFile Include="$(DownloadDirectory)**" />
|
||||
|
||||
<Error
|
||||
Condition="'@(DownloadedArtifactFile)' == ''"
|
||||
Text="No downloaded artifacts found." />
|
||||
|
||||
<DownloadedSymbolNupkgFile Include="$(DownloadDirectory)**\*.symbols.nupkg" />
|
||||
<DownloadedWixPdbFile Include="$(DownloadDirectory)**\*.wixpdb" />
|
||||
<DownloadedWixpackFile Include="$(DownloadDirectory)**\*.wixpack.zip" Condition="'$(PostBuildSign)' != 'true'" />
|
||||
<DownloadedWorkloadsVSInsertionFile Include="$(DownloadDirectory)*\workloads-vs\**\*" />
|
||||
<DownloadedNupkgFile
|
||||
Include="$(DownloadDirectory)**\*.nupkg"
|
||||
Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!-- Add files that are not affected by filtering. -->
|
||||
<UploadToBlobStorageFile
|
||||
Include="@(DownloadedArtifactFile)"
|
||||
Exclude="@(DownloadedSymbolNupkgFile);@(DownloadedNupkgFile);@(DownloadedWixPdbFile);@(DownloadedWorkloadsVSInsertionFile);@(DownloadedWixpackFile)" />
|
||||
|
||||
<!--
|
||||
Filter out the RID-specific (Runtime) nupkgs and RID-agnostic nupkgs. RID-specific packages
|
||||
are published from every job. RID-agnostic nupkgs are built with the same ID/version by
|
||||
every job, so one specific job's outputs must be picked to sign and publish.
|
||||
-->
|
||||
|
||||
<!-- RID-specific framework packs. -->
|
||||
<RuntimeNupkgFile
|
||||
Include="
|
||||
$(DownloadDirectory)**\Microsoft.*.Runtime.*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.*.App.Host.*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.*.App.Crossgen2.*.nupkg"
|
||||
Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!-- VS insertion packages, carrying RID-specific installers. -->
|
||||
<RuntimeNupkgFile
|
||||
Include="$(DownloadDirectory)**\VS.Redist.Common.*.nupkg"
|
||||
Exclude="@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!--
|
||||
Workloads VS insertion artifacts produced by src/workloads/workloads.csproj. Only grab
|
||||
the zip artifacts as they're grouped by SDK feature band which correlates with specific VS versions.
|
||||
-->
|
||||
<WorkloadsVSInsertionFile
|
||||
Include="
|
||||
$(DownloadDirectory)*\workloads-vs\**\*.zip"/>
|
||||
|
||||
<!--
|
||||
Runtime packages associated with some identity packages. Need to exclude "runtime.native.*"
|
||||
because Libraries produces some "runtime.native.Foo" packages with
|
||||
"runtime.<rid>.runtime.native.Foo" identity packages.
|
||||
-->
|
||||
<RuntimeNupkgFile
|
||||
Include="$(DownloadDirectory)**\runtime.*.nupkg"
|
||||
Exclude="
|
||||
$(DownloadDirectory)**\runtime.native.*.nupkg;
|
||||
@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<!--
|
||||
Packages that aren't matched above as RID-specific are considered RID-agnostic. Also include
|
||||
the AllConfigurations packages from the Libraries build.
|
||||
-->
|
||||
<RidAgnosticNupkgToPublishFile
|
||||
Include="
|
||||
$(DownloadDirectory)**\Microsoft.NET.Workload.Mono.Toolchain.*Manifest-*.nupkg;
|
||||
$(DownloadDirectory)**\Microsoft.NET.Sdk.WebAssembly.Pack.*.nupkg;
|
||||
$(DownloadDirectory)*\$(PublishRidAgnosticPackagesFromPlatform)\**\*.nupkg;
|
||||
$(DownloadDirectory)*\*AllConfigurations\**\*.nupkg"
|
||||
Exclude="@(RuntimeNupkgFile);@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<TransportPackagesToPublishFile
|
||||
Include="$(DownloadDirectory)**\*Transport*.nupkg"
|
||||
Exclude="@(RuntimeNupkgFile);@(RidAgnosticNupkgToPublishFile);@(DownloadedSymbolNupkgFile)" />
|
||||
|
||||
<NupkgToPublishFile Include="@(RuntimeNupkgFile);@(RidAgnosticNupkgToPublishFile);@(TransportPackagesToPublishFile)" />
|
||||
|
||||
<!--
|
||||
Assuming all symbol packages ship and can be found by turning .nupkg => .symbols.nupkg, find
|
||||
them. Don't check for missing symbol packages here: some nupkgs don't have them for valid
|
||||
reasons, such as the VS insertion packages that transport MSIs. Symbol package validation
|
||||
will check for symbol completeness with file-by-file granularity rather than looking for
|
||||
missing symbols.nupkg files: https://github.com/dotnet/arcade/issues/2499.
|
||||
|
||||
Handles several conventions:
|
||||
* NonShipping packages have symbol nupkgs that are Shipping.
|
||||
* Shipping packages have symbol packages in a "symbols" subdirectory.
|
||||
-->
|
||||
<PotentialSymbolNupkgToPublishFile
|
||||
Include="
|
||||
@(NupkgToPublishFile->Replace('\NonShipping\', '\Shipping\')->Replace('.nupkg', '.symbols.nupkg'));
|
||||
@(NupkgToPublishFile->Replace('\NonShipping\', '\NonShipping\symbols\')->Replace('.nupkg', '.symbols.nupkg'));
|
||||
@(NupkgToPublishFile->Replace('\Shipping\', '\Shipping\symbols\')->Replace('.nupkg', '.symbols.nupkg'))" />
|
||||
|
||||
<SymbolNupkgToPublishFile
|
||||
Include="@(PotentialSymbolNupkgToPublishFile -> Distinct())"
|
||||
Condition="Exists('%(Identity)')" />
|
||||
|
||||
<!-- Split nupkgs into shipping/nonshipping for BAR categorization. -->
|
||||
<ShippingNupkgToPublishFile
|
||||
Include="@(NupkgToPublishFile)"
|
||||
Condition="$([System.String]::new('%(Identity)').Contains('\Shipping\'))" />
|
||||
|
||||
<NonShippingNupkgToPublishFile
|
||||
Include="@(NupkgToPublishFile)"
|
||||
Exclude="@(ShippingNupkgToPublishFile)" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<Error
|
||||
Condition="'@(SymbolNupkgToPublishFile)' == ''"
|
||||
Text="No symbol packages found." />
|
||||
|
||||
<!--
|
||||
Duplicate RuntimeNupkgFile items mean artifact upload will fail, but only after another hour
|
||||
of signing. Detect this early. It's possible to automatically "fix" this with Distinct(),
|
||||
however the patterns should be fairly specific: this is likely a build infra mistake that
|
||||
should be corrected.
|
||||
-->
|
||||
<Error
|
||||
Text="Duplicate RuntimeNupkgFile entries for: %(RuntimeNupkgFile.Identity)"
|
||||
Condition="@(RuntimeNupkgFile->Count()) > 1" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CreateChecksums">
|
||||
<ItemGroup>
|
||||
<ArtifactsForGeneratingChecksums Include="@(UploadToBlobStorageFile)"
|
||||
DestinationPath="%(FullPath)$(ChecksumExtension)" />
|
||||
<GeneratedChecksumFile Include="@(ArtifactsForGeneratingChecksums -> '%(DestinationPath)')" />
|
||||
</ItemGroup>
|
||||
|
||||
<GenerateChecksums Items="@(ArtifactsForGeneratingChecksums)" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -11,7 +11,6 @@
|
|||
<Target Name="SetupTestContextVariables"
|
||||
Condition="'$(IsTestProject)' == 'true'"
|
||||
DependsOnTargets="
|
||||
GetProductVersions;
|
||||
DetermineTestOutputDirectory"
|
||||
BeforeTargets="Build">
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -558,12 +558,19 @@
|
|||
<_RollupInputs Include="$(BrowserProjectRoot)runtime/*.js"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="SetMonoRollupEnvironment" DependsOnTargets="GetProductVersions">
|
||||
<Target Name="SetMonoRollupEnvironment">
|
||||
<!-- Retrieve the runtime pack product version. -->
|
||||
<MSBuild Projects="$(RepoRoot)src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.sfxproj"
|
||||
Targets="ReturnProductVersion"
|
||||
Properties="Crossgen2SdkOverridePropsPath=;
|
||||
Crossgen2SdkOverrideTargetsPath=">
|
||||
<Output TaskParameter="TargetOutputs" PropertyName="RuntimePackProductVersion" />
|
||||
</MSBuild>
|
||||
<ItemGroup>
|
||||
<_MonoRollupEnvironmentVariable Include="Configuration:$(Configuration)" />
|
||||
<_MonoRollupEnvironmentVariable Include="NativeBinDir:$(NativeBinDir)" />
|
||||
<_MonoRollupEnvironmentVariable Include="WasmObjDir:$(WasmObjDir)" />
|
||||
<_MonoRollupEnvironmentVariable Include="ProductVersion:$(ProductVersion)" />
|
||||
<_MonoRollupEnvironmentVariable Include="ProductVersion:$(RuntimePackProductVersion)" />
|
||||
<_MonoRollupEnvironmentVariable Include="WasmEnableThreads:$(WasmEnableThreads)" />
|
||||
<_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:1" Condition="'$(WasmEnableSIMD)' != 'false'" />
|
||||
<_MonoRollupEnvironmentVariable Include="WASM_ENABLE_SIMD:0" Condition="'$(WasmEnableSIMD)' == 'false'" />
|
||||
|
|
|
@ -27,10 +27,5 @@
|
|||
|
||||
<Target Name="CreateManifestResourceNames" />
|
||||
<Target Name="CoreCompile" />
|
||||
<Target Name="_SetProductVersion" DependsOnTargets="GetProductVersions" BeforeTargets="Pack">
|
||||
<PropertyGroup>
|
||||
<PackageVersion>$(ProductVersion)</PackageVersion>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<IncrementalNativeBuild Condition="'$(IncrementalNativeBuild)' == ''">true</IncrementalNativeBuild>
|
||||
<BuildCoreHostDependsOn>GetProductVersions;GenerateRuntimeVersionFile</BuildCoreHostDependsOn>
|
||||
<BuildCoreHostDependsOn>GenerateRuntimeVersionFile</BuildCoreHostDependsOn>
|
||||
<BuildCoreHostDependsOn Condition="'$(EnableSourceControlManagerQueries)' == 'true'">$(BuildCoreHostDependsOn);InitializeSourceControlInformationFromSourceControlManager</BuildCoreHostDependsOn>
|
||||
<IntermediateOutputRootPath>$(ArtifactsObjDir)$(OutputRID).$(Configuration)\</IntermediateOutputRootPath>
|
||||
<!-- Global location for version files -->
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using Microsoft.Build.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Microsoft.DotNet.Build.Tasks
|
||||
{
|
||||
public class GenerateChecksums : BuildTask
|
||||
{
|
||||
/// <summary>
|
||||
/// An item collection of files for which to generate checksums. Each item must have metadata
|
||||
/// 'DestinationPath' that specifies the path of the checksum file to create.
|
||||
/// </summary>
|
||||
[Required]
|
||||
public ITaskItem[] Items { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
foreach (ITaskItem item in Items)
|
||||
{
|
||||
try
|
||||
{
|
||||
string destinationPath = item.GetMetadata("DestinationPath");
|
||||
if (string.IsNullOrEmpty(destinationPath))
|
||||
{
|
||||
throw new Exception($"Metadata 'DestinationPath' is missing for item '{item.ItemSpec}'.");
|
||||
}
|
||||
|
||||
if (!File.Exists(item.ItemSpec))
|
||||
{
|
||||
throw new Exception($"The file '{item.ItemSpec}' does not exist.");
|
||||
}
|
||||
|
||||
Log.LogMessage(
|
||||
MessageImportance.High,
|
||||
"Generating checksum for '{0}' into '{1}'...",
|
||||
item.ItemSpec,
|
||||
destinationPath);
|
||||
|
||||
using (FileStream stream = File.OpenRead(item.ItemSpec))
|
||||
{
|
||||
using(HashAlgorithm hashAlgorithm = SHA512.Create())
|
||||
{
|
||||
byte[] hash = hashAlgorithm.ComputeHash(stream);
|
||||
string checksum = BitConverter.ToString(hash).Replace("-", string.Empty);
|
||||
File.WriteAllText(destinationPath, checksum);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// We have 2 log calls because we want a nice error message but we also want to capture the
|
||||
// callstack in the log.
|
||||
Log.LogError("An exception occurred while trying to generate a checksum for '{0}'.", item.ItemSpec);
|
||||
Log.LogMessage(MessageImportance.Low, e.ToString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue