Skip to content

Conversation

euronay
Copy link
Contributor

@euronay euronay commented Oct 1, 2019

No description provided.

build.cake Outdated
var configuration = Argument("configuration", "Release");


var buildDir = Directory($"./build/{configuration}/");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to name it "artifacts"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

build.cake Outdated
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solutionFile);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain what is the difference between DotNetCoreRestore and NuGetRestore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NuGetRestore uses the nuget cli instead of dotnet. Apologies I've only really written cake scripts for full framework projects before so I used what I know! I've updated to use DotNetRestore

build.cake Outdated
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please always clean outputNupkg, obj and bin directories clean if it is a local build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No check if it is a local build

build.cake Outdated
{
if(IsRunningOnWindows())
{
MSBuild(solutionFile, settings =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use DotNetCoreBuild here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Have changed.

build.cake Outdated

var buildDir = Directory($"./build/{configuration}/");
var solutionFile = "./src/Grok.Net.sln";
var outputNupkg = $"./src/Grok.Net/bin/{configuration}/*.nupkg";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't actually need to hardcode tha path, just use something like GetFiles(@"**/*.nupkg")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer relevant now I've changed to DotNetPack

@@ -15,7 +15,8 @@

<PropertyGroup>
<Version>1.0.1</Version>
</PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, it will generate package on each build. We can remove this line and add DotNetCorePack task to build.cake to generate only if it is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Marusyk Marusyk self-assigned this Oct 1, 2019
@euronay euronay requested a review from Marusyk October 2, 2019 11:24
Copy link
Owner

@Marusyk Marusyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Please make small changes. Thank you in advance

build.cake Outdated
Task("Clean")
.Does(() =>
{
CleanDirectories(new[]{ artifactsDir, binDir, objDir });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about this way:

Task("Clean")
    .Does(() =>
    {
        CleanDirectory(artifactsDir);

        if(BuildSystem.IsLocalBuild)
        {
            CleanDirectories(GetDirectories("./**/obj") + GetDirectories("./**/bin"));
        }
    });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good way 👍

build.cake Outdated
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
DotNetCoreBuild(projectFile, new DotNetCoreBuildSettings(){ Configuration = configuration });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default DotNetCoreBuild will run nuget restore command. As it is currently implemented, we run "Restore-NuGet-Packages" task before "Build". So, we don't actually need to run restore command again. You can do it in this way:

DotNetCoreBuild(projectFile, new DotNetCoreBuildSettings
{
	Configuration = configuration,
	NoRestore = true
});

it will decrease build time. yes it is only a few milliseconds, but sometimes milliseconds is important :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A fair point. Changed.

.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
DotNetCorePack(projectFile, new DotNetCorePackSettings()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here. DotNetCorePack runs nuget restore command and build command. In this task, we have already restored and built a project. Try this one:

var settings = new DotNetCorePackSettings
{
	Configuration = configuration,
	NoRestore = false,
	NoBuild = true,
	OutputDirectory = artifactsDir
};

DotNetCorePack(projectFile, settings);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

@euronay euronay requested a review from Marusyk October 2, 2019 19:42
Copy link
Owner

@Marusyk Marusyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing this

@Marusyk Marusyk merged commit 6d58dfd into Marusyk:master Oct 2, 2019
@Marusyk
Copy link
Owner

Marusyk commented Oct 2, 2019

@euronay thank you for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants