Skip to content

Commit de0e18e

Browse files
Restructure Publish.proj so that default artifacts can be updated (#15383)
Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
1 parent 43494f7 commit de0e18e

1 file changed

Lines changed: 43 additions & 48 deletions

File tree

src/Microsoft.DotNet.Arcade.Sdk/tools/Publish.proj

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
EnableDefaultArtifacts Includes packages under "/artifacts/packages/**" for publishing. Defaults to true.
1616
DotNetBuildPass While building the repo as part of the entire .NET stack, this parameter specifies which build pass the current build is part of.
1717
The build pass number gets added to the asset manifest file name to avoid collisions.
18-
18+
1919
Optional items:
2020
Artifact (with Metadata) Path to the artifact to publish. Declare the item in Signing.props to sign and publish the artifact.
2121
- ChecksumPath The destination path to generate a checksum file for the artifact. Set the `RelativeBlobPathParent`
@@ -58,33 +58,27 @@
5858
<Import Project="StrongName.targets" />
5959
<Import Project="Sign.props" />
6060

61-
<!-- Allow for repo specific Publish properties such as add additional files to be published -->
62-
<Import Project="$(RepositoryEngineeringDir)Publishing.props" Condition="Exists('$(RepositoryEngineeringDir)Publishing.props')" />
63-
6461
<PropertyGroup>
6562
<!-- Default publishing target is 3. -->
66-
<PublishingVersion Condition="'$(PublishingVersion)' == ''">3</PublishingVersion>
63+
<PublishingVersion>3</PublishingVersion>
6764

6865
<!-- Globally set property. -->
6966
<IsStableBuild>false</IsStableBuild>
7067
<IsStableBuild Condition="'$(DotNetFinalVersionKind)' == 'release'">true</IsStableBuild>
7168

7269
<!-- If `IsReleaseOnlyPackageVersion` is set to true, package safety checks can be skipped-->
7370
<IsReleaseOnlyPackageVersion>false</IsReleaseOnlyPackageVersion>
74-
<IsReleaseOnlyPackageVersion Condition ="('$(SkipPackagePublishingVersionChecks)' == 'true') or ('$(PreReleaseVersionLabel)' == '' and '$(AutoGenerateAssemblyVersion)' == 'true')">true</IsReleaseOnlyPackageVersion>
71+
<IsReleaseOnlyPackageVersion Condition ="'$(SkipPackagePublishingVersionChecks)' == 'true' or ('$(PreReleaseVersionLabel)' == '' and '$(AutoGenerateAssemblyVersion)' == 'true')">true</IsReleaseOnlyPackageVersion>
7572

76-
<!-- If `AutoGenerateSymbolPackages` is not set we default it to true. -->
77-
<!-- Do not generate symbol packages if in outer source build mode, to avoid creating copies of the intermediates. -->
78-
<!-- Also do not generate symbol packages if in inner source build, in product build. -->
73+
<!-- If `AutoGenerateSymbolPackages` is not set we default it to true.
74+
Do not generate symbol packages if in outer source build mode, to avoid creating copies of the intermediates.
75+
Also do not generate symbol packages if in inner source build, in product build. -->
7976
<AutoGenerateSymbolPackages Condition="'$(AutoGenerateSymbolPackages)' == '' and
8077
('$(DotNetBuildSourceOnly)' != 'true' or ('$(DotNetBuildInnerRepo)' == 'true' and '$(DotNetBuildOrchestrator)' != 'true'))">true</AutoGenerateSymbolPackages>
8178

82-
<SymbolPackagesDir>$(ArtifactsTmpDir)SymbolPackages\</SymbolPackagesDir>
83-
79+
<PublishDependsOnTargets>$(PublishDependsOnTargets);BeforePublish;AutoGenerateSymbolPackages</PublishDependsOnTargets>
8480
<PublishDependsOnTargets Condition="$(PublishToSymbolServer)">$(PublishDependsOnTargets);PublishSymbols</PublishDependsOnTargets>
8581
<PublishDependsOnTargets Condition="$(DotNetPublishUsingPipelines)">$(PublishDependsOnTargets);PublishToAzureDevOpsArtifacts</PublishDependsOnTargets>
86-
87-
<PublishDependsOnTargets>BeforePublish;$(PublishDependsOnTargets)</PublishDependsOnTargets>
8882
</PropertyGroup>
8983

9084
<PropertyGroup>
@@ -99,71 +93,69 @@
9993
<AssetManifestFilePath>$(ArtifactsLogDir)AssetManifest\$(AssetManifestFileName)</AssetManifestFilePath>
10094
</PropertyGroup>
10195

96+
<ItemGroup Condition="'$(EnableDefaultArtifacts)' == 'true'">
97+
<Artifact Include="$(ArtifactsShippingPackagesDir)**/*.nupkg" PublishFlatContainer="false" />
98+
<Artifact Include="$(ArtifactsNonShippingPackagesDir)**/*.nupkg" IsShipping="false" PublishFlatContainer="false" />
99+
</ItemGroup>
100+
101+
<!-- Allow for repo specific Publish properties such as add additional files to be published -->
102+
<Import Project="$(RepositoryEngineeringDir)Publishing.props" Condition="Exists('$(RepositoryEngineeringDir)Publishing.props')" />
103+
102104
<Import Project="$(NuGetPackageRoot)microsoft.dotnet.build.tasks.feed\$(MicrosoftDotNetBuildTasksFeedVersion)\build\Microsoft.DotNet.Build.Tasks.Feed.targets"/>
103105
<Import Project="$(NuGetPackageRoot)microsoft.symboluploader.build.task\$(MicrosoftSymbolUploaderBuildTaskVersion)\build\PublishSymbols.targets" Condition="$(PublishToSymbolServer)"/>
104106

105-
<Target Name="Publish"
106-
DependsOnTargets="$(PublishDependsOnTargets)" />
107+
<Target Name="Publish" DependsOnTargets="$(PublishDependsOnTargets)" />
107108

108109
<Target Name="BeforePublish">
109-
<ItemGroup Condition="'$(EnableDefaultArtifacts)' == 'true'">
110-
<ExistingSymbolPackages Include="$(ArtifactsShippingPackagesDir)**/*.symbols.nupkg" IsShipping="true" />
111-
<ExistingSymbolPackages Include="$(ArtifactsNonShippingPackagesDir)**/*.symbols.nupkg" IsShipping="false" />
112-
113-
<PackagesToPublish Include="$(ArtifactsShippingPackagesDir)**/*.nupkg" IsShipping="true" />
114-
<PackagesToPublish Include="$(ArtifactsNonShippingPackagesDir)**/*.nupkg" IsShipping="false" />
115-
</ItemGroup>
116-
117-
<!-- Respect Artifact item repo extension point for packages -->
118110
<ItemGroup Condition="'@(Artifact)' != ''">
119-
<ExistingSymbolPackages Include="@(Artifact)" Condition="'%(Artifact.SkipPublish)' != 'true' and $([System.String]::Copy('%(Filename)%(Extension)').EndsWith('.symbols.nupkg'))" />
120-
<PackagesToPublish Include="@(Artifact)" Condition="'%(Artifact.SkipPublish)' != 'true' and '%(Extension)' == '.nupkg'" />
111+
<_ExistingSymbolPackage Include="@(Artifact)" Condition="'%(Artifact.SkipPublish)' != 'true' and $([System.String]::Copy('%(Filename)%(Extension)').EndsWith('.symbols.nupkg'))" />
112+
<_PackageToPublish Include="@(Artifact)" Exclude="@(_ExistingSymbolPackage)" Condition="'%(Artifact.SkipPublish)' != 'true' and '%(Extension)' == '.nupkg'" />
121113
</ItemGroup>
114+
</Target>
122115

123-
<ItemGroup>
124-
<!-- Make sure that PackagesToPublish doesn't contain existing symbol packages. -->
125-
<PackagesToPublish Remove="@(ExistingSymbolPackages)" />
116+
<Target Name="AutoGenerateSymbolPackages" DependsOnTargets="BeforePublish" Condition="'$(AutoGenerateSymbolPackages)' == 'true'">
117+
<PropertyGroup>
118+
<SymbolPackagesDir Condition="'$(SymbolPackagesDir)' == ''">$(ArtifactsTmpDir)SymbolPackages\</SymbolPackagesDir>
119+
</PropertyGroup>
126120

127-
<!-- Do not generate symbol packages when building from source. The generate package for the source build intermediate
128-
will simply contain the same, non-symbol content. -->
129-
<PackagesToPublish Update="@(PackagesToPublish)" Condition="'$(AutoGenerateSymbolPackages)' == 'true'">
121+
<ItemGroup>
122+
<_PackageToPublish Update="@(_PackageToPublish)">
130123
<SymbolPackageToGenerate Condition="!Exists('%(RootDir)%(Directory)%(Filename).symbols.nupkg')">$(SymbolPackagesDir)%(Filename).symbols.nupkg</SymbolPackageToGenerate>
131-
</PackagesToPublish>
124+
</_PackageToPublish>
132125

133-
<SymbolPackagesToGenerate Include="@(PackagesToPublish->'%(SymbolPackageToGenerate)')" Condition="'%(PackagesToPublish.SymbolPackageToGenerate)' != ''" Exclude="@(ExistingSymbolPackages -> '$(SymbolPackagesDir)%(Filename)%(Extension)')">
134-
<OriginalPackage>%(PackagesToPublish.Identity)</OriginalPackage>
135-
<IsShipping>%(PackagesToPublish.IsShipping)</IsShipping>
136-
</SymbolPackagesToGenerate>
126+
<_SymbolPackageToGenerate Include="@(_PackageToPublish->'%(SymbolPackageToGenerate)')"
127+
Exclude="@(_ExistingSymbolPackage -> '$(SymbolPackagesDir)%(Filename)%(Extension)')"
128+
Condition="'%(_PackageToPublish.SymbolPackageToGenerate)' != ''">
129+
<OriginalPackage>%(_PackageToPublish.Identity)</OriginalPackage>
130+
<IsShipping>%(_PackageToPublish.IsShipping)</IsShipping>
131+
</_SymbolPackageToGenerate>
137132

138133
<!-- If PostBuildSign is true, then we need to include newly generated packages in ItemsToSignPostBuild. -->
139-
<ItemsToSignPostBuild Include="@(SymbolPackagesToGenerate->'%(Filename)%(Extension)')" Condition="'$(PostBuildSign)' == 'true'" />
134+
<ItemsToSignPostBuild Include="@(_SymbolPackageToGenerate->'%(Filename)%(Extension)')" Condition="'$(PostBuildSign)' == 'true'" />
140135
</ItemGroup>
141136

142137
<!--
143138
If a symbol package doesn't exist yet we assume that the regular package contains Portable PDBs.
144139
Such packages can act as symbol packages since they have the same structure.
145140
We just need to copy them to *.symbols.nupkg.
146141
-->
147-
<MakeDir Condition="'@(SymbolPackagesToGenerate)' != ''" Directories="$(SymbolPackagesDir)" />
148-
<Copy SourceFiles="@(SymbolPackagesToGenerate->'%(OriginalPackage)')" DestinationFiles="@(SymbolPackagesToGenerate)" />
142+
<MakeDir Condition="'@(_SymbolPackageToGenerate)' != ''" Directories="$(SymbolPackagesDir)" />
143+
<Copy SourceFiles="@(_SymbolPackageToGenerate->'%(OriginalPackage)')" DestinationFiles="@(_SymbolPackageToGenerate)" />
149144

150145
<ItemGroup>
151146
<!--
152147
These packages from Arcade-Services include some native libraries that
153148
our current symbol uploader can't handle. Below is a workaround until
154149
we get issue: https://github.com/dotnet/arcade/issues/2457 sorted.
155150
-->
156-
<SymbolPackagesToGenerate Remove="$(SymbolPackagesDir)**/Microsoft.DotNet.Darc.*" />
157-
<SymbolPackagesToGenerate Remove="$(SymbolPackagesDir)**/Microsoft.DotNet.Maestro.Tasks.*" />
151+
<_SymbolPackageToGenerate Remove="$(SymbolPackagesDir)**/Microsoft.DotNet.Darc.*" />
152+
<_SymbolPackageToGenerate Remove="$(SymbolPackagesDir)**/Microsoft.DotNet.Maestro.Tasks.*" />
158153

159154
<!-- Exclude all existing *.symbols.nupkg in source-only build - we create a unified symbols archive instead. -->
160-
<ExistingSymbolPackages Remove="@(ExistingSymbolPackages)" Condition="'$(DotNetBuildSourceOnly)' == 'true'"/>
155+
<_ExistingSymbolPackage Remove="@(_ExistingSymbolPackage)" Condition="'$(DotNetBuildSourceOnly)' == 'true'"/>
161156

162-
<ItemsToPushToBlobFeed Include="@(PackagesToPublish);@(ExistingSymbolPackages);@(SymbolPackagesToGenerate)" Exclude="@(ItemsToPushToBlobFeed)" />
157+
<ItemsToPushToBlobFeed Include="@(_PackageToPublish);@(_ExistingSymbolPackage);@(_SymbolPackageToGenerate)" Exclude="@(ItemsToPushToBlobFeed)" />
163158
</ItemGroup>
164-
165-
<Error Condition="'$(AllowEmptySignPostBuildList)' != 'true' AND '@(ItemsToSignPostBuild)' == ''"
166-
Text="List of files to sign post-build is empty. Make sure that ItemsToSignPostBuild is configured correctly." />
167159
</Target>
168160

169161
<!-- Generate checksums from artifact items that set ChecksumPath.
@@ -256,6 +248,9 @@
256248
</ItemsToPushToBlobFeed>
257249
</ItemGroup>
258250

251+
<Error Condition="'$(AllowEmptySignPostBuildList)' != 'true' AND '@(ItemsToSignPostBuild)' == ''"
252+
Text="List of files to sign post-build is empty. Make sure that ItemsToSignPostBuild is configured correctly." />
253+
259254
<!--
260255
The user can set `PublishingVersion` via eng\Publishing.props
261256
-->
@@ -342,7 +337,7 @@
342337
<!--
343338
Publish Portable PDBs contained in symbol packages.
344339
-->
345-
<PackagesToPublishToSymbolServer Include="@(ExistingSymbolPackages);@(SymbolPackagesToGenerate)"/>
340+
<PackagesToPublishToSymbolServer Include="@(_ExistingSymbolPackage);@(_SymbolPackageToGenerate)"/>
346341
</ItemGroup>
347342

348343
<PropertyGroup>

0 commit comments

Comments
 (0)