Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
* release/0.2.0: (24 commits)
  (build) Corrected failing build in 15.3 Visual Studio
  (GH-76) Updated to Cake 0.21.1
  (GH-18) Tabs to Spaces
  (maint) Update to https
  Add support for drag-and-drop with cake and dll files
  Re-target to .NET Framework 4.6 and update NuGet dependencies
  Update Cake dependencies/templates to 0.19.4
  Adds Visual Studio 2017 support
  added params key word
  (GH-64) Update Cake to 0.17.0/1
  Add support for Cake-specific language/IDE settings
  Add MagicChunks-powered version transform
  Remove diagnostic logging, fix manifest versioning
  Upload as single stream, not multipart
  Fix compilation error and rookie mistake
  Additional logging for MyGet upload client
  task-runner: Rework regex to allow whitespace
  Additional build scripts for CI builds/packages
  Added support for "smart" indentation in Cake files. Indents are added on method body open, otherwise last offset used.
  Update task match pattern to support symbols and numbers in task names (to fix #37)
  ...
  • Loading branch information
gep13 committed Aug 22, 2017
2 parents d1dd982 + 44d06b0 commit 0f11ab7
Show file tree
Hide file tree
Showing 66 changed files with 1,390 additions and 199 deletions.
18 changes: 9 additions & 9 deletions Cake.VisualStudio.sln
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26127.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.VisualStudio", "src\Cake.VisualStudio.csproj", "{94660BCF-169A-42E1-BD84-345449743069}"
ProjectSection(ProjectDependencies) = postProject
{FCE573DD-E74E-4AB1-9D17-56FC8869797F} = {FCE573DD-E74E-4AB1-9D17-56FC8869797F}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04D0CE67-A915-44BB-BC3C-8E7885CF9E97}"
ProjectSection(SolutionItems) = preProject
build.cake = build.cake
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinTemplate", "template\AddinTemplate\AddinTemplate.csproj", "{FCE573DD-E74E-4AB1-9D17-56FC8869797F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Templates", "Templates", "{7067556F-B744-4F73-B509-C8CC9F559AB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.VisualStudio", "src\Cake.VisualStudio.csproj", "{94660BCF-169A-42E1-BD84-345449743069}"
ProjectSection(ProjectDependencies) = postProject
{FCE573DD-E74E-4AB1-9D17-56FC8869797F} = {FCE573DD-E74E-4AB1-9D17-56FC8869797F}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinTemplate", "template\AddinTemplate\AddinTemplate.csproj", "{FCE573DD-E74E-4AB1-9D17-56FC8869797F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModuleTemplate", "template\ModuleTemplate\ModuleTemplate.csproj", "{85BCBED7-39BD-4670-85F7-EE36D0DA31C0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ItemTemplate", "template\ItemTemplate\ItemTemplate.csproj", "{C27AB61E-D245-4A8C-ABD1-53313E388509}"
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Build worker image
image: Visual Studio 2017

# Build script
init:
- git config --global core.autocrlf true
Expand Down
Binary file removed art/cake-icon.pxf
Binary file not shown.
165 changes: 121 additions & 44 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

//////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
//////////////////////////////////////////////////////////////////////

#addin "nuget:https://www.nuget.org/api/v2?package=MagicChunks&version=1.2.0.58"
#tool "nuget:?package=gitreleasemanager&version=0.6.0"
#tool "nuget:?package=GitVersion.CommandLine&version=3.4.1"

//////////////////////////////////////////////////////////////////////
// EXTERNAL SCRIPTS
//////////////////////////////////////////////////////////////////////

#load "./build/parameters.cake"

///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
///////////////////////////////////////////////////////////////////////////////
Expand All @@ -14,94 +28,157 @@ var solution = ParseSolution(solutionPath);
var projects = solution.Projects;
var projectPaths = projects.Select(p => p.Path.GetDirectory());
var artifacts = "./dist/";
var publishingError = false;
///////////////////////////////////////////////////////////////////////////////
// BUILD VARIABLES
///////////////////////////////////////////////////////////////////////////////

var buildSystem = BuildSystem;
var IsMainCakeVsRepo = StringComparer.OrdinalIgnoreCase.Equals("cake-build/cake-vs", buildSystem.AppVeyor.Environment.Repository.Name);
var IsMainCakeVsBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch);
var IsBuildTagged = buildSystem.AppVeyor.Environment.Repository.Tag.IsTag
&& !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name);
BuildParameters parameters = BuildParameters.GetParameters(Context, BuildSystem);
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
// Executed BEFORE the first task.
Information("Running tasks...");
parameters.SetBuildVersion(
BuildVersion.CalculatingSemanticVersion(
context: Context,
parameters: parameters
)
);
Information("Building version {0} of cake-vs ({1}, {2}) using version {3} of Cake. (IsTagged: {4})",
parameters.Version.SemVersion,
parameters.Configuration,
parameters.Target,
parameters.Version.CakeVersion,
parameters.IsTagged);
});
Teardown(ctx =>
{
// Executed AFTER the last task.
Information("Finished running tasks.");
// Executed AFTER the last task.
Information("Finished running tasks.");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("Test-Pattern")
.Does(() => {
foreach (var file in GetFiles("./template/**/Properties/AssemblyInfo.cs")) {
Information("Match: {0}", file.FullPath);
}
});
Task("Clean")
.Does(() =>
.Does(() =>
{
// Clean solution directories.
foreach(var path in projectPaths)
{
Information("Cleaning {0}", path);
CleanDirectories(path + "/**/bin/" + configuration);
CleanDirectories(path + "/**/obj/" + configuration);
}
Information("Cleaning common files...");
CleanDirectory(artifacts);
});
Task("Create-Release-Notes")
.Does(() =>
{
GitReleaseManagerCreate(parameters.GitHub.UserName, parameters.GitHub.Password, "cake-build", "cake-vs", new GitReleaseManagerCreateSettings {
Milestone = parameters.Version.Milestone,
Name = parameters.Version.Milestone,
Prerelease = true,
TargetCommitish = "master"
});
});
Task("Update-Manifest-Version")
.WithCriteria(() => parameters.ShouldPublishToMyGet)
.Does(() =>
{
// Clean solution directories.
foreach(var path in projectPaths)
{
Information("Cleaning {0}", path);
CleanDirectories(path + "/**/bin/" + configuration);
CleanDirectories(path + "/**/obj/" + configuration);
}
Information("Cleaning common files...");
CleanDirectory(artifacts);
BuildVersion.UpdateManifestVersion(
context: Context,
path: "./src/source.extension.vsixmanifest"
);
});
Task("Restore")
.Does(() =>
.Does(() =>
{
// Restore all NuGet packages.
Information("Restoring solution...");
NuGetRestore(solutionPath);
// Restore all NuGet packages.
Information("Restoring solution...");
NuGetRestore(solutionPath);
});
Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.Does(() =>
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("Update-Manifest-Version")
.Does(() =>
{
Information("Building solution...");
MSBuild(solutionPath, settings =>
settings.SetPlatformTarget(PlatformTarget.MSIL)
Information("Building solution...");
MSBuild(solutionPath, settings =>
settings.SetPlatformTarget(PlatformTarget.MSIL)
.SetMSBuildPlatform(MSBuildPlatform.x86)
.WithProperty("TreatWarningsAsErrors","true")
.SetVerbosity(Verbosity.Quiet)
.WithTarget("Build")
.SetConfiguration(configuration));
.UseToolVersion(MSBuildToolVersion.VS2017)
.WithProperty("TreatWarningsAsErrors","true")
.SetVerbosity(Verbosity.Quiet)
.WithTarget("Build")
.SetConfiguration(configuration));
});
Task("Post-Build")
.IsDependentOn("Build")
.Does(() =>
.IsDependentOn("Build")
.Does(() =>
{
CopyFileToDirectory("./src/bin/" + configuration + "/Cake.VisualStudio.vsix", artifacts);
});
Task("Publish-Extension")
Task("Publish-GitHub-Release")
.WithCriteria(() => parameters.ShouldPublish)
.Does(() =>
{
var buildResultDir = Directory(artifacts);
var packageFile = File("Cake.VisualStudio.vsix");
GitReleaseManagerAddAssets(parameters.GitHub.UserName, parameters.GitHub.Password, "cake-build", "cake-vs", parameters.Version.Milestone, buildResultDir + packageFile);
GitReleaseManagerClose(parameters.GitHub.UserName, parameters.GitHub.Password, "cake-build", "cake-vs", parameters.Version.Milestone);
})
.OnError(exception =>
{
Information("Publish-GitHub-Release Task failed, but continuing with next Task...");
publishingError = true;
});
Task("Upload-Artifact")
.IsDependentOn("Post-Build")
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
.WithCriteria(() => IsMainCakeVsRepo)
.Does(() =>
.WithCriteria(() => parameters.ShouldPublishToAppVeyor)
.Does(() =>
{
AppVeyor.UploadArtifact(artifacts + "Cake.VisualStudio.vsix");
});
Task("Publish-Extension")
.IsDependentOn("Post-Build")
.WithCriteria(() => parameters.ShouldPublishToMyGet)
.Does(() =>
{
var vsixPath = artifacts + "Cake.VisualStudio.vsix";
var client = MyGetClient.GetClient(parameters.MyGet.Url, parameters.MyGet.Key, s => Context.Verbose(s));
Information("Uploading VSIX to {0}...", parameters.MyGet.Url);
var response = client.UploadVsix(GetFile(artifacts + "Cake.VisualStudio.vsix"));
Information("VSIX Upload {0}", response.IsSuccessStatusCode ? "succeeded." : "failed with reason '" + response.ReasonPhrase + "'.");
});
Task("Default")
.IsDependentOn("Post-Build");
.IsDependentOn("Post-Build");
Task("AppVeyor")
.IsDependentOn("Upload-Artifact")
.IsDependentOn("Publish-Extension");
RunTarget(target);
62 changes: 62 additions & 0 deletions build/myget.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#addin "System.Net.Http"
using System.Net.Http;

public class MyGetClient : HttpClient
{

public string ApiKey { get; set; }
public Uri FeedUri { get; set; }
private Action<string> Log { get; set; }

public static MyGetClient GetClient(string uri, string key)
{
return GetClient(uri, key, s => { });
}

public static MyGetClient GetClient(string uri, string key, Action<string> log) {
return new MyGetClient
{
FeedUri = uri.TrimEnd('/').EndsWith("/upload")
? new Uri(uri)
: new Uri(uri.TrimEnd('/') + "/upload"),
ApiKey = key,
Log = log
};
}

public static MyGetClient GetClient(MyGetFeed feed)
{
return MyGetClient.GetClient(feed.Url, feed.Key);
}

public HttpResponseMessage UploadVsix(IFile file)
{
Log = Log ?? (s => { });
using (var content = new StreamContent(file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)))
{
DefaultRequestHeaders.Add("X-NuGet-ApiKey", ApiKey);
Log.Invoke(string.Format("Issuing POST request to {0}", FeedUri));
using (var message =
PostAsync(FeedUri, content).Result)
{
return message;
}
}
}
}

public class MyGetFeed
{
public string Url { get; private set; }
public string Key { get; private set; }

public MyGetFeed(string feedUrl, string apiKey)
{
Url = feedUrl;
Key = apiKey;
}
}

public IFile GetFile(FilePath path) {
return Context.FileSystem.GetFile(path);
}
Loading

0 comments on commit 0f11ab7

Please sign in to comment.