Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.14.50</VersionPrefix>
<VersionPrefix>17.14.51</VersionPrefix>
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.13.9</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
<!-- differentiate experimental insertions to avoid package id conflicts,
<!-- differentiate experimental insertions to avoid package id conflicts,
it has to be alphabetically after "preview" to avoid downgrade errors in VS -->
<PreReleaseVersionLabel Condition="'$(IsExperimental)' == 'true'">test</PreReleaseVersionLabel>
<DotNetUseShippingVersions>true</DotNetUseShippingVersions>
Expand All @@ -31,6 +31,18 @@
As a result, we CONTINUE TO REFERENCE the old versions at build time, so those are the versions that get embedded into MSBuild assemblies.
However, we can update, binding-redirect to, and distribute the newest version (that matches the VS-referenced versions) in order to get the benefits of updating.
See uses of $(UseFrozenMaintenancePackageVersions) for details.

These referenced versions are deliberately NOT bumped to the servicing build that the
net472 runtime wave ($(RuntimePackageVersion_VSDeploy)) was produced against: doing so
would change what the .NET (Core) build references and pull in new source-build prebuilts.
Instead, net472 redistributes the newer maintenance assemblies through the same
$(DeployRuntimeServicingAssemblies) swap as the runtime packages (see
src/Directory.Build.targets). Because their assembly versions move between servicing
builds, the matching redirects in src/MSBuild/app.config and app.amd64.config point at the
deployed assembly versions: System.Memory 4.6.3 -> 4.0.5.0,
System.Runtime.CompilerServices.Unsafe 6.1.2 -> 6.0.3.0,
System.Threading.Tasks.Extensions 4.6.3 -> 4.2.4.0, and the transitively redistributed
System.Buffers 4.6.1 -> 4.0.5.0 and System.Numerics.Vectors 4.6.1 -> 4.1.6.0.
-->
<SystemMemoryVersion>4.6.0</SystemMemoryVersion>
<SystemThreadingTasksExtensionsVersion>4.6.0</SystemThreadingTasksExtensionsVersion>
Expand All @@ -41,20 +53,30 @@
</PropertyGroup>
<PropertyGroup>
<!-- dotnet/runtime packages -->
<SystemCollectionsImmutableVersion>9.0.0</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>9.0.0</SystemConfigurationConfigurationManagerVersion>
<SystemDiagnosticsDiagnosticSourceVersion>9.0.0</SystemDiagnosticsDiagnosticSourceVersion>
<SystemDiagnosticsEventLogVersion>9.0.0</SystemDiagnosticsEventLogVersion>
<SystemFormatsAsn1Version>9.0.0</SystemFormatsAsn1Version>
<SystemFormatsNrbfVersion>9.0.0</SystemFormatsNrbfVersion>
<SystemReflectionMetadataVersion>9.0.0</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>9.0.0</SystemReflectionMetadataLoadContextVersion>
<SystemResourcesExtensionsVersion>9.0.0</SystemResourcesExtensionsVersion>
<SystemSecurityCryptographyProtectedDataVersion>9.0.0</SystemSecurityCryptographyProtectedDataVersion>
<SystemTextEncodingCodePagesVersion>9.0.0</SystemTextEncodingCodePagesVersion>
<SystemTextJsonVersion>9.0.0</SystemTextJsonVersion>
<SystemThreadingChannelsVersion>9.0.0</SystemThreadingChannelsVersion>
<SystemThreadingTasksDataflowVersion>9.0.0</SystemThreadingTasksDataflowVersion>
<!--
$(RuntimePackageVersion_CompileTime) is the version MSBuild COMPILES against and declares as its
own NuGet package dependencies. It is deliberately the same for every target framework
so that restore never sees a version downgrade: with central transitive pinning on, a
TargetFramework-conditioned version here would leak the higher version into leaf
packaging/test projects (which pin the unconditioned version directly) and fail with
NU1109.

For net472 we additionally REDISTRIBUTE a newer servicing build of these assemblies to
line up with a Visual Studio servicing event, WITHOUT changing what we compile or
declare against. That is driven by $(RuntimePackageVersion_VSDeploy): the newer packages
are downloaded and copied to the output in place of the compiled-against assemblies, and
the net472 binding redirects (src/MSBuild/app.config and app.amd64.config) point at them.
See the ReplaceRuntimeAssembliesWithServicingVersions target in src/Directory.Build.targets.
This mirrors the $(UseFrozenMaintenancePackageVersions) mechanism in reverse (there we
compile against an older build than we ship; here we ship a newer build than we compile).

These two versions are the single source of truth. src/Directory.Build.targets selects between
them per project and assigns the individual System.* runtime package versions from the result;
the selection lives there because it depends on $(IsUnitTestProject) and $(TargetFramework),
which are not yet set this early.
-->
<RuntimePackageVersion_CompileTime>9.0.0</RuntimePackageVersion_CompileTime>
<RuntimePackageVersion_VSDeploy>10.0.8</RuntimePackageVersion_VSDeploy>
</PropertyGroup>
<PropertyGroup>
<!-- maintained in eng/dependabot/Packages.props -->
Expand Down
156 changes: 156 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,50 @@
<PackageDownload Include="System.Numerics.Vectors" Version="[$(FrozenSystemNumericsVectorsVersion)]" />
</ItemGroup>

<!--
Select the dotnet/runtime build each project references. This selection lives here rather than in
eng/Versions.props because it depends on $(IsUnitTestProject) and $(TargetFramework), which are
not yet set when that file is imported.

Most projects reference $(RuntimePackageVersion_CompileTime) - the build MSBuild compiles against
and declares as its own package dependencies. net472 unit-test projects load Microsoft.Build
in-proc and run the redistributed MSBuild.exe, so they instead reference the servicing build the
application projects redistribute (see $(DeployRuntimeServicingAssemblies) below):
$(RuntimePackageVersion_VSDeploy). Referencing it flows the servicing versions through restore,
keeping each test output directory self-consistent - the deployed assemblies, the generated
test-host binding redirects, and the bundled MSBuild.exe.config all agree. net9.0 keeps the
compile-time versions (the shared framework supplies these there).

Pinning only the leaf test projects higher does not cause an NU1109 downgrade, because their
transitive providers (Microsoft.Build etc.) stay at $(RuntimePackageVersion_CompileTime).
-->
<PropertyGroup>
<RuntimePackageVersion Condition="'$(IsUnitTestProject)' == 'true' and '$(TargetFramework)' == 'net472'">$(RuntimePackageVersion_VSDeploy)</RuntimePackageVersion>
<RuntimePackageVersion Condition="'$(RuntimePackageVersion)' == ''">$(RuntimePackageVersion_CompileTime)</RuntimePackageVersion>

<SystemCollectionsImmutableVersion>$(RuntimePackageVersion)</SystemCollectionsImmutableVersion>
<SystemConfigurationConfigurationManagerVersion>$(RuntimePackageVersion)</SystemConfigurationConfigurationManagerVersion>
<SystemDiagnosticsDiagnosticSourceVersion>$(RuntimePackageVersion)</SystemDiagnosticsDiagnosticSourceVersion>
<SystemDiagnosticsEventLogVersion>$(RuntimePackageVersion)</SystemDiagnosticsEventLogVersion>
<SystemFormatsAsn1Version>$(RuntimePackageVersion)</SystemFormatsAsn1Version>
<SystemFormatsNrbfVersion>$(RuntimePackageVersion)</SystemFormatsNrbfVersion>
<SystemReflectionMetadataVersion>$(RuntimePackageVersion)</SystemReflectionMetadataVersion>
<SystemReflectionMetadataLoadContextVersion>$(RuntimePackageVersion)</SystemReflectionMetadataLoadContextVersion>
<SystemResourcesExtensionsVersion>$(RuntimePackageVersion)</SystemResourcesExtensionsVersion>
<SystemSecurityCryptographyProtectedDataVersion>$(RuntimePackageVersion)</SystemSecurityCryptographyProtectedDataVersion>
<SystemTextEncodingCodePagesVersion>$(RuntimePackageVersion)</SystemTextEncodingCodePagesVersion>
<SystemTextJsonVersion>$(RuntimePackageVersion)</SystemTextJsonVersion>
<SystemThreadingChannelsVersion>$(RuntimePackageVersion)</SystemThreadingChannelsVersion>
<SystemThreadingTasksDataflowVersion>$(RuntimePackageVersion)</SystemThreadingTasksDataflowVersion>
</PropertyGroup>

<!-- The net472 servicing wave binds to newer maintenance packages than the compile-time defaults in eng/Versions.props. -->
<PropertyGroup Condition="'$(IsUnitTestProject)' == 'true' and '$(TargetFramework)' == 'net472'">
<SystemMemoryVersion>4.6.3</SystemMemoryVersion>
<SystemThreadingTasksExtensionsVersion>4.6.3</SystemThreadingTasksExtensionsVersion>
<SystemRuntimeCompilerServicesUnsafeVersion>6.1.2</SystemRuntimeCompilerServicesUnsafeVersion>
</PropertyGroup>

<!-- Work around maintenance-packages updates breaking stuff -->
<Target Name="ReplaceCompileReferencesWithOlderMaintenancePackagesVersions"
BeforeTargets="ResolveAssemblyReferences"
Expand All @@ -184,6 +228,118 @@
</ItemGroup>
</Target>

<!--
net472 redistributes newer dotnet/runtime servicing assemblies than it compiles against,
to line up with a Visual Studio servicing event. This mirrors the frozen maintenance-package
mechanism above, in reverse: compile and restore stay at the referenced versions so there is
no package downgrade (and so the .NET (Core) build, which shares these references, does not
pull in new source-build prebuilts), while here we download the servicing build and copy those
assemblies to the output in place of the compiled-against ones. The matching binding redirects
live in src/MSBuild/app.config and src/MSBuild/app.amd64.config and must be kept in sync with
%(_DeployedRuntimeAssembly.Version).

The dotnet/runtime 10.x wave is redistributed at $(RuntimePackageVersion_VSDeploy); the
maintenance packages it binds to (System.Memory etc.) are redistributed at the matching
servicing versions without changing their referenced ($(SystemMemoryVersion) etc.) versions.

This is opt-in per project ($(DeployRuntimeServicingAssemblies)) and intended only for the
assemblies that Visual Studio actually loads (the MSBuild.exe output directory). Enabling it
in a library project would make that project's output disagree with what every downstream
project compiles against, producing spurious MSB3277 version-conflict warnings (errors under
-warnAsError); the redistributed assemblies must therefore only appear in the final,
non-referenced application output.
-->
<ItemGroup Condition="'$(TargetFramework)' == 'net472' and '$(DeployRuntimeServicingAssemblies)' == 'true'">
<!-- dotnet/runtime 10.x servicing wave, redistributed at $(RuntimePackageVersion_VSDeploy). -->
<_DeployedRuntimeAssembly Include="System.Collections.Immutable;System.Configuration.ConfigurationManager;System.Diagnostics.DiagnosticSource;System.Diagnostics.EventLog;System.Formats.Asn1;System.Formats.Nrbf;System.Reflection.Metadata;System.Reflection.MetadataLoadContext;System.Resources.Extensions;System.Security.Cryptography.ProtectedData;System.Text.Encoding.CodePages;System.Text.Json;System.Threading.Channels;System.Threading.Tasks.Dataflow">
<Version>$(RuntimePackageVersion_VSDeploy)</Version>
</_DeployedRuntimeAssembly>
<!-- Transitive dependencies of the above (notably of System.Text.Json) that we also
redistribute and that ship as part of the same wave. -->
<_DeployedRuntimeAssembly Include="System.IO.Pipelines;System.Text.Encodings.Web;Microsoft.Bcl.AsyncInterfaces">
<Version>$(RuntimePackageVersion_VSDeploy)</Version>
</_DeployedRuntimeAssembly>
<!-- Maintenance packages the wave binds to. Their assembly versions move between servicing
builds (so the app.config / app.amd64.config redirects move with them); they are
redistributed here without bumping their referenced versions. -->
<_DeployedRuntimeAssembly Include="System.Memory">
<Version>4.6.3</Version>
</_DeployedRuntimeAssembly>
<_DeployedRuntimeAssembly Include="System.Runtime.CompilerServices.Unsafe">
<Version>6.1.2</Version>
</_DeployedRuntimeAssembly>
<_DeployedRuntimeAssembly Include="System.Threading.Tasks.Extensions">
<Version>4.6.3</Version>
</_DeployedRuntimeAssembly>
<_DeployedRuntimeAssembly Include="System.Buffers">
<Version>4.6.1</Version>
</_DeployedRuntimeAssembly>
<_DeployedRuntimeAssembly Include="System.Numerics.Vectors">
<Version>4.6.1</Version>
</_DeployedRuntimeAssembly>
<!-- System.Formats.Nrbf in the 10.x wave binds to Microsoft.Bcl.HashCode 6.0.0.0 on net462,
but the compile-time closure only brings in 1.0.0.0. Redistribute 6.0.0 so the shipped
assembly matches the redirect (and the version Nrbf actually loads). -->
<_DeployedRuntimeAssembly Include="Microsoft.Bcl.HashCode">
<Version>6.0.0</Version>
</_DeployedRuntimeAssembly>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472' and '$(DeployRuntimeServicingAssemblies)' == 'true'">
<PackageDownload Include="@(_DeployedRuntimeAssembly)" Version="[%(Version)]" />
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net472' and '$(DeployRuntimeServicingAssemblies)' == 'true'">
<!-- RAR sees the net472 binding redirect to the deployed version but resolves the referenced
version (the swap to the servicing build happens after RAR, and the compile references
must stay on the packages so their .NET Framework type-forwards keep working), so it
reports an unresolvable version conflict. That mismatch is intentional;
ValidateMSBuildPackageDependencyVersions enforces that the shipped redirects match the
assemblies actually in the output. -->
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB3277</MSBuildWarningsAsMessages>
</PropertyGroup>

<!--
Swap the runtime copy-local assemblies AFTER RAR, so the output directory contains the
redistributed servicing build rather than the compiled-against one. We deliberately do NOT
touch the compile-time references: the net462 reference assemblies type-forward into the
.NET Framework (e.g. System.Configuration.ConfigurationManager forwards
ConfigurationErrorsException to the GAC's System.Configuration), and substituting raw file
references for the package references breaks those forwards. The build-time RAR
version-conflict warning that results is suppressed (and the real guardrail is the
ValidateMSBuildPackageDependencyVersions task) in the projects that opt in.
-->
<Target Name="ReplaceRuntimeAssembliesWithServicingVersions"
AfterTargets="ResolveAssemblyReferences"
Condition="'$(TargetFramework)' == 'net472' and '@(_DeployedRuntimeAssembly)' != ''">
<PropertyGroup>
<!-- Semicolon-delimited (and -bracketed) so membership tests can't match on a substring. -->
<_DeployedRuntimeAssemblyIds>;@(_DeployedRuntimeAssembly);</_DeployedRuntimeAssemblyIds>
<!-- The package ids that are actually copy-local in this project, so we only swap the
assemblies it really redistributes (some of the wave is not referenced here). -->
<_RuntimeCopyLocalIds>;@(ReferenceCopyLocalPaths->'%(NuGetPackageId)');</_RuntimeCopyLocalIds>
</PropertyGroup>
<ItemGroup>
<!-- Precompute the servicing-build path per assembly (kept out of the transform below so
that transform string stays free of nested quotes / property functions). -->
<_DeployedRuntimeAssembly>
<DeployedPath>$(NuGetPackageRoot)$([System.String]::Copy('%(Identity)').ToLowerInvariant())\%(Version)\lib\net462\%(Identity).dll</DeployedPath>
</_DeployedRuntimeAssembly>
</ItemGroup>
<ItemGroup>
<!-- Drop the compiled-against copies of the assemblies we redistribute... -->
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' != '' and $(_DeployedRuntimeAssemblyIds.Contains(';%(ReferenceCopyLocalPaths.NuGetPackageId);'))" />

<!-- ...and add the servicing build, but only for assemblies this project actually copies. -->
<ReferenceCopyLocalPaths Include="@(_DeployedRuntimeAssembly->'%(DeployedPath)')"
Condition="$(_RuntimeCopyLocalIds.Contains(';%(_DeployedRuntimeAssembly.Identity);'))">
<NuGetPackageId>%(_DeployedRuntimeAssembly.Identity)</NuGetPackageId>
<NuGetPackageVersion>%(_DeployedRuntimeAssembly.Version)</NuGetPackageVersion>
</ReferenceCopyLocalPaths>
</ItemGroup>
Comment thread
JanProvaznik marked this conversation as resolved.
Resolved
</Target>

<!-- Import parent targets -->
<Import Project="..\Directory.Build.targets"/>

Expand Down
6 changes: 6 additions & 0 deletions src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

<!-- The output of this project is sort of an "executable" so it can get the latest versions of everything. -->
<UseFrozenMaintenancePackageVersions>false</UseFrozenMaintenancePackageVersions>

<!-- This project's output is copied into the bootstrap MSBuild that tests run against, so it
is a redistribution surface for the net472 dotnet/runtime servicing assemblies just like
MSBuild.csproj. See the ReplaceRuntimeAssembliesWithServicingVersions target in
src/Directory.Build.targets. -->
<DeployRuntimeServicingAssemblies>true</DeployRuntimeServicingAssemblies>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/MSBuild/MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
redirect ValueTuple _down_ to match VS. -->
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>

<!-- This is the executable copy of MSBuild that Visual Studio loads, so its output is
where we redistribute the newer dotnet/runtime servicing assemblies for net472 (the
ones the net472 binding redirects in app.config / app.amd64.config point at). See the
ReplaceRuntimeAssembliesWithServicingVersions target in src/Directory.Build.targets. -->
<DeployRuntimeServicingAssemblies>true</DeployRuntimeServicingAssemblies>

<IsPackable>true</IsPackable>
<ContentTargetFolders>contentFiles</ContentTargetFolders>
<BuildOutputTargetFolder>contentFiles\any\</BuildOutputTargetFolder>
Expand Down
Loading