forked from cake-build/cake
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(cake-buildGH-2063) Adds netstandard2 integration tests.
- Adds integration test for loading netstandard2 addin.
- Loading branch information
1 parent
0d5623e
commit d82d177
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Task("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin") | ||
.Does(() => | ||
{ | ||
DotNetCorePack($"{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj", | ||
new DotNetCorePackSettings { | ||
Configuration = "Release" | ||
}); | ||
|
||
var script = $@"#addin nuget:{Paths.Resources}/Cake.Core/Scripting/netstandard2.addin/bin/Release?package=netstandard2.addin&version=1.0.0 | ||
Information(""Magic number: {0}"", GetMagicNumber(false)); | ||
Information(""The answer to life: {0}"", TheAnswerToLife); | ||
"; | ||
|
||
CakeExecuteExpression(script); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Cake.Core.Scripting.AddinDirective") | ||
.IsDependentOn("Cake.Core.Scripting.AddinDirective.LoadNetStandardAddin"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/MyCakeExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using Cake.Core; | ||
using Cake.Core.Annotations; | ||
|
||
public static class MyCakeExtension | ||
{ | ||
[CakeMethodAlias] | ||
public static int GetMagicNumber(this ICakeContext context, bool value) | ||
{ | ||
return value ? int.MinValue : int.MaxValue; | ||
} | ||
|
||
[CakeMethodAlias] | ||
public static int GetMagicNumberOrDefault(this ICakeContext context, bool value, Func<int> defaultValueProvider = null) | ||
{ | ||
if (value) | ||
{ | ||
return int.MinValue; | ||
} | ||
|
||
return defaultValueProvider == null ? int.MaxValue : defaultValueProvider(); | ||
} | ||
|
||
[CakePropertyAlias] | ||
public static int TheAnswerToLife(this ICakeContext context) | ||
{ | ||
return 42; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/integration/resources/Cake.Core/Scripting/netstandard2.addin/netstandard2.addin.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Cake.Core" Version="0.26.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |