Skip to content

Commit

Permalink
Add build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Nov 25, 2020
1 parent 43f6b69 commit e23708e
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
* text=auto

# Explicitly declare files that should always be converted to LF regardless of platform
*.sh text eol=lf
*.dotsettings text eol=lf
22 changes: 7 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,36 +1,28 @@
#Ignore thumbnails created by Windows
#windows
Thumbs.db

#Ignore metadata created by OSX
#osx
.DS_Store
._*

#Ignore files created by Visual Studio
#visual-studio
.vs/
*.user
*.suo
*.tmp_proj
*.dbmdl
*.dbproj.schemaview
*.cache
*.vsdoc
[Oo]bj/
[Bb]in/
[Dd]ebug/
[Rr]elease/
[Rr][Cc]/
[Cc]ode[Cc]overage/
[Ff]x[Cc]op/
[Ll]og/
[Tt]emp/

# Ignore NuGet Packages
#nuget
*.nupkg
**/packages/*

#Ignore files created by ReSharper
_ReSharper*/

#Ignore files created by NUnit
TestResult.xml
*.VisualState.xml
#cake
/build/*
/tools/*
105 changes: 105 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#tool "nuget:?package=NuGet.CommandLine&version=5.8.0"
#addin "nuget:?package=Cake.MinVer&version=0.1.0"

var target = Argument<string>("target", "pack");
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));

Task("clean")
.Does(() =>
{
CleanDirectory("./build/artifacts");
CleanDirectories("./src/**/bin");
CleanDirectories("./src/**/obj");
CleanDirectories("./test/**/bin");
CleanDirectories("./test/**/obj");
});

Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
NuGetRestore("./Ookii.Dialogs.WinForms.sln", new NuGetRestoreSettings
{
NoCache = true,
});
});

Task("build")
.IsDependentOn("restore")
.Does(() =>
{
var assemblyVersionInfoFile = FilePath.FromString("./src/Ookii.Dialogs.WinForms/Properties/AssemblyVersionInfo.cs");
var assemblyVersionInfoBytes = System.IO.File.ReadAllBytes(assemblyVersionInfoFile.FullPath);

try
{
CreateAssemblyInfo(assemblyVersionInfoFile, new AssemblyInfoSettings
{
Version = buildVersion.AssemblyVersion,
FileVersion = buildVersion.FileVersion,
InformationalVersion = buildVersion.PackageVersion,
});

MSBuild("./Ookii.Dialogs.WinForms.sln", new MSBuildSettings
{
Configuration = "Debug",
ToolVersion = MSBuildToolVersion.VS2019,
}.WithTarget("Rebuild"));

MSBuild("./Ookii.Dialogs.WinForms.sln", new MSBuildSettings
{
Configuration = "Release",
ToolVersion = MSBuildToolVersion.VS2019,
}.WithTarget("Rebuild"));
}
finally
{
System.IO.File.WriteAllBytes(assemblyVersionInfoFile.FullPath, assemblyVersionInfoBytes);
}
});

Task("pack")
.IsDependentOn("build")
.Does(() =>
{
var releaseNotes = $"https://github.com/augustoproiete/ookii-dialogs-winforms/releases/tag/v{buildVersion.PackageVersion}";

NuGetPack("./src/Ookii.Dialogs.WinForms/Ookii.Dialogs.WinForms.nuspec", new NuGetPackSettings
{
Version = buildVersion.PackageVersion,
OutputDirectory = "./build/artifacts",
ReleaseNotes = new[] { releaseNotes },
});
});

Task("publish")
.IsDependentOn("pack")
.Does(context =>
{
var url = context.EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}

var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}

var nugetPushSettings = new DotNetCoreNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};

foreach (var nugetPackageFile in GetFiles("./build/artifacts/*.nupkg"))
{
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});

RunTarget(target);
11 changes: 11 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo on
@cd %~dp0

set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
set DOTNET_CLI_TELEMETRY_OPTOUT=1
set DOTNET_NOLOGO=1

dotnet tool restore
@if %ERRORLEVEL% neq 0 goto :eof

dotnet cake --verbosity=diagnostic %*
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euox pipefail

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

dotnet tool restore

dotnet cake --verbosity=diagnostic $@
12 changes: 12 additions & 0 deletions cake.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Nuget]
Source=https://api.nuget.org/v3/index.json
UseInProcessClient=true
LoadDependencies=false

[Paths]
Tools=./tools
Addins=./tools/addins
Modules=./tools/modules

[Settings]
SkipVerification=false
2 changes: 1 addition & 1 deletion src/Ookii.Dialogs.WinForms/Ookii.Dialogs.WinForms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Ookii.Dialogs.WinForms.xml</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
Expand Down Expand Up @@ -105,6 +104,7 @@
<DependentUpon>ProgressDialog.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyVersionInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand Down
14 changes: 0 additions & 14 deletions src/Ookii.Dialogs.WinForms/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,3 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("16078df2-e2d1-4754-9864-84c288a1e9bd")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
10 changes: 10 additions & 0 deletions src/Ookii.Dialogs.WinForms/Properties/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Cake.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Reflection;

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]

0 comments on commit e23708e

Please sign in to comment.