Skip to content

Commit

Permalink
(GH-332) Support .NET Core 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Sep 25, 2019
1 parent bf73cb4 commit 83c63d1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 116 deletions.
1 change: 1 addition & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
assembly-versioning-scheme: Major
assembly-file-versioning-scheme: MajorMinorPatchTag
next-version: 2.1.0
mode: ContinuousDeployment
branches:
master:
Expand Down
10 changes: 7 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ environment:
secure: BSPdW2TgnQtoQXXbeDECug==

skip_tags: true
image: Visual Studio 2019 Preview
image: Visual Studio 2019
test: off

install:
- cinst dotnetcore-sdk --pre
- cinst dotnetcore-sdk

pull_requests:
do_not_increment_build_number: false
Expand All @@ -35,4 +35,8 @@ artifacts:
- path: \Publish\*.*

nuget:
disable_publish_on_pr: true
disable_publish_on_pr: true

skip_commits:
files:
- '**/*.md'
174 changes: 64 additions & 110 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

#module nuget:?package=Cake.DotNetTool.Module
#tool "dotnet:?package=NuGetKeyVaultSignTool&version=1.2.18"
Expand All @@ -11,18 +11,18 @@
#tool vswhere
#addin Cake.Figlet

//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var verbosity = Argument("verbosity", Verbosity.Minimal);
var dotnetcoreverbosity = Argument("dotnetcoreverbosity", DotNetCoreVerbosity.Minimal);

//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

var repoName = "gong-wpf-dragdrop";
var isLocal = BuildSystem.IsLocalBuild;
Expand All @@ -34,6 +34,12 @@ if (isLocal == false || verbosity == Verbosity.Verbose)
}
GitVersion gitVersion = GitVersion(new GitVersionSettings { OutputType = GitVersionOutput.Json });

var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var branchName = gitVersion.BranchName;
var isDevelopBranch = StringComparer.OrdinalIgnoreCase.Equals("dev", branchName);
var isReleaseBranch = StringComparer.OrdinalIgnoreCase.Equals("master", branchName);
var isTagged = AppVeyor.Environment.Repository.Tag.IsTag;

var latestInstallationPath = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = true });
var msBuildPath = latestInstallationPath.Combine("./MSBuild/Current/Bin");
var msBuildPathExe = msBuildPath.CombineWithFilePath("./MSBuild.exe");
Expand All @@ -43,12 +49,6 @@ if (FileExists(msBuildPathExe) == false)
throw new NotImplementedException("You need at least Visual Studio 2019 to build this project.");
}

var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest;
var branchName = gitVersion.BranchName;
var isDevelopBranch = StringComparer.OrdinalIgnoreCase.Equals("dev", branchName);
var isReleaseBranch = StringComparer.OrdinalIgnoreCase.Equals("master", branchName);
var isTagged = AppVeyor.Environment.Repository.Tag.IsTag;

// Directories and Paths
var solution = "./src/GongSolutions.WPF.DragDrop.sln";
var publishDir = "./Publish";
Expand All @@ -60,40 +60,37 @@ Action Abort = () => { throw new Exception("a non-recoverable fatal error occurr
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////

Setup(context =>
Setup(ctx =>
{
// Executed BEFORE the first task.

if (!IsRunningOnWindows())
{
throw new NotImplementedException($"{repoName} will only build on Windows because it's not possible to target WPF and Windows Forms from UNIX.");
}

Information(Figlet(repoName));

Information("Informational Version : {0}", gitVersion.InformationalVersion);
Information("SemVer Version : {0}", gitVersion.SemVer);
Information("AssemblySemVer Version : {0}", gitVersion.AssemblySemVer);
Information("Informational Version: {0}", gitVersion.InformationalVersion);
Information("SemVer Version: {0}", gitVersion.SemVer);
Information("AssemblySemVer Version: {0}", gitVersion.AssemblySemVer);
Information("MajorMinorPatch Version: {0}", gitVersion.MajorMinorPatch);
Information("NuGet Version : {0}", gitVersion.NuGetVersion);
Information("NuGet Version: {0}", gitVersion.NuGetVersion);
Information("IsLocalBuild : {0}", isLocal);
Information("Branch : {0}", branchName);
Information("Configuration : {0}", configuration);
Information("MSBuildPath : {0}", msBuildPath);
});

Teardown(context =>
Teardown(ctx =>
{
// Executed AFTER the last task.
});

//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

Task("Clean")
.ContinueOnError()
.Does(() =>
.ContinueOnError()
.Does(() =>
{
var directoriesToDelete = GetDirectories("./**/obj")
.Concat(GetDirectories("./**/bin"))
Expand All @@ -104,24 +101,18 @@ Task("Clean")
Task("Restore")
.Does(() =>
{
var msBuildSettings = new MSBuildSettings {
Verbosity = verbosity
, ToolPath = msBuildPathExe
, Configuration = configuration
, ArgumentCustomization = args => args.Append("/m")
};
MSBuild(solution, msBuildSettings.WithTarget("restore"));
NuGetRestore(solution, new NuGetRestoreSettings { MSBuildPath = msBuildPath.ToString() });
});

Task("Build")
.IsDependentOn("Restore")
.Does(() =>
.IsDependentOn("Restore")
.Does(() =>
{
var msBuildSettings = new MSBuildSettings {
Verbosity = verbosity
, ToolPath = msBuildPathExe
, Configuration = configuration
, ArgumentCustomization = args => args.Append("/m")
, ArgumentCustomization = args => args.Append("/m").Append("/nr:false") // The /nr switch tells msbuild to quite once it’s done
, BinaryLogger = new MSBuildBinaryLogSettings() { Enabled = isLocal }
};
MSBuild(solution, msBuildSettings
Expand All @@ -139,7 +130,7 @@ Task("dotnetBuild")
var buildSettings = new DotNetCoreBuildSettings {
Verbosity = dotnetcoreverbosity,
Configuration = configuration,
ArgumentCustomization = args => args.Append("/m"),
ArgumentCustomization = args => args.Append("/m").Append("/nr:false"), // The /nr switch tells msbuild to quite once it’s done
MSBuildSettings = new DotNetCoreMSBuildSettings()
.SetMaxCpuCount(0)
.SetConfiguration(configuration)
Expand All @@ -153,43 +144,8 @@ Task("dotnetBuild")
});

Task("Pack")
.WithCriteria(() => !isPullRequest)
.Does(() =>
{
EnsureDirectoryExists(Directory(publishDir));

var msBuildSettings = new MSBuildSettings {
Verbosity = verbosity
, ToolPath = msBuildPathExe
, Configuration = configuration
};
var projects = GetFiles("./src/GongSolutions.WPF.DragDrop/*.csproj");

foreach(var project in projects)
{
Information("Packing {0}", project);

DeleteFiles(GetFiles("./src/**/*.nuspec"));

MSBuild(project, msBuildSettings
.WithTarget("pack")
.WithProperty("NoBuild", "true")
.WithProperty("IncludeBuildOutput", "true")
.WithProperty("PackageOutputPath", MakeAbsolute(Directory(publishDir)).FullPath)
.WithProperty("RepositoryBranch", branchName)
.WithProperty("RepositoryCommit", gitVersion.Sha)
.WithProperty("Version", isReleaseBranch ? gitVersion.MajorMinorPatch : gitVersion.NuGetVersion)
.WithProperty("AssemblyVersion", gitVersion.AssemblySemVer)
.WithProperty("FileVersion", gitVersion.AssemblySemFileVer)
.WithProperty("InformationalVersion", gitVersion.InformationalVersion)
);
}

});

Task("dotnetPack")
.WithCriteria(() => !isPullRequest)
.Does(() =>
.WithCriteria(() => !isPullRequest)
.Does(() =>
{
EnsureDirectoryExists(Directory(publishDir));

Expand All @@ -212,7 +168,6 @@ Task("dotnetPack")
};

var projects = GetFiles("./src/GongSolutions.WPF.DragDrop/*.csproj");

foreach(var project in projects)
{
Information("Packing {0}", project);
Expand All @@ -223,38 +178,6 @@ Task("dotnetPack")
}
});

Task("Zip")
.Does(() =>
{
EnsureDirectoryExists(Directory(publishDir));
Zip($"./src/Showcase/bin/{configuration}", $"{publishDir}/Showcase.DragDrop.{configuration}-v" + gitVersion.NuGetVersion + ".zip");
});

Task("CreateRelease")
.WithCriteria(() => !isTagged)
.Does(() =>
{
var username = EnvironmentVariable("GITHUB_USERNAME");
if (string.IsNullOrEmpty(username))
{
throw new Exception("The GITHUB_USERNAME environment variable is not defined.");
}

var token = EnvironmentVariable("GITHUB_TOKEN");
if (string.IsNullOrEmpty(token))
{
throw new Exception("The GITHUB_TOKEN environment variable is not defined.");
}

GitReleaseManagerCreate(username, token, "punker76", repoName, new GitReleaseManagerCreateSettings {
Milestone = gitVersion.MajorMinorPatch,
Name = gitVersion.AssemblySemFileVer,
Prerelease = isDevelopBranch,
TargetCommitish = branchName,
WorkingDirectory = "."
});
});

void SignFiles(IEnumerable<FilePath> files, string description)
{
var vurl = EnvironmentVariable("azure-key-vault-url");
Expand Down Expand Up @@ -405,6 +328,39 @@ Task("SignNuGet")
}
}
});

Task("Zip")
.Does(() =>
{
EnsureDirectoryExists(Directory(publishDir));
Zip($"./src/Showcase/bin/{configuration}", $"{publishDir}/Showcase.DragDrop.{configuration}-v" + gitVersion.NuGetVersion + ".zip");
});

Task("CreateRelease")
.WithCriteria(() => !isTagged)
.Does(() =>
{
var username = EnvironmentVariable("GITHUB_USERNAME");
if (string.IsNullOrEmpty(username))
{
throw new Exception("The GITHUB_USERNAME environment variable is not defined.");
}

var token = EnvironmentVariable("GITHUB_TOKEN");
if (string.IsNullOrEmpty(token))
{
throw new Exception("The GITHUB_TOKEN environment variable is not defined.");
}

GitReleaseManagerCreate(username, token, "punker76", repoName, new GitReleaseManagerCreateSettings {
Milestone = gitVersion.MajorMinorPatch,
Name = gitVersion.AssemblySemFileVer,
Prerelease = isDevelopBranch,
TargetCommitish = branchName,
WorkingDirectory = "."
});
});

///////////////////////////////////////////////////////////////////////////////
// TASK TARGETS
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -417,11 +373,9 @@ Task("Default")
Task("appveyor")
.IsDependentOn("Default")
.IsDependentOn("Sign")
// .IsDependentOn("Pack");
.IsDependentOn("dotnetPack")
.IsDependentOn("Pack")
.IsDependentOn("SignNuGet")
.IsDependentOn("Zip")
;
.IsDependentOn("Zip");

///////////////////////////////////////////////////////////////////////////////
// EXECUTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<!-- Project properties -->
<PropertyGroup>
<TargetFrameworks>net45;net46;net47;netcoreapp3.0</TargetFrameworks>
<AssemblyName>GongSolutions.WPF.DragDrop</AssemblyName>
<Title>gong-wpf-dragdrop</Title>
<RootNamespace>GongSolutions.WPF.DragDrop</RootNamespace>
Expand Down
1 change: 0 additions & 1 deletion src/Showcase/Showcase.WPF.DragDrop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<!-- Project properties -->
<PropertyGroup>
<TargetFrameworks>net45;net46;net47;netcoreapp3.0</TargetFrameworks>
<AssemblyName>Showcase.WPF.DragDrop</AssemblyName>
<RootNamespace>Showcase.WPF.DragDrop</RootNamespace>
<DisableFody Condition="'$(Configuration)' == 'Debug' or '$(TargetFramework)' == 'netcoreapp3.0'">true</DisableFody>
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100-preview"
"version": "3.0.100"
}
}

0 comments on commit 83c63d1

Please sign in to comment.