Skip to content

Commit

Permalink
(cake-archiveGH-80) Trying to add back in net461
Browse files Browse the repository at this point in the history
Based on some suggestions from @devlead, tried to run unit tests for
each project, as well as providing a FrameworkOverride path to use Mono.

Neither of these seem to work, but wanted to put the work up for folks
to take a look at.
  • Loading branch information
gep13 committed Jun 28, 2020
1 parent 9140b77 commit 013671b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
3 changes: 0 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ fi

echo "Running build script.."
pushd .
echo "Changing to build folder..."
cd build
echo "dotnet run..."
dotnet run --project Build.csproj -- "$@"
echo "going back to previous folder..."
popd
19 changes: 19 additions & 0 deletions build/Lifetime.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using Cake.Common;
using Cake.Common.Diagnostics;
using Cake.Common.Build;
Expand Down Expand Up @@ -49,6 +50,24 @@ public override void Setup(Context context)
.WithProperty("AssemblyVersion", context.Version.Version)
.WithProperty("FileVersion", context.Version.Version);

if(!context.IsRunningOnWindows())
{
var frameworkPathOverride = context.Environment.Runtime.IsCoreClr
? new []{
new DirectoryPath("/Library/Frameworks/Mono.framework/Versions/Current/lib/mono"),
new DirectoryPath("/usr/lib/mono"),
new DirectoryPath("/usr/local/lib/mono")
}
.Select(directory =>directory.Combine("4.5"))
.FirstOrDefault(directory => context.FileSystem.Exist(directory))
?.FullPath + "/"
: new FilePath(typeof(object).Assembly.Location).GetDirectory().FullPath + "/";

// Use FrameworkPathOverride when not running on Windows.
context.Information("Build will use FrameworkPathOverride={0} since not building on Windows.", frameworkPathOverride);
context.MSBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
}

context.Information("Version: {0}", context.Version);
context.Information("Sem version: {0}", context.Version.SemVersion);
context.Information("Configuration: {0}", context.BuildConfiguration);
Expand Down
18 changes: 12 additions & 6 deletions build/Tasks/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ public class UnitTests : FrostingTask<Context>
{
public override void Run(Context context)
{
var project = "./src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj";
context.DotNetCoreTest(project, new DotNetCoreTestSettings {
Configuration = context.BuildConfiguration,
NoBuild = true
});
foreach(var framework in new[] { "netcoreapp2.0", "netcoreapp3.0", "net461" })
{
var project = "./src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj";

context.DotNetCoreTest(project, new DotNetCoreTestSettings {
Framework = framework,
Configuration = context.BuildConfiguration,
NoBuild = true,
NoRestore = true
});
}
}
}
}
2 changes: 1 addition & 1 deletion src/Cake.Frosting.Example/Cake.Frosting.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/cake-build/frosting</RepositoryUrl>
<VersionPrefix>0.1.0</VersionPrefix>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<AssemblyName>Cake.Frosting.Example</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Cake.Frosting.Example</PackageId>
Expand Down
12 changes: 9 additions & 3 deletions src/Cake.Frosting.Tests/Cake.Frosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageLicenseUrl>https://github.com/cake-build/frosting/blob/develop/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/cake-build/frosting</RepositoryUrl>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<LangVersion>7</LangVersion>
</PropertyGroup>

Expand All @@ -22,12 +22,18 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="Cake.Testing" Version="0.38.4" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<!-- .NET Framework packages -->
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.IO.Compression" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Frosting/Cake.Frosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/cake-build/frosting</RepositoryUrl>
<VersionPrefix>0.1.0</VersionPrefix>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Cake.Frosting</AssemblyName>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
Expand Down

0 comments on commit 013671b

Please sign in to comment.