aspnetcore/build/PackageArchive.targets

71 lines
3.4 KiB
XML

<Project>
<PropertyGroup>
<_TemplatesDirectory>$(MSBuildThisFileDirectory)tools\templates\</_TemplatesDirectory>
<_WorkRoot>$(RepositoryRoot).w\</_WorkRoot>
<MetapackageRestoreSource>$(RepositoryRoot).deps\Signed\Packages\</MetapackageRestoreSource>
<LzmaOutputPackageName>nuGetPackagesArchive-$(PackageVersion)</LzmaOutputPackageName>
</PropertyGroup>
<Target Name="BuildFallbackArchive" DependsOnTargets="ResolveRepoInfo">
<Error Text="ArchiverPath must be specified" Condition=" '$(ArchiverPath)' == '' " />
<Error Text="Archiver not found at $(ArchiverPath)" Condition="!Exists('$(ArchiverPath)')" />
<!-- Clear the directories -->
<RemoveDir Directories="$(_WorkRoot)" />
<!-- Copy the archive template -->
<Copy SourceFiles="$(_TemplatesDirectory)Archive\Archive.csproj" DestinationFiles="$(_WorkRoot)Archive.csproj" />
<!-- Copy the archive template -->
<RepoTasks.AddArchiveReferences
ReferencePackagePath="$(_WorkRoot)Archive.csproj"
BuildArtifacts="@(ArtifactInfo)"
PackageArtifacts="@(PackageArtifact)"
ExternalDependencies="@(ExternalDependency)"
MetapackageVersion="$(PackageVersion)" />
<PropertyGroup>
<FallbackStagingDir>$(_WorkRoot)obj\$(LzmaOutputPackageName)</FallbackStagingDir>
<FallbackOutputDir>$(ArtifactsDir)lzma\</FallbackOutputDir>
<FallbackOutputPath>$(FallbackOutputDir)$(LzmaOutputPackageName).lzma</FallbackOutputPath>
<GeneratedFallbackRestoreSourcesPropsPath>$(_WorkRoot)restoresources.$(LzmaOutputPackageName).props</GeneratedFallbackRestoreSourcesPropsPath>
</PropertyGroup>
<ItemGroup>
<_FallbackArchiveRestoreSources Include="$(MetapackageRestoreSource)" Condition="Exists($(MetapackageRestoreSource))" />
<_FallbackArchiveRestoreSources Include="$(DependencyMirrorPackageDir)" Condition="Exists($(DependencyMirrorPackageDir))" />
</ItemGroup>
<RepoTasks.GenerateRestoreSourcesPropsFile
Sources="@(_FallbackArchiveRestoreSources)"
OutputPath="$(GeneratedFallbackRestoreSourcesPropsPath)" />
<!-- Create the Staging Dir -->
<MakeDir Directories="$(FallbackStagingDir);$(FallbackOutputDir)" />
<!-- Restore the target project -->
<MSBuild
Projects="$(_WorkRoot)Archive.csproj"
Targets="Restore"
Properties="RestorePackagesPath=$(FallbackStagingDir);RuntimeFrameworkVersion=$(MicrosoftNETCoreApp21PackageVersion);DotNetRestoreSourcePropsPath=$(GeneratedFallbackRestoreSourcesPropsPath);AspNetUniverseBuildOffline=true" />
<!-- Add global CLI tools to the LZMA -->
<!-- Join categories (defined in artifacts.props) with package version info (defined in repos) -->
<RepoTasks.JoinItems
Left="@(ArtifactInfo)" LeftKey="PackageId" LeftMetadata="*" LeftItemSpec="PackageId"
Right="@(PackageArtifact->WithMetadataValue('LZMA', 'true')->WithMetadataValue('PackageType', 'DotnetTool'))">
<Output TaskParameter="JoinResult" ItemName="_DotnetToolPackageId" />
</RepoTasks.JoinItems>
<ItemGroup>
<_DotnetToolPackages Include="$(MetapackageRestoreSource)%(_DotnetToolPackageId.Identity).%(_DotnetToolPackageId.Version).nupkg" />
</ItemGroup>
<RepoTasks.CreateNuGetV3FolderFeed Packages="@(_DotnetToolPackages)" DestinationFolder="$(FallbackStagingDir)" Overwrite="true" />
<!-- Create the archive -->
<Exec Command="$(ArchiverPath) -a $(FallbackOutputPath) $(FallbackStagingDir)" />
</Target>
</Project>