Giter Site home page Giter Site logo

cake.tool compat? about cake.aws.s3 HOT 4 CLOSED

sharperad avatar sharperad commented on August 21, 2024
cake.tool compat?

from cake.aws.s3.

Comments (4)

SharpeRAD avatar SharpeRAD commented on August 21, 2024

You haven't included the original cake file so it's very hard for me to give you a definitive answer. I would assume by the title that you're running it using the .net core global tool so my first question is what happens when you run the CLI it from the standard Powershell script?

v0.6.6 of Cake.AWS.S3 has a reference to AWSSDK.S3 v3.3.17.9, not v3.3.0.0 so what other addons are you trying to use in your script?

from cake.aws.s3.

bonesoul avatar bonesoul commented on August 21, 2024

hey there using the cake.tool (https://www.nuget.org/packages/Cake.Tool/)

when i run my build script with actual cake (https://www.nuget.org/packages/Cake) it all works fine.

here is my script for your reference;

// sample I:  https://github.com/fluentassertions/fluentassertions/blob/master/build.cake
// sample II: https://github.com/gtbuchanan/repo-template-cs/blob/master/build.cake

// packages to use

#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
#tool "nuget:?package=vswhere&Version=2.5.2"
#addin "Cake.AWS.S3&version=0.6.6"
#addin "Cake.Git&Version=0.19.0"
#addin "Cake.Discord&version=0.1.0"

// master configuration
var buildRoot =  MakeAbsolute(Directory("./")); // get current path.
var target = Argument("target", "Default"); // build target. default 
var configuration = Argument("configuration", "Release"); // build configuration. release.
var vsLatest  = VSWhereLatest(); // get the vs path.
var msBuildPathX64 = (vsLatest == null) ? null : vsLatest.CombineWithFilePath("./MSBuild/15.0/Bin/amd64/MSBuild.exe");

// build configuration
var isAzurePipelines = TFBuild.IsRunningOnVSTS || TFBuild.IsRunningOnTFS; // are we running over azure devops?
var isWindowsBuild = IsRunningOnWindows(); // are we running a windows based build?
 var isLocal = BuildSystem.IsLocalBuild; // are we running a local build?

// git configuration
var currentBranch = Argument<string>("currentBranch", GitBranchCurrent("../").FriendlyName);
var isStableBuild = string.Equals(currentBranch, "master", StringComparison.OrdinalIgnoreCase);
var version = GitVersion(new GitVersionSettings { UpdateAssemblyInfo = false }); // init gitversion.

// solution configuration.
var sourcesDir = MakeAbsolute(Directory("../src")); // source code folder [src/]
var solutionFile = MakeAbsolute(File("../PSNBooster.sln")); // solution file [src/PsnBooster.UI/PSNBooster.sln]
var testProjectFile = MakeAbsolute(File($"{sourcesDir}/PsnBooster.Core.Tests/PsnBooster.Core.Tests.csproj")); // test project file [src/PsnBooster.Core.Tests/PsnBooster.Core.Tests.csproj]
var solutionOutput = MakeAbsolute(Directory($"{sourcesDir}/PsnBooster.UI/bin/{configuration}")); // the output folder for solution [src/PsnBooster.UI/bin/Release]

// tools
var advancedInstallerExecutable = File(@"tools\Advanced Installer 15.5.1\bin\x86\AdvancedInstaller.com"); // advanced installer path.
var advancedInstallerConfig = $"{buildRoot}/setup.aip"; // advanced installer setup config - [build/setup.aip]

// target filenames.
var targetInstallerFilename = "psnbooster-" + version.FullSemVer + ".zip"; // [psnbooster-x.y.z.zip]
var targetPortableFilename = "psnbooster-portable-" + version.FullSemVer + ".zip"; // [psnbooster-portable-x.y.z.zip]

// artifact directories.
var artifactsDir = MakeAbsolute(Directory("./artifacts/")); // base artifacts dir - [build/artifacts/]
var buildArtifactsDir = MakeAbsolute(Directory($"{artifactsDir}/release")); // artifacts directory for the build [build/artifacts/release]
var installerArtifactsDir = MakeAbsolute(Directory($"{artifactsDir}/setup")); // artifacts directory for the build - [build/artifacts/setup]

// release paths.
var releasesRoot = MakeAbsolute(Directory($"./releases/{(isStableBuild ? "stable" : "development")}"));
var installerReleaseDir = MakeAbsolute(Directory($"{releasesRoot}/installer/")); // the output directory for installer releases [build/releases/stable|development/setup]
var portableReleaseDir = MakeAbsolute(Directory($"{releasesRoot}/portable/")); // the output directory for portable releases [build/releases/stable|development/portable]
var installerReleaseFile = MakeAbsolute(File($"{installerReleaseDir}/{targetInstallerFilename}")); // the actual release file - [build/releases/psnbooster-x.y.z.zip]
var portableReleaseFile = MakeAbsolute(File($"{portableReleaseDir}/{targetPortableFilename}")); // the actual portable release file - [build/releases/psnbooster-portable-x.y.z.zip]

// amazons 3 config.
var s3ReleaseRoot = $"releases/{(isStableBuild ? "stable" : "development")}"; // s3 release root - [releases/stable|development/]
var s3InstallerFile = $"{s3ReleaseRoot}/installer/{targetInstallerFilename}"; // uploaded s3 file - [releases/stable|developemnt/psnbooster-x.y.z.zip]
var s3PortableFile = $"{s3ReleaseRoot}/portable/{targetPortableFilename}"; // uploaded s3 file - [releases/stable|development/psnbooster-portable-x.y.z.zip]
var s3BaseUrl = "https://s3.eu-central-1.amazonaws.com/cdn.psnbooster.com/";

// artifact files.
var artifactInstallerFile = MakeAbsolute(File($"{installerArtifactsDir}/psnbooster-setup.exe")); // the setup file - [build/artifacts/setup/psnbooster-setup.exe]
var artifactZippedInstallerFile = MakeAbsolute(File($"{installerArtifactsDir}/{targetInstallerFilename}")); // the zip that contains setup file - [build/artifacts/setup/psnbooster-x.y.z.zip]
var artifactPortableFile = MakeAbsolute(File($"{installerArtifactsDir}/{targetPortableFilename}")); // the portable zip file - [build/artifacts/setup/psnbooster-portable-x.y.z.zip]

// discord config
var discordWebhookUrl = "https://discordapp.com/api/webhooks/524146916922228736/_kbXfugpLoGfLAhIgwHQkUpoMPX8oZtnrot_ia1BMAvq6fuY6qYGJl6yBi-KbU-0w4bF";

// logs
var msbuildLogFile = artifactsDir.ToString() + "./msbuild.log"; // logs for MSBuild [build/artifacts/msbuild.log]

// TASKS

Setup(context =>
{
	Information($"starting build for version {version.FullSemVer}..");
	Information($"building a {(isStableBuild ? "stable" : "development")} release..");
	if(isWindowsBuild) 
	{
		Information("-------------------------------------------------------------------");
		Information($"target installer filename: {targetInstallerFilename}");
		Information($"target portable filename: {targetPortableFilename}");
		Information("-------------------------------------------------------------------");
		Information($"solution file: {solutionFile}");
		Information($"solution output: {solutionOutput}");
		Information("-------------------------------------------------------------------");
		Information($"release installer: {installerReleaseFile}");
		Information($"release portable: {portableReleaseFile}");
		Information("-------------------------------------------------------------------");
		Information($"build artifacts: {buildArtifactsDir}");
		Information($"installer artifacts: {installerArtifactsDir}");
		Information($"artifact installer: {artifactInstallerFile}");
		Information($"artifact zipped installer: {artifactZippedInstallerFile}");
		Information($"artifact portable: {artifactPortableFile}");
		Information("-------------------------------------------------------------------");
		Information($"s3 release installer: {s3InstallerFile}");
		Information($"s3 release portable: {s3PortableFile}");
		Information("-------------------------------------------------------------------");
		Information($"advanced installer path: {advancedInstallerExecutable}, using config: {advancedInstallerConfig}");
	} else {
		Information("skipping an installer build as we are not on windows..");
	}
});


Task("Clean")
    .Does(() =>
	{
		Information("cleaning artifact directories..");
		CleanDirectory(solutionOutput); // clean the solution output directory before a re-compile.

		if(!isWindowsBuild) return; // if we are building on windows, skip folder cleaning stuff for creating artifacts.
		CleanDirectory(artifactsDir); // clean the artifacts directory.
		if (!DirectoryExists(installerReleaseDir)) CreateDirectory(installerReleaseDir); // create the releases dir if not exists..
		if (!DirectoryExists(portableReleaseDir)) CreateDirectory(portableReleaseDir); // create the releases dir if not exists..
		if (FileExists(installerReleaseFile)) DeleteFile(installerReleaseFile); // remove the release file if exists already.
		if (FileExists(portableReleaseFile)) DeleteFile(portableReleaseFile); // remove the release file if exists already.
		CreateDirectory(buildArtifactsDir); // create the artifact release dir.
		CreateDirectory(installerArtifactsDir); // create the artifact setup dir.
	});

Task("Restore")
    .IsDependentOn("Clean")
    .Does(() =>
	{
		// restore dotnet project's packages.
		DotNetCoreRestore(solutionFile.ToString(), new DotNetCoreRestoreSettings
		{
			NoCache = true,
			Verbosity = DotNetCoreVerbosity.Normal
		});
	
		if(!isWindowsBuild) return; // only restore .net packages on windows builds.

		// restore .net project's packages.
		NuGetRestore(solutionFile.ToString(), new NuGetRestoreSettings 
		{ 
			NoCache = true,
			Verbosity = NuGetVerbosity.Normal
		});
	});

Task("Build")
    .IsDependentOn("Restore")
    .Does(() =>
	{
		if(isWindowsBuild)
		{
		  // on windows host, build using msbuild.
		  MSBuild(solutionFile.ToString(), settings => {
				settings.Verbosity = Verbosity.Minimal;
				settings.ToolPath = msBuildPathX64;
				settings.ToolVersion = MSBuildToolVersion.VS2017;
				settings.SetConfiguration(configuration);
				settings.AddFileLogger(new MSBuildFileLogger {
					LogFile = msbuildLogFile,
					MSBuildFileLoggerOutput = MSBuildFileLoggerOutput.All   
				});
			});
		}
		else
		{
			// else on *nix, use dotnet core.
			DotNetCoreBuild(testProjectFile.ToString(), new DotNetCoreBuildSettings {
				Configuration = configuration,
				Verbosity = DotNetCoreVerbosity.Minimal
			});

			// on linux / macos, use xbuild (mono)
			// XBuild(solutionFile.ToString(), settings => settings.SetConfiguration(configuration));
		}
	});

Task("Test")
    .IsDependentOn("Build")
    .Does(() =>
	{			
		DotNetCoreTest(solutionFile.ToString(), new DotNetCoreTestSettings { // run donet core tests.
			ArgumentCustomization = args => args.Append("--logger \"trx;LogFileName=TestResults.xml\"") // output test results as XML so that VSTS can pick it up
		});
	});

Task("Artifacts")
	.WithCriteria(isWindowsBuild == true) // skip building an installer on *nix based system.
    .IsDependentOn("Test")
    .Does(() =>
	{	
		// copy release files.
		var extensions = new string[] { ".exe", ".dll", ".yml", ".config" }; // file extensions to copy.
		var files = GetFiles(solutionOutput.ToString() + "/**/*.*").Where(f => extensions.Contains(f.GetExtension().ToLower())); // get the files.
		CopyFiles(files, buildArtifactsDir, true); // copy them to release dir.

		// create the portable zip.
		Information($"creating portable release file: {targetPortableFilename}..");
		var releaseFiles = GetFiles(buildArtifactsDir + "/**/*.*");
		Zip(buildArtifactsDir, artifactPortableFile, releaseFiles);
		// copy the output zip file to actual release directory.
		CopyFiles(artifactPortableFile.ToString(), portableReleaseDir);		

		// build installer package.
		Information($"creating zipped installer release file: {targetInstallerFilename}.. ");
		var setVersion = StartProcess(advancedInstallerExecutable, "/edit " + advancedInstallerConfig + " /SetVersion " + version.MajorMinorPatch); // set installer version.
		var buildInstaller = StartProcess(advancedInstallerExecutable, @"/build " + advancedInstallerConfig); // build the installer.	
		Zip(installerArtifactsDir, artifactZippedInstallerFile.ToString(), artifactInstallerFile.ToString()); // create the setup zip.

		// copy the output zip file to actual release directory.
		CopyFiles(artifactZippedInstallerFile.ToString(), installerReleaseDir);		
	});

Task("Upload")
	.WithCriteria(isWindowsBuild == true && !isLocal) // skip artifact uploads on *nix based systems & local builds. 
    .IsDependentOn("Artifacts")
    .Does(async () =>
	{		
		// upload the portable release file.
		Information($"uploading portable release: {targetPortableFilename}..");
		await S3Upload(portableReleaseFile, s3PortableFile,
			new UploadSettings()
				.SetAccessKey("S3KEY")
				.SetSecretKey("S3SECRET")
				.SetRegion("eu-central-1")
				.SetBucketName("bucket")
				.SetCannedACL(S3CannedACL.PublicRead));		

		// upload the installer release file.
		Information($"uploading setup release: {targetInstallerFilename}..");
		await S3Upload(installerReleaseFile, s3InstallerFile,
			new UploadSettings()
				.SetAccessKey("S3KEY")
				.SetSecretKey("S3SECRET")
				.SetRegion("eu-central-1")
				.SetBucketName("bucket")
				.SetCannedACL(S3CannedACL.PublicRead));

		var portableFileUrl = $"{s3BaseUrl}{s3PortableFile}";
		var installerFileUrl = $"{s3BaseUrl}{s3InstallerFile}";
	});

Teardown(context =>
{
		Information($"build done for version {version.FullSemVer}..");
		if(isAzurePipelines) TFBuild.Commands.UpdateBuildNumber(version.FullSemVer);
});


// Targets

Task("Default")
	.IsDependentOn("Clean")
	.IsDependentOn("Restore")
	.IsDependentOn("Build")
    .IsDependentOn("Test")
	.IsDependentOn("Artifacts")
	.IsDependentOn("Upload");

// Execution.

RunTarget(target);

from cake.aws.s3.

mabead avatar mabead commented on August 21, 2024

I had the same issue, I resolved it by using #addin nuget:?package=Cake.AWS.S3&version=0.6.8&loaddependencies=true (note the loaddependencies option). I think that the README should be modified to reflect this.

from cake.aws.s3.

SharpeRAD avatar SharpeRAD commented on August 21, 2024

I've updated the ReadMe to mention the loaddependencies option 👍

from cake.aws.s3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.