-
Notifications
You must be signed in to change notification settings - Fork 57
Add cake build script (#2) #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
build.cake
Outdated
var configuration = Argument("configuration", "Release"); | ||
|
||
|
||
var buildDir = Directory($"./build/{configuration}/"); |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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 => |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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")
There was a problem hiding this comment.
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
src/Grok.Net/Grok.Net.csproj
Outdated
@@ -15,7 +15,8 @@ | |||
|
|||
<PropertyGroup> | |||
<Version>1.0.1</Version> | |||
</PropertyGroup> | |||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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 }); |
There was a problem hiding this comment.
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"));
}
});
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
There was a problem hiding this 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
@euronay thank you for your PR |
No description provided.