dotnet-installer/build/Microsoft.DotNet.Cli.Publish.targets

101 lines
4.2 KiB
Text
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(ToolsDir)/PublishContent.targets" />
<Import Project="$(MSBuildThisFileDirectory)/publish/Microsoft.DotNet.Cli.Badge.targets" />
<UsingTask TaskName="UploadToAzure" AssemblyFile="$(BuildToolsTaskDir)/Microsoft.DotNet.Build.CloudTestTasks.dll"/>
<UsingTask TaskName="FinalizeBuildTask" AssemblyFile="$(CLIBuildDll)" />
<!-- PUBLISH_TO_AZURE_BLOB env variable set by CI -->
<Target Name="Publish"
Condition=" '$(PUBLISH_TO_AZURE_BLOB)' != '' "
DependsOnTargets="Prepare;
Package;
PublishArtifacts;
FinalizeBuild" />
<Target Name="PublishArtifacts" DependsOnTargets="SetupAzureBlobInformation;
GenerateVersionBadge;
GatherItemsForPattern;
UploadToAzure;
PublishDebFilesToDebianRepo;
PublishCliVersionBadge" />
<Target Name="FinalizeBuild">
<FinalizeBuildTask AccountName="$(CloudDropAccountName)"
AccountKey="$(CloudDropAccessToken)"
NugetVersion="$(NugetVersion)"
Channel="$(Channel)"
CommitHash="$(CommitHash)"
BranchName="$(BranchName)" />
</Target>
<Target Name="SetupAzureBlobInformation">
<PropertyGroup>
<Product>Sdk</Product>
<ContainerName>$(STORAGE_CONTAINER)</ContainerName>
<CloudDropAccessToken>$(STORAGE_KEY)</CloudDropAccessToken>
<CloudDropAccountName>$(STORAGE_ACCOUNT)</CloudDropAccountName>
<DotnetBlobRootUrl>https://$(CloudDropAccountName).blob.core.windows.net/$(ContainerName)</DotnetBlobRootUrl>
</PropertyGroup>
</Target>
<Target Name="GatherItemsForPattern">
<ItemGroup>
<ForPublishing Include="@(GeneratedInstallers)" />
<ForPublishing Include="%(GenerateArchivesInputsOutputs.Outputs)" />
</ItemGroup>
<ItemGroup>
<ForPublishing>
<RelativeBlobPath>$(Product)/$(NugetVersion)/$([System.String]::Copy('%(Filename)%(Extension)').Replace('\' ,'/'))</RelativeBlobPath>
</ForPublishing>
</ItemGroup>
</Target>
<Target Name="PublishDebFilesToDebianRepo" Condition=" '$(OSName)' == 'ubuntu' ">
<Error Condition="'$(REPO_ID)' == ''" Text="REPO_ID must be set as an environment variable for debian publishing." />
<ItemGroup>
<SdkInstallerFileItemGroup Include="$(SdkInstallerFile)" />
</ItemGroup>
<PropertyGroup>
<SdkDebianPackageName>dotnet-dev-$(NugetVersion)</SdkDebianPackageName>
<SdkDebianUploadUrl>$(DotnetBlobRootUrl)/$(Product)/$(NugetVersion)/%(SdkInstallerFileItemGroup.Filename)%(SdkInstallerFileItemGroup.Extension)</SdkDebianUploadUrl>
<DebianUploadJsonFile>$(PackageDirectory)/package_upload.json</DebianUploadJsonFile>
<DebianRevisionNumber>1</DebianRevisionNumber>
<DebianUploadJsonContent>
{
"name":"$(SdkDebianPackageName)",
"version":"$(NugetVersion)-$(DebianRevisionNumber)",
"repositoryId":"$(REPO_ID)",
"sourceUrl": "$(SdkDebianUploadUrl)"
}
</DebianUploadJsonContent>
</PropertyGroup>
<Delete Files="$(DebianUploadJsonFile)" />
<WriteLinesToFile File="$(DebianUploadJsonFile)" Lines="$(DebianUploadJsonContent)" />
<Exec Command="$(RepoRoot)/scripts/publish/repoapi_client.sh -addpkg $(DebianUploadJsonFile)" />
</Target>
<Target Name="PublishCliVersionBadge">
<ItemGroup>
<CliVersionBadgeToUpload Include="$(VersionBadge)" />
</ItemGroup>
<ItemGroup>
<CliVersionBadgeToUpload>
<RelativeBlobPath>$(Product)/$(NugetVersion)/$([System.String]::Copy('%(Filename)%(Extension)').Replace('\' ,'/'))</RelativeBlobPath>
</CliVersionBadgeToUpload>
</ItemGroup>
<UploadToAzure
AccountKey="$(CloudDropAccessToken)"
AccountName="$(CloudDropAccountName)"
ContainerName="$(ContainerName)"
Items="@(CliVersionBadgeToUpload)" />
</Target>
</Project>