Skip to content

Commit

Permalink
Make the "dotnet" repo project actually do a build instead of being s…
Browse files Browse the repository at this point in the history
…ome root utility project. This build, however, only publishes the assets.

Unlike the approach I take in dotnet#47076, this approach allows our final "vertical" publish to use a the live Arcade logic instead of the bootstrapping Arcade.
  • Loading branch information
jkoritzinsky committed Mar 5, 2025
1 parent ed797da commit b6613cf
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 17 deletions.
2 changes: 0 additions & 2 deletions src/SourceBuild/content/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<ShortStack Condition="'$(TargetOS)' == 'linux-bionic'">true</ShortStack>
<!-- Mono LLVM builds are short -->
<ShortStack Condition="'$(DotNetBuildMonoEnableLLVM)' == 'true' or '$(DotNetBuildMonoAOTEnableLLVM)' == 'true'">true</ShortStack>
<!-- Short stack builds stop at runtime, not the whole SDK -->
<RootRepo Condition="'$(ShortStack)' == 'true'">runtime</RootRepo>
</PropertyGroup>

<!-- See https://github.com/dotnet/arcade/blob/main/Documentation/UnifiedBuild/Unified-Build-Controls.md#output-controls for
Expand Down
11 changes: 5 additions & 6 deletions src/SourceBuild/content/repo-projects/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@

<ArtifactsLogRepoDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsLogDir)', '$(RepositoryName)'))</ArtifactsLogRepoDir>
<PackageReportRepoDir>$([MSBuild]::NormalizeDirectory('$(PackageReportDir)', '$(RepositoryName)'))</PackageReportRepoDir>

<!-- By default, a repo uses the repo-specific output paths. -->
<UseRepoArtifactsOutputPaths>true</UseRepoArtifactsOutputPaths>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildOS)' == 'windows'">
Expand Down Expand Up @@ -109,14 +112,10 @@
<CommonArgs Condition="'$(OfficialBuildId)' != ''">$(CommonArgs) /p:OfficialBuildId=$(OfficialBuildId)</CommonArgs>
<CommonArgs Condition="'$(ForceDryRunSigning)' != ''">$(CommonArgs) /p:ForceDryRunSigning=$(ForceDryRunSigning)</CommonArgs>

<!-- Pass locations for assets -->
<CommonArgs>$(CommonArgs) /p:SourceBuiltAssetsDir=$(ArtifactsAssetsDir)</CommonArgs>
<CommonArgs>$(CommonArgs) /p:SourceBuiltAssetManifestsDir=$(RepoAssetManifestsDir)</CommonArgs>

<!-- PGO assets by default are "Vertical" visibilty. Each repo will enable the specific artifacts it must publish externally -->
<CommonArgs Condition="'$(PgoInstrument)' == 'true'">$(CommonArgs) /p:DefaultArtifactVisibility=Vertical</CommonArgs>
<!-- ShortStack builds only publish new assets from the root repository. All other assets are duplicates. -->
<CommonArgs Condition="'$(ShortStack)' == 'true' and '$(MSBuildProjectName)' != '$(RootRepo)'">$(CommonArgs) /p:DefaultArtifactVisibility=Vertical</CommonArgs>
<!-- ShortStack builds only publish new assets from the runtime repository. All other assets are duplicates. -->
<CommonArgs Condition="'$(ShortStack)' == 'true' and '$(MSBuildProjectName)' != 'runtime'">$(CommonArgs) /p:DefaultArtifactVisibility=Vertical</CommonArgs>
</PropertyGroup>

<!-- Build specific args -->
Expand Down
17 changes: 13 additions & 4 deletions src/SourceBuild/content/repo-projects/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,33 @@
<!-- Force use of dotnet msbuild (ignoring global.json contents) unless ForceDotNetMSBuildEngine is explicitly set in the repo project. -->
<CommonArgs Condition="'$(BuildOS)' == 'windows' and '$(ForceDotNetMSBuildEngine)' != 'false'">$(CommonArgs) $(FlagParameterPrefix)msbuildEngine dotnet</CommonArgs>

<!-- Only pass these properites through when necessary to reduce command line noise. -->
<CommonArgs Condition="'$(DotNetBuildTests)' == 'true' and '$(DotNetBuildTestsOptOut)' != 'true'">$(CommonArgs) /p:DotNetBuildTests=true</CommonArgs>
</PropertyGroup>

<!-- Add repo-specific output paths. -->
<PropertyGroup Condition="'$(UseRepoArtifactsOutputPaths)' == 'true'">
<!-- Add the overrides for the shipping and non-shipping packages here to allow repo projects to identify a project as reference-only -->
<RepoArtifactsShippingPackagesDir Condition="'$(ReferenceOnlyRepoArtifacts)' != 'true'">$([MSBuild]::NormalizeDirectory('$(ArtifactsShippingPackagesDir)', '$(RepositoryName)'))</RepoArtifactsShippingPackagesDir>
<RepoArtifactsShippingPackagesDir Condition="'$(ReferenceOnlyRepoArtifacts)' == 'true'">$(ReferencePackagesDir)</RepoArtifactsShippingPackagesDir>
<RepoArtifactsNonShippingPackagesDir Condition="'$(ReferenceOnlyRepoArtifacts)' != 'true'">$([MSBuild]::NormalizeDirectory('$(ArtifactsNonShippingPackagesDir)', '$(RepositoryName)'))</RepoArtifactsNonShippingPackagesDir>
<RepoArtifactsNonShippingPackagesDir Condition="'$(ReferenceOnlyRepoArtifacts)' == 'true'">$(ReferencePackagesDir)</RepoArtifactsNonShippingPackagesDir>
<RepoArtifactsPdbArtifactsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsSymStoreDirectory)', '$(RepositoryName)'))</RepoArtifactsPdbArtifactsDir>

<!-- Pass locations for assets -->
<CommonArgs>$(CommonArgs) /p:SourceBuiltAssetsDir=$(ArtifactsAssetsDir)</CommonArgs>
<CommonArgs>$(CommonArgs) /p:SourceBuiltAssetManifestsDir=$(RepoAssetManifestsDir)</CommonArgs>

<!-- Pass location for packages -->
<CommonArgs>$(CommonArgs) /p:SourceBuiltShippingPackagesDir=$(RepoArtifactsShippingPackagesDir)</CommonArgs>
<!-- Trim the trailing slash as it breaks argument parsing on Windows if this is the last argument. -->
<CommonArgs>$(CommonArgs) /p:SourceBuiltNonShippingPackagesDir=$(RepoArtifactsNonShippingPackagesDir.TrimEnd('\'))</CommonArgs>
<CommonArgs>$(CommonArgs) /p:SourceBuiltPdbArtifactsDir=$(RepoArtifactsPdbArtifactsDir.TrimEnd('\'))</CommonArgs>
<CommonArgs>$(CommonArgs) /p:SourceBuiltNonShippingPackagesDir=$(RepoArtifactsNonShippingPackagesDir.TrimEnd('\'))</CommonArgs>
</PropertyGroup>

<!-- Pass RID and Portable/non-portable information -->
<!-- Pass RID and Portable/non-portable information -->
<PropertyGroup>
<_platformIndex>$(NETCoreSdkRuntimeIdentifier.LastIndexOf('-'))</_platformIndex>
<RuntimeOS>$(NETCoreSdkRuntimeIdentifier.Substring(0, $(_platformIndex)))</RuntimeOS>

Expand All @@ -38,9 +50,6 @@
<CommonArgs>$(CommonArgs) /p:PortableBuild=$(PortableBuild)</CommonArgs>
<CommonArgs Condition="'$(ShortStack)' != 'true' and '$(TargetOS)' != 'linux-musl'">$(CommonArgs) /p:RuntimeOS=$(RuntimeOS)</CommonArgs>
<CommonArgs Condition="'$(ShortStack)' != 'true' and '$(TargetOS)' != 'linux-musl'">$(CommonArgs) /p:BaseOS=$(BaseOS)</CommonArgs>

<!-- Only pass these properites through when necessary to reduce command line noise. -->
<CommonArgs Condition="'$(DotNetBuildTests)' == 'true' and '$(DotNetBuildTestsOptOut)' != 'true'">$(CommonArgs) /p:DotNetBuildTests=true</CommonArgs>
</PropertyGroup>

<PropertyGroup>
Expand Down
13 changes: 8 additions & 5 deletions src/SourceBuild/content/repo-projects/dotnet.proj
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<Project Sdk="Microsoft.Build.NoTargets">

<PropertyGroup>
<!-- This is a wrapper project that doesn't build anything. -->
<IsUtilityProject>true</IsUtilityProject>
<!-- The dotnet "repo" project just uses Arcade to drive the build. -->
<BuildScript>$(ProjectDirectory)eng\common\build$(ShellExtension)</BuildScript>
<UseRepoArtifactsOutputPaths>false</UseRepoArtifactsOutputPaths>

<BuildArgs Condition="'$(ArtifactsStagingDir)' != ''">$(BuildArgs) /p:ArtifactsStagingDir="$(ArtifactsStagingDir)"</BuildArgs>
<BuildArgs>$(BuildArgs) /p:VerticalArtifactsDir="$(ArtifactsDir.TrimEnd('/\'))"</BuildArgs>
</PropertyGroup>

<!-- This project file serves a couple of purpose.
Expand All @@ -11,7 +14,8 @@
- If we have a repo that is not in sdk's dependency tree, we can still build it by including it here. -->

<ItemGroup>
<RepositoryReference Include="sdk" />
<RepositoryReference Condition="'$(ShortStack)' != 'true'" Include="sdk" />
<RepositoryReference Condition="'$(ShortStack)' == 'true'" Include="runtime" />
</ItemGroup>

<ItemGroup Condition="'$(DotNetBuildPass)' == '2' and '$(TargetOS)' == 'windows' and '$(TargetArchitecture)' == 'x64'">
Expand All @@ -25,5 +29,4 @@
<RepositoryReference Remove="@(RepositoryReference)" />
<RepositoryReference Include="runtime" DotNetBuildPass="2" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/SourceBuild/content/src/dotnet/DotNet.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Solution />
74 changes: 74 additions & 0 deletions src/SourceBuild/content/src/dotnet/eng/Publishing.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<Project InitialTargets="DiscoverArtifacts">
<PropertyGroup>
<EnableDefaultArtifacts>false</EnableDefaultArtifacts>
<PushToLocalStorage>true</PushToLocalStorage>
<PreserveRepoOrigin>true</PreserveRepoOrigin>
<ArtifactsStagingDir Condition="'$(ArtifactsStagingDir)' == ''">$(VerticalArtifactsDir)/staging/</ArtifactsStagingDir>
<SourceBuiltAssetsDir>$(ArtifactsStagingDir)/assets/$(Configuration)</SourceBuiltAssetsDir>
<SourceBuiltAssetManifestsDir>$(ArtifactsStagingDir)/manifests/$(Configuration)</SourceBuiltAssetManifestsDir>
<SourceBuiltPdbArtifactsDir>$(ArtifactsStagingDir)/PDB/$(Configuration)</SourceBuiltPdbArtifactsDir>
<PublishingUseHardlinksIfPossible>true</PublishingUseHardlinksIfPossible>
<AssetManifestName Condition="'$(VerticalName)' != ''">$(VerticalName).xml</AssetManifestName>
<AssetManifestName Condition="'$(DotNetBuildSourceOnly)' == 'true' or '$(AssetManifestName)' == ''">VerticalManifest.xml</AssetManifestName>
</PropertyGroup>
<PropertyGroup Condition="'$(DotNetBuildSourceOnly)' != 'true'">
<SourceBuiltShippingPackagesDir>$(ArtifactsStagingDir)/packages/$(Configuration)/Shipping</SourceBuiltShippingPackagesDir>
<SourceBuiltNonShippingPackagesDir>$(ArtifactsStagingDir)/packages/$(Configuration)/NonShipping</SourceBuiltNonShippingPackagesDir>
</PropertyGroup>
<!--
When building from source, the Private.SourceBuilt.Artifacts archive will contain the nuget packages, so don't push them where we'll upload from.
-->
<PropertyGroup Condition="'$(DotNetBuildSourceOnly)' == 'true'">
<SourceBuiltShippingPackagesDir>$(VerticalArtifactsDir)/tmp/staging/packages/$(Configuration)/Shipping</SourceBuiltShippingPackagesDir>
<SourceBuiltNonShippingPackagesDir>$(VerticalArtifactsDir)/tmp/staging/packages/$(Configuration)/NonShipping</SourceBuiltNonShippingPackagesDir>
</PropertyGroup>
<PropertyGroup>
<AssetManifestsIntermediateDir>$([MSBuild]::NormalizeDirectory('$(VerticalArtifactsDir)', 'obj', 'manifests', '$(Configuration)'))</AssetManifestsIntermediateDir>
<IntermediateSymbolsRootDir>$([MSBuild]::NormalizeDirectory('$(VerticalArtifactsDir)', 'obj', 'Symbols'))</IntermediateSymbolsRootDir>
</PropertyGroup>
<ItemGroup>
<ArtifactVisibilityToPublish Remove="@(ArtifactVisibilityToPublish)" />
<ArtifactVisibilityToPublish Include="Internal;External" />
</ItemGroup>

<!-- Build task assembly paths -->
<PropertyGroup>
<MicrosoftDotNetUnifiedBuildTasksAssembly>$([MSBuild]::NormalizePath('$(VerticalArtifactsDir)', 'bin', 'Microsoft.DotNet.UnifiedBuild.Tasks', '$(Configuration)', 'Microsoft.DotNet.UnifiedBuild.Tasks.dll'))</MicrosoftDotNetUnifiedBuildTasksAssembly>
</PropertyGroup>

<UsingTask TaskName="Microsoft.DotNet.UnifiedBuild.Tasks.GetKnownArtifactsFromAssetManifests" AssemblyFile="$(MicrosoftDotNetUnifiedBuildTasksAssembly)" TaskFactory="TaskHostFactory" />

<Target Name="DiscoverArtifacts">
<ItemGroup>
<!-- Repo manifests from individual repos -->
<RepoManifests Include="$(AssetManifestsIntermediateDir)/**/*.xml" />
</ItemGroup>
<!-- Get produced packages and assets from the manifests -->
<GetKnownArtifactsFromAssetManifests AssetManifests="@(RepoManifests)">
<Output TaskParameter="KnownPackages" ItemName="ProducedPackage" />
<Output TaskParameter="KnownBlobs" ItemName="ProducedAsset" />
</GetKnownArtifactsFromAssetManifests>
<ItemGroup>
<ProducedPackage>
<IsShipping Condition="'%(ProducedPackage.NonShipping)' != 'true'">true</IsShipping>
<IsShipping Condition="'%(ProducedPackage.NonShipping)' == 'true'">false</IsShipping>
<Kind>Package</Kind>
</ProducedPackage>
<ProducedPackage>
<ShippingFolder Condition="'%(ProducedPackage.NonShipping)' != 'true'">Shipping</ShippingFolder>
<ShippingFolder Condition="'%(ProducedPackage.NonShipping)' == 'true'">NonShipping</ShippingFolder>
</ProducedPackage>

<ReferencePackage Include="@(ProducedPackage->'$(ReferencePackageNupkgCacheDir)%(Identity).%(Version).nupkg')" Condition="'%(RepoOrigin)' == 'source-build-reference-packages'" />
</ItemGroup>

<!-- Create Artifact items for produced packages and assets -->
<ItemGroup>
<Artifact Include="@(ProducedPackage->'$(VerticalArtifactsDir)/packages/%(ShippingFolder)/%(RepoOrigin)/%(Identity).%(Version).nupkg')" Condition="'%(RepoOrigin)' != 'source-build-reference-packages'" />
<Artifact Include="@(ReferencePackage)" RepoOrigin="SourceBuildReferencePackages" />
<Artifact Include="@(ProducedAsset->'$(VerticalArtifactsDir)/assets/$(Configuration)/%(Identity)')">
<Kind>Asset</Kind>
</Artifact>
</ItemGroup>
</Target>
</Project>

0 comments on commit b6613cf

Please sign in to comment.