Skip to content

Commit

Permalink
Fixes Issue #4705 - Wrong version numbers in dlls (#4706)
Browse files Browse the repository at this point in the history
* Fixes Issue #4705

* Delete src/src.sln

* Changed to using conditionals in the directory.build.props and adjusted csprojs and assemblyinfo.cs files accordingly.

* Adding caketest

* Update src/NUnitFramework/framework/nunit.framework.csproj

Co-authored-by: Manfred Brands <manfred-brands@users.noreply.github.com>

* Update src/NUnitFramework/nunit.framework.legacy/nunit.framework.legacy.csproj

Co-authored-by: Manfred Brands <manfred-brands@users.noreply.github.com>

* Update src/NUnitFramework/nunitlite/nunitlite.csproj

Co-authored-by: Manfred Brands <manfred-brands@users.noreply.github.com>

* updated files and directory.build.props

* commented out Choose, didnt work, in directory.build.props

* Updated some tests, fixing nullrefs

* reverted formatting

* fix compiler warnings/errors

* updated cake

* Raise Error when compiling for a TargetFramework with no AssemblyConfiguration

.NET 7.0 is out of support as of May 14th 2024.

* Fixed null suppressions

* Moved cake scripts to its own project and loaded the code into the build.cake

* Fix null

* Fix more minor stuff

* Fix SA warnings

* Using same file and assembly version numbers, same as we have done earlier

* Final review changes

* Fetch tags in CI

* Updated to cake 4. Get a warnign about other cake tools like minver, raised a PR there too, but the warning can be safely ignored for now

* Now we can use AsSpan in CakeScript

---------

Co-authored-by: Manfred Brands <manfred-brands@users.noreply.github.com>
  • Loading branch information
OsirisTerje and manfred-brands committed May 26, 2024
1 parent 376b434 commit 2d20f5d
Show file tree
Hide file tree
Showing 33 changed files with 316 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.2.0",
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/NUnit.CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
steps:
- name: ⤵️ Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🛠️ Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -60,6 +62,8 @@ jobs:
steps:
- name: ⤵️ Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🛠️ Setup .NET
uses: actions/setup-dotnet@v4
Expand Down Expand Up @@ -90,6 +94,8 @@ jobs:
steps:
- name: ⤵️ Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🛠️ Setup .NET
uses: actions/setup-dotnet@v4
Expand Down
25 changes: 25 additions & 0 deletions CakeScripts.Tests/CakeScripts.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CakeScripts\CakeScripts.csproj" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions CakeScripts.Tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

global using NUnit.Framework;
14 changes: 14 additions & 0 deletions CakeScripts.Tests/VersionParsersTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

namespace CakeScripts.Tests;

public class CakeTests
{
[TestCase("1.2.3-beta.1", "1.2.3.0")]
[TestCase("1.2.3", "1.2.3.0")]
public void ThatWeCanParseAssemblyVersionStrings(string versionString, string expected)
{
var parsedVersion = VersionParsers.ParseAssemblyVersion(versionString);
Assert.That(parsedVersion, Is.EqualTo(expected));
}
}
9 changes: 9 additions & 0 deletions CakeScripts/CakeScripts.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
14 changes: 14 additions & 0 deletions CakeScripts/VersionParsers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

public static class VersionParsers
{
public static string ParseAssemblyVersion(string version)
{
var dash = version.LastIndexOf('-');
if (dash > 0)
{
return string.Concat(version.AsSpan(0, dash), ".0");
}
return version + ".0";
}
}
25 changes: 19 additions & 6 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#addin "nuget:?package=Cake.MinVer&version=3.0.0"
#load "CakeScripts/VersionParsers.cs"

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand Down Expand Up @@ -128,17 +129,29 @@ Task("Build")
DotNetBuild(SOLUTION_FILE, CreateDotNetBuildSettings());
});

DotNetBuildSettings CreateDotNetBuildSettings() =>
new DotNetBuildSettings
DotNetBuildSettings CreateDotNetBuildSettings()
{
var version = packageVersion.ToString();
var assemblyVersion = VersionParsers.ParseAssemblyVersion(version);
var msBuildSettings = new DotNetMSBuildSettings {
ContinuousIntegrationBuild = BuildSystem.GitHubActions.IsRunningOnGitHubActions,
AssemblyVersion = assemblyVersion,
FileVersion = assemblyVersion,
InformationalVersion = version
};
Information("AssemblyVersion: {0}", msBuildSettings.AssemblyVersion);
Information("FileVersion: {0}", msBuildSettings.FileVersion);
Information("InformationalVersion: {0}", msBuildSettings.InformationalVersion);

var settings = new DotNetBuildSettings
{
Configuration = configuration,
NoRestore = true,
Verbosity = DotNetVerbosity.Minimal,
MSBuildSettings = new DotNetMSBuildSettings {
Version = packageVersion,
ContinuousIntegrationBuild = BuildSystem.GitHubActions.IsRunningOnGitHubActions
}
MSBuildSettings = msBuildSettings
};
return settings;
}

//////////////////////////////////////////////////////////////////////
// TEST
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"version": "8.0.100",
"allowPrerelease": false,
"rollForward": "latestPatch"
"rollForward": "latestFeature"
}
}
14 changes: 13 additions & 1 deletion nunit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{AA24
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{8C31C709-FAC1-445C-BAD6-7FFFB3F1D39E}"
ProjectSection(SolutionItems) = preProject
.github\workflows\NUnit.Myget.Publish.yml = .github\workflows\NUnit.Myget.Publish.yml
.github\workflows\NUnit.CI.yml = .github\workflows\NUnit.CI.yml
.github\workflows\NUnit.Myget.Publish.yml = .github\workflows\NUnit.Myget.Publish.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{08744334-2350-4885-B57E-347010A27ABB}"
Expand All @@ -80,6 +80,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{0874
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "windows-tests", "src\NUnitFramework\windows-tests\windows-tests.csproj", "{7C19F745-B5F0-4A3A-B545-1E1DF4FA1F78}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CakeScripts", "CakeScripts\CakeScripts.csproj", "{8A7B6926-0FDF-4AC7-9E78-BBAC01187414}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CakeScripts.Tests", "CakeScripts.Tests\CakeScripts.Tests.csproj", "{FCF45E25-C1CB-42E8-8E83-F7FCB818E8D3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -138,6 +142,14 @@ Global
{7C19F745-B5F0-4A3A-B545-1E1DF4FA1F78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C19F745-B5F0-4A3A-B545-1E1DF4FA1F78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C19F745-B5F0-4A3A-B545-1E1DF4FA1F78}.Release|Any CPU.Build.0 = Release|Any CPU
{8A7B6926-0FDF-4AC7-9E78-BBAC01187414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8A7B6926-0FDF-4AC7-9E78-BBAC01187414}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A7B6926-0FDF-4AC7-9E78-BBAC01187414}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A7B6926-0FDF-4AC7-9E78-BBAC01187414}.Release|Any CPU.Build.0 = Release|Any CPU
{FCF45E25-C1CB-42E8-8E83-F7FCB818E8D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCF45E25-C1CB-42E8-8E83-F7FCB818E8D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCF45E25-C1CB-42E8-8E83-F7FCB818E8D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCF45E25-C1CB-42E8-8E83-F7FCB818E8D3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
33 changes: 0 additions & 33 deletions src/CommonAssemblyInfo.cs

This file was deleted.

38 changes: 37 additions & 1 deletion src/NUnitFramework/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<NUnitLibraryFrameworks>net462;net6.0</NUnitLibraryFrameworks>
<NUnitRuntimeFrameworks>net462;net6.0;net8.0</NUnitRuntimeFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<!--<OutputPath>..\..\..\bin\$(Configuration)\</OutputPath>-->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<Nullable>enable</Nullable>
<AnnotatedReferenceAssemblyVersion>7.0.0</AnnotatedReferenceAssemblyVersion>
<GenerateNullableAttributes>false</GenerateNullableAttributes>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Company>NUnit Software</Company>
<Product>NUnit 4</Product>
<Copyright>Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt</Copyright>
<Trademark>NUnit is a trademark of NUnit Software</Trademark>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
Expand All @@ -35,6 +39,38 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'net462'">
<PropertyGroup>
<AssemblyConfiguration>.NET Framework 4.6.2 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net6.0'))">
<PropertyGroup>
<AssemblyConfiguration>.NET 6.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net8.0'))">
<PropertyGroup>
<AssemblyConfiguration>.NET 8.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>
</When>
<When Condition="$(TargetFramework.StartsWith('net9.0'))">
<PropertyGroup>
<AssemblyConfiguration>.NET 9.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<AssemblyConfiguration />
</PropertyGroup>
</Otherwise>
</Choose>

<Target Name="CheckConfiguration" BeforeTargets="Compile">
<Error Condition="'$(AssemblyConfiguration)' == ''" Text="Missing AssemblyConfiguration for $(TargetFramework)" />
</Target>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" PrivateAssets="all" />
Expand Down
9 changes: 0 additions & 9 deletions src/NUnitFramework/FrameworkVersion.cs

This file was deleted.

Loading

0 comments on commit 2d20f5d

Please sign in to comment.