Skip to content

Commit

Permalink
Add new net48 build target (#776)
Browse files Browse the repository at this point in the history
* Add new net48 build target

* Fix tests and add new ones for .net48

* Add net48 test reports to github action

* Add net48 target for tests

* Add reference to System.Net.Http

---------

Co-authored-by: Alastair Pitts <[email protected]>
  • Loading branch information
scme0 and APErebus authored Oct 9, 2023
1 parent 7e654ea commit 632796a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 19 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ jobs:
path: ./TestResults/Win_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .Net 4.8 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows.Net 4.8 unit test results
path: ./TestResults/Win_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .Net 6.0 unit test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
Expand All @@ -74,6 +82,14 @@ jobs:
path: ./TestResults/Win-E2E_net462_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .Net 4.8 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
with:
name: Windows .Net 4.8 E2E test results
path: ./TestResults/Win-E2E_net48_*.trx
reporter: dotnet-trx
fail-on-error: true
- name: Windows .Net 6.0 E2E test report
uses: dorny/test-reporter@v1
if: success() || failure() # run this step even if previous step failed
Expand Down
8 changes: 4 additions & 4 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Build : NukeBuild
.DependsOn(Compile)
.Executes(() =>
{
foreach (var target in new[] {"net462", "netstandard2.0"})
foreach (var target in new[] {"net462", "net48","netstandard2.0"})
{
var inputFolder = OctopusClientFolder / "bin" / Configuration / target;
var outputFolder = OctopusClientFolder / "bin" / Configuration / $"{target}Merged";
Expand Down Expand Up @@ -230,12 +230,12 @@ class Build : NukeBuild
.Executes(() =>
{
EnsureCleanDirectory(RootDirectory / "TestResults");

DockerComposeBuild(RootDirectory / "docker-compose.build.yml", "--no-cache");
DockerComposeUp(RootDirectory / "docker-compose.test.yml");
DockerComposeDown(RootDirectory / "docker-compose.test.yml");

var unitTestResultFiles = Directory.GetFiles(RootDirectory / "TestResults", "*.trx");
var unitTestResultFiles = Directory.GetFiles(RootDirectory / "TestResults", "*.trx");

Assert.Count(unitTestResultFiles, 11, "Incorrect number of results files found");
});
Expand Down Expand Up @@ -309,7 +309,7 @@ void SignBinaries(AbsolutePath path)

Log.Information($"Finished signing {files.Length} files.");
}

void SignWithAzureSignTool(AbsolutePath[] files, string timestampUrl)
{
Log.Information("Signing files using azuresigntool and the production code signing certificate.");
Expand Down
31 changes: 26 additions & 5 deletions source/Octopus.Client.E2ETests/NuSpecDependenciesFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void NuSpecFileShouldHaveADependencyNode()
public void NuSpecFileShouldHaveADependencyGroupForEachTargetFramework()
{
var dependencyGroups = nuSpecFile.SelectNodes("//ns:package/ns:metadata/ns:dependencies/ns:group", nameSpaceManager);
dependencyGroups.Count.Should().Be(2, "Should have 2 dependency groups");
dependencyGroups.Count.Should().Be(3, "Should have 3 dependency groups");
}

public static TestCaseData[] DependencyExpectations =
Expand Down Expand Up @@ -156,30 +156,51 @@ public void NuSpecFileShouldHaveAFrameworkAssembliesNode()
public void NuSpecFileShouldOnlyHaveFrameworkAssembliesForNetFramework()
{
var dependencies = nuSpecFile.SelectNodes(
"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework != '.NETFramework4.6.2']",
"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework != '.NETFramework4.6.2' and @targetFramework != '.NETFramework4.8']",
nameSpaceManager);
dependencies.Count.Should().Be(0, "There should be only be frameworkAssemblies listed for .NETFramework4.6.2");
dependencies.Count.Should().Be(0, "There should be only be frameworkAssemblies listed for .NETFramework4.6.2 and .NETFramework4.8");
}

[Test]
public void NuSpecFileShouldHave3FrameworkAssembliesForNetFramework()
public void NuSpecFileShouldHave3FrameworkAssembliesForNetFramework462()
{
var dependencies = nuSpecFile.SelectNodes(
"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework = '.NETFramework4.6.2']",
nameSpaceManager);
dependencies.Count.Should().Be(3, "There should be 3 frameworkAssemblies listed for .NETFramework4.6.2");
}

[Test]
public void NuSpecFileShouldHave3FrameworkAssembliesForNetFramework48()
{
var dependencies = nuSpecFile.SelectNodes(
"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework = '.NETFramework4.8']",
nameSpaceManager);
dependencies.Count.Should().Be(3, "There should be 3 frameworkAssemblies listed for .NETFramework4.8");
}

[Test]
[TestCase("System.ComponentModel.DataAnnotations")]
[TestCase("System.Net.Http")]
[TestCase("System.Numerics")]
public void NuSpecFileShouldHaveSystemComponentModelDataAnnotationsFrameworkAssemblyForNetFramework(string assemblyName)
public void NuSpecFileShouldHaveSystemComponentModelDataAnnotationsFrameworkAssemblyForNetFramework462(string assemblyName)
{
var frameworkAssembly = nuSpecFile.SelectSingleNode(
$"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework = '.NETFramework4.6.2' and @assemblyName = '{assemblyName}']",
nameSpaceManager);
frameworkAssembly.Should().NotBeNull($"Should have a frameworkAssembly node for '{assemblyName}' for .NETFramework4.6.2");
}

[Test]
[TestCase("System.ComponentModel.DataAnnotations")]
[TestCase("System.Net.Http")]
[TestCase("System.Numerics")]
public void NuSpecFileShouldHaveSystemComponentModelDataAnnotationsFrameworkAssemblyForNetFramework48(string assemblyName)
{
var frameworkAssembly = nuSpecFile.SelectSingleNode(
$"//ns:package/ns:metadata/ns:frameworkAssemblies/ns:frameworkAssembly[@targetFramework = '.NETFramework4.8' and @assemblyName = '{assemblyName}']",
nameSpaceManager);
frameworkAssembly.Should().NotBeNull($"Should have a frameworkAssembly node for '{assemblyName}' for .NETFramework4.8");
}
}
}
5 changes: 3 additions & 2 deletions source/Octopus.Client.E2ETests/Octopus.Client.E2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="!$([MSBuild]::IsOSUnixLike())">
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net48;net6.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSUnixLike())">
<TargetFrameworks>net6.0</TargetFrameworks>
Expand All @@ -34,7 +34,8 @@
</ItemGroup>

<ItemGroup>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
</ItemGroup>

</Project>
8 changes: 4 additions & 4 deletions source/Octopus.Client.Tests/Octopus.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="!$([MSBuild]::IsOSUnixLike())">
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net462;net48;net6.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSUnixLike())">
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net48' ">
<RuntimeIdentifier>win7-x86</RuntimeIdentifier> <!-- So that libuv is copied correctly -->
<BaseNuGetRuntimeIdentifier>win7-x86</BaseNuGetRuntimeIdentifier> <!-- So that libuv is copied correctly -->
</PropertyGroup>
Expand Down Expand Up @@ -47,19 +47,19 @@
<PackageReference Include="Nancy" Version="2.0.0" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="Serilog" Version="2.3.0" />

<PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net48' ">
<PackageReference Include="Libuv" Version="1.10.0" />
<PackageReference Include="Best.Conventional" Version="1.3.0.122" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
Expand Down
2 changes: 1 addition & 1 deletion source/Octopus.Client/Octopus.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</PropertyGroup>

<PropertyGroup Condition="!$([MSBuild]::IsOSUnixLike())">
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;net48;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsOSUnixLike())">
Expand Down
8 changes: 8 additions & 0 deletions source/Octopus.Client/Octopus.Client.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<dependencies>
<group targetFramework=".NETFramework4.6.2">
</group>
<group targetFramework=".NETFramework4.8">
</group>

<group targetFramework=".NETStandard2.0">
<dependency id="Microsoft.CSharp" version="4.7.0" exclude="Build,Analyzers" />
Expand All @@ -27,12 +29,18 @@
<frameworkAssembly assemblyName="System.ComponentModel.DataAnnotations" targetFramework=".NETFramework4.6.2" />
<frameworkAssembly assemblyName="System.Net.Http" targetFramework=".NETFramework4.6.2" />
<frameworkAssembly assemblyName="System.Numerics" targetFramework=".NETFramework4.6.2" />

<frameworkAssembly assemblyName="System.ComponentModel.DataAnnotations" targetFramework=".NETFramework4.8" />
<frameworkAssembly assemblyName="System.Net.Http" targetFramework=".NETFramework4.8" />
<frameworkAssembly assemblyName="System.Numerics" targetFramework=".NETFramework4.8" />
</frameworkAssemblies>
</metadata>
<files>
<file src="icon.png" target="images\" />
<file src="bin\release\net462\Octopus.Client.dll" target="lib\net462" />
<file src="bin\release\net462\Octopus.Client.xml" target="lib\net462" />
<file src="bin\release\net48\Octopus.Client.dll" target="lib\net48" />
<file src="bin\release\net48\Octopus.Client.xml" target="lib\net48" />
<file src="bin\release\netstandard2.0\Octopus.Client.dll" target="lib\netstandard2.0" />
<file src="bin\release\netstandard2.0\Octopus.Client.xml" target="lib\netstandard2.0" />
</files>
Expand Down
6 changes: 3 additions & 3 deletions source/Octopus.Server.Client/Octopus.Server.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ This package contains the non-ILmerged client library for the HTTP API in Octopu
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="!$([MSBuild]::IsOSUnixLike())">
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;net48;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSUnixLike())">
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net48' ">
<DebugType>embedded</DebugType>
<DefineConstants>$(DefineConstants);FULL_FRAMEWORK</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);HTTP_CLIENT_SUPPORTS_SSL_OPTIONS;LIBLOG_PORTABLE</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'net48' ">
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Numerics" />
<Reference Include="System.Net.Http" />
Expand Down

0 comments on commit 632796a

Please sign in to comment.