Skip to content

Commit

Permalink
Use -pack switch instead of -allconfigurations to create packages (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorHofer authored Jan 3, 2025
1 parent 27fd292 commit 19c25fd
Show file tree
Hide file tree
Showing 19 changed files with 223 additions and 218 deletions.
2 changes: 1 addition & 1 deletion docs/project/library-servicing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Keep in mind that we still need package authoring in .NET 8 and older versions.

Develop and test your change as normal. For packages, you may want to test them outside the repo infrastructure. To do so, execute the following steps:

1. From a clean copy of your branch, run `build.cmd/sh libs -allconfigurations`
1. From a clean copy of your branch, run `build.cmd/sh libs -pack`

2. Check in `artifacts\bin\packages\Debug` for the existence of your package, with the appropriate package version.

Expand Down
3 changes: 1 addition & 2 deletions eng/DotNetBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@
Properties that control flags from the VMR build, and the expected output for the VMR build should be added to this file. -->

<!-- Enable regular Arcade signing and publishing in VMR build -->
<InnerBuildArgs Condition="'$(DotNetBuildOrchestrator)' == 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)restore $(FlagParameterPrefix)build $(FlagParameterPrefix)publish</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildOrchestrator)' == 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)restore $(FlagParameterPrefix)build $(FlagParameterPrefix)pack $(FlagParameterPrefix)publish</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildOrchestrator)' == 'true' and '$(Sign)' == 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)sign</InnerBuildArgs>

<InnerBuildArgs>$(InnerBuildArgs) $(FlagParameterPrefix)arch $(TargetArch)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(DotNetBuildSourceOnly)' != 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)os $(TargetOS)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(CrossBuild)' == 'true' or ('$(TargetArch)' != '$(_hostArch)' and '$(ShortStack)' != 'true')">$(InnerBuildArgs) $(FlagParameterPrefix)cross</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) $(FlagParameterPrefix)configuration $(Configuration)</InnerBuildArgs>
<InnerBuildArgs Condition="'$(ShortStack)' != 'true'">$(InnerBuildArgs) $(FlagParameterPrefix)allconfigurations</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) $(FlagParameterPrefix)verbosity $(LogVerbosity)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) $(FlagParameterPrefix)nodereuse $(ArcadeFalseBoolBuildArg)</InnerBuildArgs>
<InnerBuildArgs>$(InnerBuildArgs) $(FlagParameterPrefix)warnAsError $(ArcadeFalseBoolBuildArg)</InnerBuildArgs>
Expand Down
4 changes: 2 additions & 2 deletions eng/Publishing.props
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@

<!--
Packages that aren't matched above as RID-specific are considered RID-agnostic. Also include
the AllConfigurations packages from the Libraries build.
the packages from the Libraries build.
-->
<RidAgnosticNupkgToPublishFile
Include="
$(DownloadDirectory)**\Microsoft.NET.Workload.Mono.Toolchain.*Manifest-*.nupkg;
$(DownloadDirectory)**\Microsoft.NET.Sdk.WebAssembly.Pack.*.nupkg;
$(DownloadDirectory)*\$(PublishRidAgnosticPackagesFromPlatform)\**\*.nupkg;
$(DownloadDirectory)*\*AllConfigurations\**\*.nupkg"
$(DownloadDirectory)*\Libraries_WithPackages\**\*.nupkg"
Exclude="@(RuntimeNupkgFile);@(DownloadedSymbolNupkgFile)" />

<TransportPackagesToPublishFile
Expand Down
1 change: 0 additions & 1 deletion eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
<ItemDefinitionGroup>
<ProjectToBuild>
<Test>false</Test>
<Pack>false</Pack>
<Publish>false</Publish>
<BuildInParallel>false</BuildInParallel>
</ProjectToBuild>
Expand Down
5 changes: 2 additions & 3 deletions eng/build.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[CmdletBinding(PositionalBinding=$false)]
Param(
[switch][Alias('h')]$help,
[switch]$pack,
[switch][Alias('t')]$test,
[ValidateSet("Debug","Release","Checked")][string[]][Alias('c')]$configuration = @("Debug"),
[string][Alias('f')]$framework,
[string]$vs,
[string][Alias('v')]$verbosity = "minimal",
[ValidateSet("windows","linux","osx","android","browser","wasi")][string]$os,
[switch]$allconfigurations,
[switch]$coverage,
[string]$testscope,
[switch]$testnobuild,
Expand Down Expand Up @@ -77,7 +77,6 @@ function Get-Help() {
Write-Host ""

Write-Host "Libraries settings:"
Write-Host " -allconfigurations Build packages for all build configurations."
Write-Host " -coverage Collect code coverage when testing."
Write-Host " -framework (-f) Build framework: net10.0 or net48."
Write-Host " [Default: net10.0]"
Expand Down Expand Up @@ -312,7 +311,7 @@ foreach ($argument in $PSBoundParameters.Keys)
"hostConfiguration" { $arguments += " /p:HostConfiguration=$((Get-Culture).TextInfo.ToTitleCase($($PSBoundParameters[$argument])))" }
"framework" { $arguments += " /p:BuildTargetFramework=$($PSBoundParameters[$argument].ToLowerInvariant())" }
"os" { $arguments += " /p:TargetOS=$($PSBoundParameters[$argument])" }
"allconfigurations" { $arguments += " /p:BuildAllConfigurations=true" }
"pack" { $arguments += " -pack /p:BuildAllConfigurations=true" }
"properties" { $arguments += " " + $properties }
"verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) }
"cmakeargs" { $arguments += " /p:CMakeArgs=`"$($PSBoundParameters[$argument])`"" }
Expand Down
5 changes: 2 additions & 3 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ usage()
echo ""

echo "Libraries settings:"
echo " --allconfigurations Build packages for all build configurations."
echo " --coverage Collect code coverage when testing."
echo " --framework (-f) Build framework: net10.0 or net48."
echo " [Default: net10.0]"
Expand Down Expand Up @@ -308,8 +307,8 @@ while [[ $# > 0 ]]; do
shift 2
;;

-allconfigurations)
arguments="$arguments /p:BuildAllConfigurations=true"
-pack)
arguments="$arguments --pack /p:BuildAllConfigurations=true"
shift 1
;;

Expand Down
9 changes: 2 additions & 7 deletions eng/packaging.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,10 @@
<PackageReadmeFilePath Condition="'$(PackageReadmeFilePath)' == '' and '$(EnableDefaultPackageReadmeFile)' == 'true'">PACKAGE.md</PackageReadmeFilePath>
<BeforePack>$(BeforePack);ValidatePackageReadmeExists</BeforePack>

<!-- Generate packages for rid specific projects or for allconfigurations during build. -->
<!-- A package isn't generated if in servicing or in runtimelab. Intended to be overridden at project level. -->
<!-- Generate packages for rid specific projects when not in runtimelab (to avoid binclashes when using the same feed). -->
<IsRIDSpecificProject Condition="$(MSBuildProjectName.StartsWith('runtime.')) and
!$(MSBuildProjectName.StartsWith('runtime.native'))">true</IsRIDSpecificProject>
<GeneratePackageOnBuild Condition="(
'$(BuildAllConfigurations)' == 'true' or
'$(IsRIDSpecificProject)' == 'true'
) and
'$(GitHubRepositoryName)' != 'runtimelab'">true</GeneratePackageOnBuild>
<GeneratePackageOnBuild Condition="'$(IsRIDSpecificProject)' == 'true' and '$(GitHubRepositoryName)' != 'runtimelab'">true</GeneratePackageOnBuild>

<!-- During NoBuild pack invocations, skip project reference build. Necessary for the IncludeProjectReferencesWithPackAttributeInPackage target. -->
<BuildProjectReferences Condition="'$(NoBuild)' == 'true'">false</BuildProjectReferences>
Expand Down
7 changes: 3 additions & 4 deletions eng/pipelines/global-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ extends:
eq(variables['isRollingBuild'], true))

#
# Build Libraries AllConfigurations. This exercises the code path where we build libraries for all
# configurations on a non Windows operating system.
# Build Libraries (all TFMs) and create packages on a non Windows operating system.
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand All @@ -92,8 +91,8 @@ extends:
platforms:
- linux_x64_dev_innerloop
jobParameters:
nameSuffix: Libraries_AllConfigurations
buildArgs: -subset libs -allconfigurations
nameSuffix: Libraries_WithPackages
buildArgs: -subset libs -pack
timeoutInMinutes: 120
condition:
or(
Expand Down
2 changes: 0 additions & 2 deletions eng/pipelines/official/stages/publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
PublishRidAgnosticPackagesFromPlatform: windows_x64
publishingInfraVersion: 3

stages:

Expand Down Expand Up @@ -28,7 +27,6 @@ stages:
# Stages-based publishing entry point
- template: /eng/common/templates-official/post-build/post-build.yml
parameters:
publishingInfraVersion: ${{ parameters.publishingInfraVersion }}
validateDependsOn:
- PrepareForPublish
# The following checks are run after the build in the validation and release pipelines
Expand Down
8 changes: 4 additions & 4 deletions eng/pipelines/runtime-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ extends:
name: MonoRuntimePacks

#
# Build libraries AllConfigurations for packages
# Build libraries (all TFMs) and packages
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand All @@ -464,13 +464,13 @@ extends:
- windows_x64
jobParameters:
templatePath: 'templates-official'
buildArgs: -s tools+libs -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_AllConfigurations
buildArgs: -s tools+libs -pack -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_WithPackages
isOfficialBuild: ${{ variables.isOfficialBuild }}
postBuildSteps:
- template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
parameters:
name: Libraries_AllConfigurations
name: Libraries_WithPackages
timeoutInMinutes: 95
#
# Build SourceBuild packages
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtime-richnav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extends:
richCodeNavigationLanguage: "csharp"
nameSuffix: Libs
timeoutInMinutes: 240
buildArgs: -s libs.sfx+libs.oob -allConfigurations
buildArgs: -s libs.sfx+libs.oob -pack
preBuildSteps:
- script: dotnet.cmd nuget add source -n richnav "https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-buildservices/nuget/v3/index.json"
displayName: Add richnav NuGet feed
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ extends:
eq(variables['isRollingBuild'], true))
#
# Build and test libraries AllConfigurations
# Build and test libraries for all TFMs and create packages
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
Expand All @@ -1234,8 +1234,8 @@ extends:
platforms:
- windows_x64
jobParameters:
buildArgs: -test -s tools+libs+libs.tests -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_AllConfigurations
buildArgs: -test -s tools+libs+libs.tests -pack -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_WithPackages
timeoutInMinutes: 150
condition: >-
or(
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtimelab-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extends:
- windows_x64
jobParameters:
templatePath: 'templates-official'
buildArgs: -s tools+libs -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
buildArgs: -s tools+libs -allConfigurations -c $(_BuildConfig) /p:BuildAllConfigurations=true /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_AllConfigurations
isOfficialBuild: true
postBuildSteps:
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/runtimelab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extends:
platforms:
- windows_x64
jobParameters:
buildArgs: -test -s tools+libs+libs.tests -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
buildArgs: -test -s tools+libs+libs.tests -c $(_BuildConfig) /p:BuildAllConfigurations=true /p:TestAssemblies=false /p:TestPackages=true
nameSuffix: Libraries_AllConfigurations
timeoutInMinutes: 150
extraVariablesTemplates:
Expand Down
58 changes: 58 additions & 0 deletions src/libraries/oob-trim.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<Project Sdk="Microsoft.Build.NoTargets">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)-$(TargetOS)</TargetFramework>
<!-- Import the illink file which contains some of the logic required to illink the out-of-band assemblies. -->
<ExplicitlyImportCustomILLinkTargets>true</ExplicitlyImportCustomILLinkTargets>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="oob-src.proj" OutputItemType="OOBAssembly" />
</ItemGroup>

<Target Name="GetTrimOOBAssembliesInputs"
DependsOnTargets="ResolveProjectReferences">
<PropertyGroup>
<OOBAssembliesTrimDir>$([MSBuild]::NormalizeDirectory('$(IntermediateOutputPath)', 'illink-$(TargetArchitecture)'))</OOBAssembliesTrimDir>
<OOBAssembliesTrimMarkerFile>$(OOBAssembliesTrimDir)marker.txt</OOBAssembliesTrimMarkerFile>
</PropertyGroup>

<ItemGroup>
<OOBLibrarySuppressionsXml Include="@(OOBAssembly->Metadata('ILLinkSuppressionsXmls'))" />

<OOBAssemblyToTrim Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'true'))" />
<OOBAssemblyReference Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'false'));
@(SharedFrameworkAssembly)" />
</ItemGroup>
</Target>

<Target Name="TrimOOBAssemblies"
AfterTargets="Build"
DependsOnTargets="GetTrimOOBAssembliesInputs;PrepareForAssembliesTrim"
Inputs="$(ILLinkTasksAssembly);@(OOBAssemblyToTrim);@(OOBAssemblyReference);@(OOBLibrarySuppressionsXml)"
Outputs="$(OOBAssembliesTrimMarkerFile)">
<Message Text="$(MSBuildProjectName) -> Trimming $(OutputRID) out-of-band assemblies with ILLinker..." Importance="high" />

<PropertyGroup>
<OOBILLinkArgs>$(ILLinkArgs)</OOBILLinkArgs>
<!-- Unnecessary suppressions - disable for now since we didn't clean the runtime yet -->
<OOBILLinkArgs>$(ILLinkArgs) --nowarn IL2121</OOBILLinkArgs>
<OOBILLinkArgs Condition="'@(OOBLibrarySuppressionsXml)' != ''" >$(OOBILLinkArgs) --link-attributes "@(OOBLibrarySuppressionsXml->'%(FullPath)', '" --link-attributes "')"</OOBILLinkArgs>
</PropertyGroup>

<MakeDir Directories="$(OOBAssembliesTrimDir)" />
<ILLink AssemblyPaths=""
RootAssemblyNames="@(OOBAssemblyToTrim)"
ReferenceAssemblyPaths="@(OOBAssemblyReference)"
OutputDirectory="$(OOBAssembliesTrimDir)"
ExtraArgs="$(OOBILLinkArgs)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />

<!-- Create a marker file which serves as the target's output to enable incremental builds. -->
<Touch Files="$(OOBAssembliesTrimMarkerFile)"
AlwaysCreate="true" />
</Target>

</Project>
55 changes: 5 additions & 50 deletions src/libraries/oob.proj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.Build.NoTargets">
<Project Sdk="Microsoft.Build.Traversal">

<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)-$(TargetOS)</TargetFramework>
<!-- By default, build the NetCoreAppCurrent vertical only. -->
<BuildTargetFramework Condition="'$(BuildAllConfigurations)' != 'true'">$(NetCoreAppCurrent)</BuildTargetFramework>
<!-- Import the illink file which contains some of the logic required to illink the out-of-band assemblies. -->
<ExplicitlyImportCustomILLinkTargets Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">true</ExplicitlyImportCustomILLinkTargets>
</PropertyGroup>

<ItemGroup Condition="'$(BuildTargetFramework)' == '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
<ProjectReference Include="sfx-src.proj" OutputItemType="SharedFrameworkAssembly" />
<ProjectReference Include="oob-src.proj" OutputItemType="OOBAssembly" />
<ProjectReference Include="sfx-src.proj" />
<ProjectReference Include="oob-src.proj" />

<ProjectReference Include="apicompat\ApiCompat.proj"
Condition="'$(DotNetBuildSourceOnly)' != 'true' and '$(ApiCompatValidateAssemblies)' != 'false'" />

<ProjectReference Include="oob-trim.proj" />
</ItemGroup>

<ItemGroup Condition="'$(BuildTargetFramework)' != '$(NetCoreAppCurrent)' or '$(BuildTargetFramework)' == ''">
Expand All @@ -22,51 +22,6 @@
<ProjectReference Include="oob-gen.proj" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
</ItemGroup>

<Target Name="GetTrimOOBAssembliesInputs"
DependsOnTargets="ResolveProjectReferences">
<PropertyGroup>
<OOBAssembliesTrimDir>$([MSBuild]::NormalizeDirectory('$(IntermediateOutputPath)', 'illink-$(TargetArchitecture)'))</OOBAssembliesTrimDir>
<OOBAssembliesTrimMarkerFile>$(OOBAssembliesTrimDir)marker.txt</OOBAssembliesTrimMarkerFile>
</PropertyGroup>

<ItemGroup>
<OOBLibrarySuppressionsXml Include="@(OOBAssembly->Metadata('ILLinkSuppressionsXmls'))" />

<OOBAssemblyToTrim Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'true'))" />
<OOBAssemblyReference Include="@(OOBAssembly->WithMetadataValue('IsTrimmable', 'false'));
@(SharedFrameworkAssembly)" />
</ItemGroup>
</Target>

<Target Name="TrimOOBAssemblies"
AfterTargets="Build"
Condition="'@(OOBAssembly)' != ''"
DependsOnTargets="GetTrimOOBAssembliesInputs;PrepareForAssembliesTrim"
Inputs="$(ILLinkTasksAssembly);@(OOBAssemblyToTrim);@(OOBAssemblyReference);@(OOBLibrarySuppressionsXml)"
Outputs="$(OOBAssembliesTrimMarkerFile)">
<Message Text="$(MSBuildProjectName) -> Trimming $(OutputRID) out-of-band assemblies with ILLinker..." Importance="high" />

<PropertyGroup>
<OOBILLinkArgs>$(ILLinkArgs)</OOBILLinkArgs>
<!-- Unnecessary suppressions - disable for now since we didn't clean the runtime yet -->
<OOBILLinkArgs>$(ILLinkArgs) --nowarn IL2121</OOBILLinkArgs>
<OOBILLinkArgs Condition="'@(OOBLibrarySuppressionsXml)' != ''" >$(OOBILLinkArgs) --link-attributes "@(OOBLibrarySuppressionsXml->'%(FullPath)', '" --link-attributes "')"</OOBILLinkArgs>
</PropertyGroup>

<MakeDir Directories="$(OOBAssembliesTrimDir)" />
<ILLink AssemblyPaths=""
RootAssemblyNames="@(OOBAssemblyToTrim)"
ReferenceAssemblyPaths="@(OOBAssemblyReference)"
OutputDirectory="$(OOBAssembliesTrimDir)"
ExtraArgs="$(OOBILLinkArgs)"
ToolExe="$(_DotNetHostFileName)"
ToolPath="$(_DotNetHostDirectory)" />

<!-- Create a marker file which serves as the target's output to enable incremental builds. -->
<Touch Files="$(OOBAssembliesTrimMarkerFile)"
AlwaysCreate="true" />
</Target>

<Target Name="SetAzureDevOpsVariableForBuiltPackages"
Condition="'$(ContinuousIntegrationBuild)' == 'true'"
AfterTargets="Build;Pack">
Expand Down
Loading

0 comments on commit 19c25fd

Please sign in to comment.