|
| 1 | +<Project> |
| 2 | + |
| 3 | + <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> |
| 4 | + |
| 5 | + <PropertyGroup> |
| 6 | + <!-- TFM doesn't matter. These settings are required to make NuGet happy so we can restore required MSBuild packages. --> |
| 7 | + <TargetFramework>netcoreapp3.0</TargetFramework> |
| 8 | + <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences> |
| 9 | + <ManifestsPath>$(ArtifactsDir)manifests\</ManifestsPath> |
| 10 | + <MaestroApiEndpoint Condition="'$(MaestroApiEndpoint)' == ''">https://maestro-prod.westus2.cloudapp.azure.com</MaestroApiEndpoint> |
| 11 | + </PropertyGroup> |
| 12 | + |
| 13 | + <ItemGroup> |
| 14 | + <PackageReference Include="Microsoft.DotNet.Build.Tasks.Feed" Version="2.2.0-beta.19061.6" /> |
| 15 | + <PackageReference Include="Microsoft.DotNet.Maestro.Tasks" Version="1.1.0-beta.19065.2" /> |
| 16 | + </ItemGroup> |
| 17 | + |
| 18 | + <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> |
| 19 | + |
| 20 | + <PropertyGroup> |
| 21 | + <PublishDependsOn> |
| 22 | + GetFilesToPublish; |
| 23 | + GenerateBuildAssetManifest; |
| 24 | + PublishToAzureFeed; |
| 25 | + PublishToMyGet; |
| 26 | + PublishToBuildAssetRegistry; |
| 27 | + </PublishDependsOn> |
| 28 | + </PropertyGroup> |
| 29 | + |
| 30 | + <Target Name="Publish" DependsOnTargets="$(PublishDependsOn)" /> |
| 31 | + |
| 32 | + <Target Name="GetFilesToPublish"> |
| 33 | + <ItemGroup> |
| 34 | + <!-- Installer output files with specific metadata. --> |
| 35 | + <_FilesToPublish Include="$(InstallersOutputPath)*.txt"> |
| 36 | + <ContentType>text/plain</ContentType> |
| 37 | + </_FilesToPublish> |
| 38 | + |
| 39 | + <_FilesToPublish Include="$(InstallersOutputPath)*.version"> |
| 40 | + <ContentType>text/plain</ContentType> |
| 41 | + <CacheControl>no-cache, no-store, must-revalidate</CacheControl> |
| 42 | + </_FilesToPublish> |
| 43 | + |
| 44 | + <_FilesToPublish Include="$(InstallersOutputPath)*.svg"> |
| 45 | + <CacheControl>no-cache, no-store, must-revalidate</CacheControl> |
| 46 | + <ContentType>image/svg+xml</ContentType> |
| 47 | + </_FilesToPublish> |
| 48 | + |
| 49 | + <!-- All other installer files. --> |
| 50 | + <_FilesToPublish Include="$(InstallersOutputPath)*" Exclude="@(_FilesToPublish)" /> |
| 51 | + |
| 52 | + <!-- Java packages --> |
| 53 | + <_FilesToPublish Include="$(ProductPackageOutputPath)*.jar;$(ProductPackageOutputPath)*.pom"> |
| 54 | + <BlobBasePath>aspnetcore/jar/$(PackageVersion)/</BlobBasePath> |
| 55 | + </_FilesToPublish> |
| 56 | + |
| 57 | + <!-- NPM packages --> |
| 58 | + <NpmPackageToPublish Include="$(ProductPackageOutputPath)*.tgz"> |
| 59 | + <BlobBasePath>aspnetcore/npm/$(PackageVersion)/</BlobBasePath> |
| 60 | + </NpmPackageToPublish> |
| 61 | + <_FilesToPublish Include="@(NpmPackageToPublish)" /> |
| 62 | + |
| 63 | + <!-- |
| 64 | + Transform the intermediate item group into the final group. |
| 65 | + You can't use globbing _and_ set metadata using FileName and Extension at the same time. MSBuild quirks are fun. |
| 66 | + --> |
| 67 | + <FilesToPublish Include="@(_FilesToPublish)"> |
| 68 | + <RelativeBlobPath Condition="'%(_FilesToPublish.BlobBasePath)' != ''">%(_FilesToPublish.BlobBasePath)%(_FilesToPublish.FileName)%(_FilesToPublish.Extension)</RelativeBlobPath> |
| 69 | + <RelativeBlobPath Condition="'%(_FilesToPublish.BlobBasePath)' == ''">aspnetcore/Runtime/$(PackageVersion)/%(_FilesToPublish.FileName)%(_FilesToPublish.Extension)</RelativeBlobPath> |
| 70 | + </FilesToPublish> |
| 71 | + <_FilesToPublish Remove="@(_FilesToPublish)" /> |
| 72 | + |
| 73 | + <PackageToPublish Include="$(ProductPackageOutputPath)*.symbols.nupkg" IsSymbolsPackage="true" /> |
| 74 | + <PackageToPublish Include="$(ProductPackageOutputPath)*.nupkg" Exclude="@(PackageToPublish)" /> |
| 75 | + </ItemGroup> |
| 76 | + |
| 77 | + <!-- |
| 78 | + 'Internal' packages are used to transfer bits to partner teams, and should not be used by customers. |
| 79 | + Publishing these can be disabled. |
| 80 | + --> |
| 81 | + <ItemGroup Condition=" '$(PublishInternalPackages)' != 'false' "> |
| 82 | + <PackageToPublish Include="$(InternalPackageOutputPath)*.symbols.nupkg" IsSymbolsPackage="true"> |
| 83 | + <ManifestArtifactData>NonShipping=true</ManifestArtifactData> |
| 84 | + </PackageToPublish> |
| 85 | + <PackageToPublish Include="$(InternalPackageOutputPath)*.nupkg" Exclude="@(PackageToPublish)"> |
| 86 | + <ManifestArtifactData>NonShipping=true</ManifestArtifactData> |
| 87 | + </PackageToPublish> |
| 88 | + </ItemGroup> |
| 89 | + |
| 90 | + <Error Text="Missing required metadata 'RelativeBlobPath' for FilesToPublish: @(FilesToPublish)" Condition="'@(FilesToPublish)' != '' AND '%(RelativeBlobPath)' == ''" /> |
| 91 | + </Target> |
| 92 | + |
| 93 | + <UsingTask TaskName="KoreBuild.Tasks.PushNuGetPackages" AssemblyFile="$(KoreBuildTasksDll)" /> |
| 94 | + |
| 95 | + <Target Name="PublishToMyGet" |
| 96 | + DependsOnTargets="GetFilesToPublish" |
| 97 | + Condition="'$(PublishToMyget)' == 'true'"> |
| 98 | + |
| 99 | + <Error Text="Missing required property: PublishMyGetFeedUrl" Condition=" '$(PublishMyGetFeedUrl)' == '' "/> |
| 100 | + <Error Text="Missing required property: PublishMyGetSymbolsFeedUrl" Condition=" '$(PublishMyGetSymbolsFeedUrl)' == '' "/> |
| 101 | + <Error Text="Missing required property: PublishMyGetNpmRegistryUrl" Condition=" '$(PublishMyGetNpmRegistryUrl)' == '' "/> |
| 102 | + <Error Text="Missing required property: PublishMyGetFeedKey" Condition=" '$(PublishMyGetFeedKey)' == '' "/> |
| 103 | + |
| 104 | + <Error Text="No packages found to publish" Condition="@(PackageToPublish->Count()) == 0" /> |
| 105 | + |
| 106 | + <PushNuGetPackages Condition="'%(PackageToPublish.IsSymbolsPackage)' != 'true' AND @(PackageToPublish->Count()) != 0" |
| 107 | + Packages="@(PackageToPublish)" |
| 108 | + TimeoutSeconds="300" |
| 109 | + Feed="$(PublishMyGetFeedUrl)" |
| 110 | + ApiKey="$(PublishMyGetFeedKey)" /> |
| 111 | + |
| 112 | + <PushNuGetPackages Condition="'%(PackageToPublish.IsSymbolsPackage)' == 'true' AND @(PackageToPublish->Count()) != 0" |
| 113 | + Packages="@(PackageToPublish)" |
| 114 | + TimeoutSeconds="300" |
| 115 | + Feed="$(PublishMyGetSymbolsFeedUrl)" |
| 116 | + ApiKey="$(PublishMyGetFeedKey)" /> |
| 117 | + |
| 118 | + <PropertyGroup> |
| 119 | + <AuthTokenSetting>$(PublishMyGetNpmRegistryUrl.Replace("https:", "")):_authToken</AuthTokenSetting> |
| 120 | + </PropertyGroup> |
| 121 | + |
| 122 | + <Message Condition=" @(NpmPackageToPublish->Count()) != 0 " |
| 123 | + Text="Skipping NPM publish because there are no npm packages to publish." |
| 124 | + Importance="high" /> |
| 125 | + |
| 126 | + <Exec Condition=" @(NpmPackageToPublish->Count()) != 0 " |
| 127 | + Command="npm config set "$(AuthTokenSetting)" $(PublishMyGetFeedKey)" |
| 128 | + StandardOutputImportance="Normal" /> |
| 129 | + |
| 130 | + <!-- When you UseCommandProcessor FileName is ignored --> |
| 131 | + <Run Condition=" @(NpmPackageToPublish->Count()) != 0 " |
| 132 | + FileName="cmd" |
| 133 | + Arguments="npm;publish;--registry;$(PublishMyGetNpmRegistryUrl);%(NpmPackageToPublish.Identity)" |
| 134 | + MaxRetries="5" |
| 135 | + UseCommandProcessor="true" |
| 136 | + ContinueOnError="true"> |
| 137 | + <Output TaskParameter="ExitCode" ItemName="_NpmExitCodes" /> |
| 138 | + </Run> |
| 139 | + |
| 140 | + <Exec Condition=" @(NpmPackageToPublish->Count()) != 0 " |
| 141 | + Command="npm config delete $(AuthTokenSetting)" |
| 142 | + StandardOutputImportance="Normal" /> |
| 143 | + |
| 144 | + <Error Text="Publishing npm modules failed" Condition=" @(NpmPackageToPublish->Count()) != 0 AND %(_NpmExitCodes.Identity) != 0" /> |
| 145 | + </Target> |
| 146 | + |
| 147 | + <Target Name="PublishToAzureFeed" |
| 148 | + DependsOnTargets="GetFilesToPublish" |
| 149 | + Condition="'$(PublishToAzureFeed)' == 'true'"> |
| 150 | + |
| 151 | + <RepoTasks.PublishToAzureBlob |
| 152 | + AccountName="$(AzureAccountName)" |
| 153 | + SharedAccessToken="$(AzureSharedAccessToken)" |
| 154 | + ContainerName="$(AzureContainerName)" |
| 155 | + Files="@(FilesToPublish)" /> |
| 156 | + </Target> |
| 157 | + |
| 158 | + <Target Name="GenerateBuildAssetManifest" |
| 159 | + DependsOnTargets="GetFilesToPublish;ResolveRepositoryBranch;ResolveCommitHash"> |
| 160 | + |
| 161 | + <GenerateBuildManifest |
| 162 | + Artifacts="@(PackageToPublish);@(FilesToPublish)" |
| 163 | + OutputPath="$(ManifestsPath)aspnetcore-$(SharedFxRid)-$(PackageVersion).xml" |
| 164 | + BuildId="$(PackageVersion)" |
| 165 | + BuildData="Location=https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" |
| 166 | + RepoUri="$(RepositoryUrl)" |
| 167 | + RepoBranch="$(RepositoryBranch)" |
| 168 | + RepoCommit="$(RepositoryCommit)" /> |
| 169 | + </Target> |
| 170 | + |
| 171 | + <UsingTask TaskName="PushMetadataToBuildAssetRegistry" AssemblyFile="$(PkgMicrosoft_DotNet_Maestro_Tasks)\tools\netcoreapp2.1\Microsoft.DotNet.Maestro.Tasks.dll"/> |
| 172 | + |
| 173 | + <Target Name="PublishToBuildAssetRegistry" |
| 174 | + DependsOnTargets="GenerateBuildAssetManifest" |
| 175 | + Condition="'$(PublishToBuildAssetRegistry)' == 'true'"> |
| 176 | + |
| 177 | + <Error Text="Missing required property: MaestroApiEndpoint" Condition=" '$(MaestroApiEndpoint)' == '' "/> |
| 178 | + <Error Text="Missing required property: BuildAssetRegistryToken" Condition=" '$(BuildAssetRegistryToken)' == '' "/> |
| 179 | + |
| 180 | + <PushMetadataToBuildAssetRegistry |
| 181 | + ManifestsPath="$(ManifestsPath)" |
| 182 | + BuildAssetRegistryToken="$(BuildAssetRegistryToken)" |
| 183 | + MaestroApiEndpoint="$(MaestroApiEndpoint)" /> |
| 184 | + </Target> |
| 185 | + |
| 186 | +</Project> |
0 commit comments