Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct product version in SPC in servicing #110980

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<!-- This prevents the default MsBuild targets from referencing System.Core.dll -->
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
<!-- Override InformationalVersion during servicing as it's returned via public api. -->
<InformationalVersion Condition="'$(PreReleaseVersionLabel)' == 'servicing'">$(ProductVersion)</InformationalVersion>
<InformationalVersion Condition="'$(StabilizePackageVersion)' == 'true'">$(ProductVersion)</InformationalVersion>
<NoWarn>$(NoWarn),0419,0649</NoWarn>
<Nullable>enable</Nullable>

Expand Down Expand Up @@ -302,6 +299,7 @@

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<CompilerVisibleProperty Include="ProductVersion" />
</ItemGroup>

<Import Project="CreateRuntimeRootILLinkDescriptorFile.targets" />
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<!-- This prevents the default MsBuild targets from referencing System.Core.dll -->
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
<RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
<!-- Override InformationalVersion during servicing as it's returned via public api. -->
<InformationalVersion Condition="'$(PreReleaseVersionLabel)' == 'servicing'">$(ProductVersion)</InformationalVersion>
<InformationalVersion Condition="'$(StabilizePackageVersion)' == 'true'">$(ProductVersion)</InformationalVersion>
<NoWarn>$(NoWarn),0419,0649</NoWarn>

<!-- Disable nullability-related warnings -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<CompilerVisibleProperty Include="ProductVersion" />
</ItemGroup>

<!-- Setup eventing file generation -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ public partial class ProductVersionInfoGenerator : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
context.RegisterPostInitializationOutput(ctx =>
{
string? informationalVersion = typeof(ProductVersionInfoGenerator).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;

// strip semver metadata (git hash) followed by + sign
string? productVersion = informationalVersion?.Split('+')?[0];
var productVersionProvider = context.AnalyzerConfigOptionsProvider.Select((options, _) =>
options.GlobalOptions.TryGetValue("build_property.ProductVersion", out string? ver) ? ver : null);

context.RegisterSourceOutput(productVersionProvider, (ctx, productVersion) =>
{
if (string.IsNullOrEmpty(productVersion))
throw new InvalidOperationException($"Unable to obtain product version at build-time.");

// strip semver prerelease label followed by - sign for Environment.Version
Version versionObject = Version.Parse(productVersion.Split('-')[0]);
Version versionObject = Version.Parse(productVersion);

ctx.AddSource("ProductVersionInfo.g.cs", $@"// <auto-generated/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,10 @@ public void VerifyFrameworkDescriptionContainsCorrectVersion()
return;

Assert.DoesNotContain("+", version); // no git hash
Assert.DoesNotContain("-", version); // no preview suffix
akoeplinger marked this conversation as resolved.
Show resolved Hide resolved

#if STABILIZE_PACKAGE_VERSION
// a stabilized version looks like 8.0.0
Assert.DoesNotContain("-", version);
Assert.True(Version.TryParse(version, out Version _));
#else
// a non-stabilized version looks like 8.0.0-preview.5.23280.8 or 8.0.0-dev
Assert.Contains("-", version);
var versionNumber = version.Substring(0, version.IndexOf("-"));
Assert.True(Version.TryParse(versionNumber, out Version _));
#endif
Assert.True(Version.TryParse(version, out Version ver));
Assert.Equal(Environment.Version, ver);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-unix;$(NetCoreAppCurrent)-browser</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(StabilizePackageVersion)' == 'true'">$(DefineConstants);STABILIZE_PACKAGE_VERSION</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CheckArchitectureTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
<!-- These prevent the default MsBuild targets from referencing System.dll and mscorlib.dll -->
<ExcludeMscorlibFacade>true</ExcludeMscorlibFacade>
<RuntimeMetadataVersion>v4.0.30319</RuntimeMetadataVersion>
<!-- Override InformationalVersion during servicing as it's returned via public api. -->
<InformationalVersion Condition="'$(PreReleaseVersionLabel)' == 'servicing'">$(ProductVersion)</InformationalVersion>
<InformationalVersion Condition="'$(StabilizePackageVersion)' == 'true'">$(ProductVersion)</InformationalVersion>
<NoWarn>$(NoWarn),0419,0649</NoWarn>
<Nullable>enable</Nullable>

Expand Down Expand Up @@ -301,6 +298,7 @@

<ItemGroup>
<ProjectReference Include="$(LibrariesProjectRoot)\System.Private.CoreLib\gen\System.Private.CoreLib.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<CompilerVisibleProperty Include="ProductVersion" />
</ItemGroup>

<Target Name="CopyCoreLibToBinDir" AfterTargets="Build">
Expand Down
Loading