Skip to content

Commit

Permalink
updates examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mzorec committed Nov 27, 2019
1 parent 9b2aea5 commit 8d19dc7
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ NetCoreOpenSource/NetCoreOpenSource/obj/
NetCoreOpenSource/NetCoreOpenSource/.idea/
NetCoreOpenSource/NetCoreOpenSource/bin/
NetCoreOpenSource/bin/
ArgumentAndConfigurationPassThroughToTasksExample/.vs/
NetCore_csproj/FlubuExample2.Tests/bin/
NetCore_csproj/FlubuExample2.Tests/obj/
NetCoreOpenSource/.vs/NetCoreOpenSource/v16/
NetCoreOpenSource/Build/bin/
NetCoreOpenSource/.vs/
MVC_NET4.61/UpgradeLog2.htm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

/// <summary>
/// Flubu loads Newtonsoft.json and FlubuCore.PluginExample assembly from FlubuLib directory
/// If you dont put them into FlubuLib directory you can also refernce them with #ass or #nuget directive. See wiki - BuildScript fundamentals for more information.
/// </summary>
public class BuildScript : DefaultBuildScript
{
Expand All @@ -30,7 +29,6 @@ protected override void ConfigureTargets(ITaskContext context)

private void DoPluginExample(ITaskContext context)
{
//// just example that JsonConver works(Newtonsoft.json assembly got loaded from FlubuLib directory)
JsonConvert.SerializeObject("test");

//// Execution of custom written flubu task in FlubuCore.PluginExample assembly.
Expand Down
2 changes: 1 addition & 1 deletion NetCoreOpenSource/Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FlubuCore" Version="4.2.8" />
<PackageReference Include="FlubuCore" Version="4.3.3" />

</ItemGroup>
</Project>
11 changes: 5 additions & 6 deletions NetCoreOpenSource/Build/BuildScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override void ConfigureTargets(ITaskContext context)
var clean = context.CreateTarget("Clean")
.SetDescription("Clean's the solution.")
.AddCoreTask(x => x.Clean()
.AddDirectoryToClean("output", true));
.AddDirectoryToClean(OutputDirectory, true));

var restore = context.CreateTarget("Restore")
.SetDescription("Restore's nuget packages in all projects.")
Expand Down Expand Up @@ -58,21 +58,20 @@ protected override void ConfigureTargets(ITaskContext context)
.AddCoreTask(x => x.Test()
.Project("NetCoreOpenSource.Tests")
.NoBuild());

var outputDir = context.Properties.GetOutputDir();

var pack = context.CreateTarget("Pack")
.SetDescription("Prepare's nuget package.")
.AddCoreTask(x => x.Pack()
.NoBuild()
.OutputDirectory(outputDir));
.OutputDirectory(OutputDirectory));

var branch = context.BuildSystems().Travis().Branch;

//// Examine travis.yaml to see how to pass api key from travis to FlubuCore build script.
var nugetPush = context.CreateTarget("Nuget.publish")
.SetDescription("Publishes nuget package.")
.DependsOn(pack)
.AddCoreTask(x => x.NugetPush($"{outputDir}/NetCoreOpenSource.nupkg")
.AddCoreTask(x => x.NugetPush($"{OutputDirectory}/NetCoreOpenSource.nupkg")
.ApiKey(NugetApiKey)
)
.When((c) => c.BuildSystems().RunningOn == BuildSystemType.TravisCI
Expand Down
7 changes: 5 additions & 2 deletions NetCore_csproj/BuildScript.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<Compile Remove="BuildScript\obj\**" />
<Compile Remove="FlubuExample.Tests2\**" />
<Compile Remove="FlubuExample.Tests\**" />
<Compile Remove="FlubuExample2.Tests\**" />
<Compile Remove="FlubuExample\**" />
<Compile Remove="Packages\**" />
<EmbeddedResource Remove="bin\**" />
<EmbeddedResource Remove="FlubuExample2.Tests\**" />
<EmbeddedResource Remove="obj\**" />
<EmbeddedResource Remove="BuildScript\bin\**" />
<EmbeddedResource Remove="BuildScript\obj\**" />
Expand All @@ -20,6 +22,7 @@
<None Remove="BuildScript\bin\**" />
<None Remove="BuildScript\obj\**" />
<None Remove="bin\**" />
<None Remove="FlubuExample2.Tests\**" />
<None Remove="obj\**" />
<None Remove="FlubuExample.Tests2\**" />
<None Remove="FlubuExample.Tests\**" />
Expand All @@ -30,13 +33,13 @@
<None Remove="FlubuExample.v12.suo" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FlubuCore" Version="3.1.0" />
<PackageReference Include="FlubuCore" Version="4.3.3" />
<PackageReference Include="FluentMigrator" Version="3.1.3" />
<PackageReference Include="RestSharp" Version="106.3.1" />

</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="dotnet-flubu" Version="3.1.0" />
<DotNetCliToolReference Include="dotnet-flubu" Version="4.3.3" />
</ItemGroup>
<ItemGroup>
<Reference Include="xunit.assert">
Expand Down
20 changes: 19 additions & 1 deletion NetCore_csproj/BuildScript/BuildScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Newtonsoft.Json;
using RestSharp;

//// Examine build scripts in other projects for more use cases.

[Include("./BuildScript/BuildScriptHelper.cs")]
public class MyBuildScript : DefaultBuildScript
{
Expand All @@ -20,7 +20,9 @@ public class MyBuildScript : DefaultBuildScript
protected override void ConfigureBuildProperties(IBuildPropertiesContext context)
{
context.Properties.Set(BuildProps.ProductId, "FlubuExample");
//// Solution is stored in flubu session so it doesn't need to be defined in restore and build task.
context.Properties.Set(BuildProps.SolutionFileName, "FlubuExample.sln");
//// BuildConfiguration is stored in flubu session so it doesn't need to be defined in build task and test tasks.
context.Properties.Set(BuildProps.BuildConfiguration, "Release");
}

Expand Down Expand Up @@ -48,6 +50,18 @@ protected override void ConfigureTargets(ITaskContext context)
.AddCoreTaskAsync(x => x.Test().Project("FlubuExample.Tests"))
.AddCoreTaskAsync(x => x.Test().Project("FlubuExample.Tests2"));


var vsSolution = context.GetVsSolution();
var testProjects = vsSolution.FilterProjects("*.Tests");

var testAlternative = context.CreateTarget("test.alternative")
.ForEach(testProjects,
(project, target) =>
{
target.AddCoreTask(x => x.Test().Project(project.ProjectName));
});


var package = context
.CreateTarget("Package")
.AddCoreTask(x => x.Publish("FlubuExample"))
Expand Down Expand Up @@ -120,6 +134,10 @@ private void ReuseSetOfTargetsExample(ITarget target, string directoryName, stri
{
c.LogInfo("Dummy example of OnFinally and When on group of tasks.");
},
onError: (c, ex) =>
{
c.LogInfo("Dummy example of OnError on group of tasks.");
},
when: c => true
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
using System.Text;
using FlubuCore.Context;
using FlubuCore.Scripting;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace BuildScript.BuildScript
{
/// <summary>
/// See FlubuExample.Tests BuildScriptTests.cs
/// </summary>
public class BuildScriptForTestsAndDebugExample : DefaultBuildScript
{
protected override void ConfigureBuildProperties(IBuildPropertiesContext context)
Expand All @@ -23,7 +27,9 @@ protected override void ConfigureTargets(ITaskContext session)

public void CreateFile(ITaskContext context)
{
File.Create("test123.txt");
using(File.Create("test123.txt"))
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading;
using FlubuCore.Scripting;
using FlubuCore.Tasks.Solution;
using Xunit;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void TestTargetExample()

[Fact]
//// You can just test your code in do (Custom code)
public void TestDoExample()
public void TestBuildScriptMethodExample()
{
if (File.Exists("test123.txt"))
{
Expand All @@ -53,10 +54,11 @@ public void TestDoExample()
IFlubuEngine engine = new FlubuEngine();

var session = engine.CreateTaskSession(new BuildScriptArguments());
bs.CreateFile(session);
Assert.True(File.Exists("test123.txt"));
}

[Fact]
[Fact(Skip = "Just an example")]
public void HowToUseTaskInOtherNetApplication()
{
////
Expand Down
5 changes: 5 additions & 0 deletions NetCore_csproj/FlubuExample.Tests/FlubuExample.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FlubuCore" Version="4.3.3" />
<PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.500-preview2-1-003177" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit" Version="3.6.1" />
Expand All @@ -30,6 +31,10 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BuildScript.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
Expand Down
11 changes: 7 additions & 4 deletions NetCore_csproj/FlubuExample.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlubuExample", "FlubuExample\FlubuExample.csproj", "{B073DE1D-453F-4437-9003-20A8DD3AD455}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlubuExample", "FlubuExample\FlubuExample.csproj", "{B073DE1D-453F-4437-9003-20A8DD3AD455}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildScript", "BuildScript.csproj", "{13796F1A-ABA3-40CB-874F-11238F37BCC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlubuExample.Tests", "FlubuExample.Tests\FlubuExample.Tests.csproj", "{AB097716-56D5-4B88-80D6-7A0F999FEA26}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlubuExample.Tests2", "FlubuExample.Tests2\FlubuExample.Tests2.csproj", "{B4C0065E-C886-41B0-97C5-C18B048BCDB2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FlubuExample2.Tests", "FlubuExample2.Tests\FlubuExample2.Tests.csproj", "{B4C0065E-C886-41B0-97C5-C18B048BCDB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -73,4 +73,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7AB1BDE1-4805-4C24-A80B-175ABB849E21}
EndGlobalSection
EndGlobal

0 comments on commit 8d19dc7

Please sign in to comment.