aspnetcore/build/Publish.targets

141 lines
6.0 KiB
XML

<Project>
<PropertyGroup>
<PublishDependsOn>
GetFilesToPublish;
PublishToAzureFeed;
PublishToMyGet;
</PublishDependsOn>
</PropertyGroup>
<Target Name="Publish" DependsOnTargets="$(PublishDependsOn)" />
<Target Name="GetFilesToPublish" DependsOnTargets="GetArtifactInfo">
<PropertyGroup>
<BlobBasePath>aspnetcore/Runtime/$(PackageVersion)/</BlobBasePath>
<NpmBlobBasePath>aspnetcore/npm/$(PackageVersion)/</NpmBlobBasePath>
<JarBlobBasePath>aspnetcore/jar/$(PackageVersion)/</JarBlobBasePath>
</PropertyGroup>
<ItemGroup>
<!-- Installer output files with specific metadata. -->
<FilesToPublish Include="$(InstallersOutputPath)*.txt">
<RelativeBlobPath>$(BlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
<ContentType>text/plain</ContentType>
</FilesToPublish>
<FilesToPublish Include="$(InstallersOutputPath)*.version">
<RelativeBlobPath>$(BlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
<ContentType>text/plain</ContentType>
<CacheControl>no-cache, no-store, must-revalidate</CacheControl>
<Overwrite>true</Overwrite>
</FilesToPublish>
<FilesToPublish Include="$(InstallersOutputPath)*.svg">
<RelativeBlobPath>$(BlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
<CacheControl>no-cache, no-store, must-revalidate</CacheControl>
<ContentType>image/svg+xml</ContentType>
<Overwrite>true</Overwrite>
</FilesToPublish>
<!-- All other installer files. -->
<FilesToPublish Include="$(InstallerOutputPath)*" Exclude="@(FilesToPublish)">
<RelativeBlobPath>$(BlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
</FilesToPublish>
<!-- Java packages -->
<FilesToPublish Include="$(ProductPackageOutputPath)*.jar">
<RelativeBlobPath>$(JarBlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
</FilesToPublish>
<FilesToPublish Include="$(ProductPackageOutputPath)*.pom">
<RelativeBlobPath>$(JarBlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
</FilesToPublish>
<!-- NPM packages -->
<NpmPackagesToPublish Include="$(ProductPackageOutputPath)*.tgz">
<RelativeBlobPath>$(NpmBlobBasePath)%(FileName)%(Extension)</RelativeBlobPath>
<ContentType>application/tar+gzip</ContentType>
</NpmPackagesToPublish>
<PackagesToPublish Include="$(ProductPackageOutputPath)*.symbols.nupkg" IsSymbolsPackage="true" />
<PackagesToPublish Include="$(ProductPackageOutputPath)*.nupkg" Exclude="@(PackagesToPublish)" />
</ItemGroup>
<!--
'Internal' packages are used to transfer bits to partner teams, and should not be used by customers.
Publishing these can be disabled.
-->
<ItemGroup Condition=" '$(PublishInternalPackages)' != 'false' ">
<PackagesToPublish Include="$(InternalPackageOutputPath)*.symbols.nupkg" IsSymbolsPackage="true">
<ManifestArtifactData>NonShipping=true</ManifestArtifactData>
</PackagesToPublish>
<PackagesToPublish Include="$(InternalPackageOutputPath)*.nupkg" Exclude="@(PackagesToPublish)">
<ManifestArtifactData>NonShipping=true</ManifestArtifactData>
</PackagesToPublish>
</ItemGroup>
</Target>
<Target Name="PublishToMyGet"
DependsOnTargets="GetFilesToPublish;GetToolsets"
Condition="'$(PublishToMyget)' == 'true'">
<Error Text="Missing required property: PublishMyGetFeedUrl" Condition=" '$(PublishMyGetFeedUrl)' == '' "/>
<Error Text="Missing required property: PublishMyGetSymbolsFeedUrl" Condition=" '$(PublishMyGetSymbolsFeedUrl)' == '' "/>
<Error Text="Missing required property: PublishMyGetNpmRegistryUrl" Condition=" '$(PublishMyGetNpmRegistryUrl)' == '' "/>
<Error Text="Missing required property: PublishMyGetFeedKey" Condition=" '$(PublishMyGetFeedKey)' == '' "/>
<Error Text="No packages found to publish" Condition="@(PackageToPublish->Count()) == 0" />
<PushNuGetPackages Condition="'%(PackageToPublish.IsSymbolsPackage)' != 'true' AND @(PackageToPublish->Count()) != 0"
Packages="@(PackageToPublish)"
Feed="$(PublishMyGetFeedUrl)"
ApiKey="$(PublishMyGetFeedKey)" />
<PushNuGetPackages Condition="'%(PackageToPublish.IsSymbolsPackage)' == 'true' AND @(PackageToPublish->Count()) != 0"
Packages="@(PackageToPublish)"
Feed="$(PublishMyGetSymbolsFeedUrl)"
ApiKey="$(PublishMyGetFeedKey)" />
<PropertyGroup>
<AuthTokenSetting>$(PublishMyGetNpmRegistryUrl.Replace("https:", "")):_authToken</AuthTokenSetting>
</PropertyGroup>
<Message Condition=" @(NpmPackageToPublish->Count()) != 0 "
Text="Skipping NPM publish because there are no npm packages to publish."
Importance="high" />
<Exec Condition=" @(NpmPackageToPublish->Count()) != 0 "
Command="npm config set &quot;$(AuthTokenSetting)&quot; $(PublishMyGetFeedKey)"
StandardOutputImportance="Normal" />
<!-- When you UseCommandProcessor FileName is ignored -->
<Run Condition=" @(NpmPackageToPublish->Count()) != 0 "
FileName="cmd"
Arguments="npm;publish;--registry;$(PublishMyGetNpmRegistryUrl);%(NpmPackageToPublish.Identity)"
MaxRetries="5"
UseCommandProcessor="true"
ContinueOnError="true">
<Output TaskParameter="ExitCode" ItemName="_NpmExitCodes" />
</Run>
<Exec Condition=" @(NpmPackageToPublish->Count()) != 0 "
Command="npm config delete $(AuthTokenSetting)"
StandardOutputImportance="Normal" />
<Error Text="Publishing npm modules failed" Condition=" @(NpmPackageToPublish->Count()) != 0 AND %(_NpmExitCodes.Identity) != 0" />
</Target>
<Target Name="PublishToAzureFeed"
DependsOnTargets="GetFilesToPublish"
Condition="'$(PublishToAzureFeed)' == 'true'">
<RepoTasks.PublishToAzureBlob
AccountName="$(AzureAccountName)"
SharedAccessToken="$(AzureSharedAccessToken)"
ContainerName="$(AzureContainerName)"
Files="@(FilesToPublish)" />
</Target>
</Project>