Skip to content

Commit

Permalink
Changed to using conditionals in the directory.build.props and adjust…
Browse files Browse the repository at this point in the history
…ed csprojs and assemblyinfo.cs files accordingly.
  • Loading branch information
OsirisTerje committed May 10, 2024
1 parent c0e3970 commit 54a699d
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 310 deletions.
40 changes: 6 additions & 34 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -116,55 +116,27 @@ Task("NuGetRestore")
DotNetRestore(SOLUTION_FILE);
});

//////////////////////////////////////////////////////////////////////
// Generate AssemblyInfo
//////////////////////////////////////////////////////////////////////

Task("Generate-AssemblyInfo")
.Description("Generates the AssemblyInfo file")
.Does(() =>
{
var version = packageVersion.ToString();
var assemblyVersion = version.Substring(0, version.LastIndexOf('-')) + ".0";
Information("Assembly Version: " + assemblyVersion);
Information("Package Version: " + packageVersion);
var assemblyInfoContents = $@"
// Generated by Cake
using System.Reflection;
[assembly: System.Reflection.AssemblyVersion(""{assemblyVersion}"")]
[assembly: System.Reflection.AssemblyFileVersion(""{assemblyVersion}"")]
[assembly: System.Reflection.AssemblyInformationalVersion(""{version}"")]
";
var filePath = "./src/AssemblyInfo.g.cs";
EnsureDirectoryExists("./src");
System.IO.File.WriteAllText(filePath, assemblyInfoContents, Encoding.UTF8);
Information($"Generated assembly info at {filePath}");
});



//////////////////////////////////////////////////////////////////////
// BUILD FRAMEWORKS
//////////////////////////////////////////////////////////////////////

Task("Build")
.Description("Builds the Solution")
.IsDependentOn("NuGetRestore")
.IsDependentOn("Generate-AssemblyInfo")
.Does(() =>
{
DotNetBuild(SOLUTION_FILE, CreateDotNetBuildSettings());
});

DotNetBuildSettings CreateDotNetBuildSettings()
{

var version = packageVersion.ToString();
var assemblyVersion = version.Substring(0, version.LastIndexOf('-')) + ".0";
var msBuildSettings = new DotNetMSBuildSettings {
ContinuousIntegrationBuild = BuildSystem.GitHubActions.IsRunningOnGitHubActions
ContinuousIntegrationBuild = BuildSystem.GitHubActions.IsRunningOnGitHubActions,
AssemblyVersion = assemblyVersion,
FileVersion = assemblyVersion,
InformationalVersion = version
};

var settings = new DotNetBuildSettings
Expand Down
8 changes: 0 additions & 8 deletions src/AssemblyInfo.g.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/CommonAssemblyInfo.cs

This file was deleted.

41 changes: 40 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,41 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<!-- .NET Core 3.1 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<AssemblyConfiguration>.NET Core 3.1 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET Framework 4.6.2 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<AssemblyConfiguration>.NET Framework 4.6.2 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET 5.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<AssemblyConfiguration>.NET 5.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET 6.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<AssemblyConfiguration>.NET 6.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET 7.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0'">
<AssemblyConfiguration>.NET 7.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET 8.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
<AssemblyConfiguration>.NET 8.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<!-- .NET 9.0 -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net9.0'">
<AssemblyConfiguration>.NET 9.0 $(Configuration)</AssemblyConfiguration>
</PropertyGroup>

<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.

11 changes: 0 additions & 11 deletions src/NUnitFramework/framework/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("nunit.framework.tests, PublicKey=002400000480000094" +
Expand Down Expand Up @@ -36,14 +35,4 @@
"bee5e972a004ddd692dec8fa404ba4591e847a8cf35de21c2d3" +
"723bc8d775a66b594adeb967537729fe2a446b548cd57a6")]

#if NET462
[assembly: AssemblyTitle("NUnit Framework (.NET Framework 4.6.2)")]
#elif NET6_0
[assembly: AssemblyTitle("NUnit Framework (.NET 6.0)")]
#else
#error Missing AssemblyTitle attribute for this target.
#endif

[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
18 changes: 7 additions & 11 deletions src/NUnitFramework/framework/nunit.framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsTestProject>false</IsTestProject>
</PropertyGroup>


<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<Title>NUnit Framework (.NET Framework 4.6.2)</Title>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<Title>NUnit Framework (.NET 6.0)</Title>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="System.Threading.Tasks.Extensions" />
Expand All @@ -17,16 +23,6 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
<Compile Include="..\FrameworkVersion.cs" Link="Properties\FrameworkVersion.cs" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\AssemblyInfo.g.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Memory" />
</ItemGroup>
Expand Down
10 changes: 0 additions & 10 deletions src/NUnitFramework/mock-assembly/Properties/AssemblyInfo.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/NUnitFramework/mock-assembly/mock-assembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<IsTestProject>false</IsTestProject>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
<Title>mock-assembly</Title>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System;
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("nunit.framework.tests, PublicKey=002400000480000094" +
Expand Down Expand Up @@ -36,14 +35,4 @@
"bee5e972a004ddd692dec8fa404ba4591e847a8cf35de21c2d3" +
"723bc8d775a66b594adeb967537729fe2a446b548cd57a6")]

#if NET462
[assembly: AssemblyTitle("NUnit Framework Classic (.NET Framework 4.6.2)")]
#elif NET6_0
[assembly: AssemblyTitle("NUnit Framework Classic (.NET 6.0)")]
#else
#error Missing AssemblyTitle attribute for this target.
#endif

[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
<Compile Include="..\FrameworkVersion.cs" Link="Properties\FrameworkVersion.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\framework\nunit.framework.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\AssemblyInfo.g.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<Title>NUnit Framework Classic (.NET Framework 4.6.2)</Title>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<Title>NUnit Framework Classic (.NET 6.0)</Title>
</PropertyGroup>


</Project>

This file was deleted.

6 changes: 1 addition & 5 deletions src/NUnitFramework/nunitlite-runner/nunitlite-runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
<RootNamespace>NUnitLite</RootNamespace>
<TargetFrameworks>$(NUnitRuntimeFrameworks)</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Title>NUnit Test Runner</Title>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
<Compile Include="..\FrameworkVersion.cs" Link="Properties\FrameworkVersion.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\framework\nunit.framework.csproj" />
<ProjectReference Include="..\nunitlite\nunitlite.csproj" />
Expand Down
6 changes: 0 additions & 6 deletions src/NUnitFramework/nunitlite.tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System.Reflection;
using NUnit.Framework;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("NUnitLite Runner Tests")]

[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]

[assembly: Parallelizable(ParallelScope.Fixtures)]
1 change: 1 addition & 0 deletions src/NUnitFramework/nunitlite.tests/nunitlite.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Nullable>disable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
<Title>NUnitLite Runner Tests</Title>
</PropertyGroup>

<ItemGroup>
Expand Down
11 changes: 0 additions & 11 deletions src/NUnitFramework/nunitlite/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("nunitlite.tests, PublicKey=002400000480000094" +
Expand All @@ -10,13 +9,3 @@
"80799d6eeef61c98abd18767827dc05daea6b6fbd2e868410d9" +
"bee5e972a004ddd692dec8fa404ba4591e847a8cf35de21c2d3" +
"723bc8d775a66b594adeb967537729fe2a446b548cd57a6")]

#if NET462
[assembly: AssemblyTitle("NUnitLite Runner (.NET Framework 4.6.2)")]
#elif NET6_0
[assembly: AssemblyTitle("NUnitLite Runner (.NET 6.0)")]
#else
#error Missing AssemblyTitle attribute for this target.
#endif

[assembly: AssemblyDescription("")]
17 changes: 8 additions & 9 deletions src/NUnitFramework/nunitlite/nunitlite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\framework\nunit.framework.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\CommonAssemblyInfo.cs" Link="Properties\CommonAssemblyInfo.cs" />
<Compile Include="..\FrameworkVersion.cs" Link="Properties\FrameworkVersion.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<Title>NUnitLite Runner (.NET Framework 4.6.2)</Title>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<Title>NUnitLite Runner (.NET 6.0)</Title>
</PropertyGroup>


<ItemGroup>
<Compile Include="..\..\AssemblyInfo.g.cs" />
<ProjectReference Include="..\framework\nunit.framework.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 54a699d

Please sign in to comment.