Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Pascal Berger
@pascalberger
Question 3: NuGet package. You can distribute .cake files as NuGet packages. It's what we call Recipe NuGet packages
Pascal Berger
@pascalberger

Question 2:

  • Code of a certain complexity I often have in an addin, where any existing testing framework can be used.
  • I normally work with recipe scripts (e.g. Cake.Recipe for OSS stuff) which contain most of the complexity and leave nearly no logic in repo build scripts

So my use cases for something you suggested are mainly for testing of the recipe scripts, where I see two main use cases:

  1. Unit testing of helper classes. Features required there is an assertion framework and the possibility to fail build script at the end
  2. Integration tests. I normally implement them by adding a separate test Cake script which uses the NuGet package built. Here is an example for Cake.Issues.Recipe.
    This allows to create a build pipeline which tests the actual package on different platforms, build servers, runners (e.g. here is the Azure Pipeline for the above script).
    The example above tests "only" calling the functionality of the recipe script, but doesn't currently tests the outcome or fails the test if outcome is not like the expected result.
    To implement tests here I would look for the same features as for point 1.
CharliePoole
@CharliePoole

@pascalberger Thanks for the feedback.

I was aware of Cake.Recipe, which is a much bigger set of scripts than I cared to deal with, but not of the possibility to have individual recipe nuget packages. So I'll look into that for sure.

CharliePoole
@CharliePoole

It's interesting that my own greatest need for this has come in testing extensions to the NUnit engine, where I don't want to write a test host to simulate completely the behavior of NUnit console and it's engine in calling the extension, because that's complex and error-prone and will need to be modified any time the engine is changed. But others would no doubt find different uses.

Anyway, I'm thinking that making it available to folks is the best way to find out what those uses are.

I'll move this to the GitHub discussions as you suggest.

Marek Pavlu
@ipavlu

Hi, I am trying Cake.AzureDevOps, trying to get pull request:
var pullRequestSettings =
new AzureDevOpsPullRequestSettings(
new Uri("http://myazuredevops/DefaultCollection/project/_git/CoreServices"),
"refs/heads/master",
AzureDevOpsAuthenticationNtlm());

var pullRequest =
AzureDevOpsPullRequest(
pullRequestSettings);

here it fails:
Error: System.AggregateException: One or more errors occurred. (Pull request not found)
---> Cake.AzureDevOps.Repos.PullRequest.AzureDevOpsPullRequestNotFoundException: Pull request not found

Please tell me, somebody, what am I horribly not realizing /missing? :).
Thanks...

Nils Andresen
@nils-a
@ipavlu I think Cake.AzureDevOps has some fair logging. Have you tried running with --verbosity=diagnostic?
Tanner Watson
@tannerwatson
Forgive my ignorance regarding python and pip. Do you think it would be possible to develop a pip module that would work similarly to the Cake.Npm.Module and Cake.Chocolatey.Module? I would think so, but not sure if there would be any gotchas with dependencies and such
bravecobra
@bravecobra
Hi, I'm trying to get reading and writing to the windows registry working through a Cake script. Anybody got an example?
I want to read from HKEY_CURRENT_USER
C. Augusto Proiete
@augustoproiete

@bravecobra Indeed, HKCU is not exposed in IRegistry and WindowsRegistryKey is internal which makes it harder for you to create your own reference to HKCU using IRegistryKey.

You'll have to use the Registry classes directly from Microsoft.Win32.Registry instead of using the Cake abstraction.

C. Augusto Proiete
@augustoproiete
@bravecobra cake-build/cake#3024
bravecobra
@bravecobra
@augustoproiete tnx for opening that issue. For now I can get away with reg.exe import, but being able to do that directly from Cake would be better. I'll await the implementation, which I guess won't be too hard.
Pascal Berger
@pascalberger

@ipavlu The source branch in the AzureDevOpsPullRequestSettings seems to be wrong:

var pullRequestSettings =
new AzureDevOpsPullRequestSettings(
new Uri("http://myazuredevops/DefaultCollection/project/_git/CoreServices"),
"refs/heads/master",
AzureDevOpsAuthenticationNtlm());

refs/heads/master needs to be the branch which you want to merge with the pull request (feature/topic branch), not the target branch.

C. Augusto Proiete
@augustoproiete

@bravecobra You're welcome. You absolutely can use Cake to interact with the Registry... You just can't use the Cake abstraction to it (yet) for your use-case.

Using the .NET classes directly should work just fine e.g.

using Microsoft.Win32;

var hkcu = Registry.CurrentUser;
var subKeyNames = hkcu.GetSubKeyNames();
foreach (var name in subKeyNames)
{
    Information("Key name: {0}", name);
}
C. Augusto Proiete
@augustoproiete

@tannerwatson :point_up: January 5, 2021 4:00 PM It should be fairly easy to implement a module for Pip similar to the Npm one if you take the same approach as the Npm module of executing Pip via ProcessRunner. In that case the only dependency you'll have is Python/Pip, which users might already have on the machine, or you can instruct users to download Python from NuGet as a tool e.g.

#module nuget:?package=Cake.Pip.Module&version=x.y.z
#tool "nuget:?package=python&version=3.9.1"
#tool "pip:?package=setuptools&version=49.2.1"

// ...

Alternatively you can implement the Pip protocol yourself - which would be more elegant, but with more work involved.

Calvin Dallmore
@aeos
I might be doing this wrong, but I noticed that if you upgrade a reference in your cake build script context.Tools.Resolve(string) may find the tool from the previous version which still exists in the tools folder. Should we always clear out the tools directory before changing a package reference?
Mattias Karlsson
@devlead
Are you fetching tools using tool preprocessor directive? Think tool directive should register binaries for right version, but quite possible having multiple versions of same tool potentially causing issues.
Calvin Dallmore
@aeos
I might be abusing the feature. I have a docker template that I include as a nuget package, and then look for it using resolve in a build step.
C. Augusto Proiete
@augustoproiete

I might be doing this wrong, but I noticed that if you upgrade a reference in your cake build script context.Tools.Resolve(string) may find the tool from the previous version which still exists in the tools folder. Should we always clear out the tools directory before changing a package reference?

@aeos I ran a few tests just now and was not able to reproduce it. This is what I've done:

tools1.cake:

#tool "nuget:?package=python&version=3.9.1"

var pythonExePath = Context.Tools.Resolve("python.exe");

var exitCode = StartProcess(pythonExePath, "--version");
Information("Exit code: {0}", exitCode);

tools2.cake:

#tool "nuget:?package=python&version=3.10.0-a4&prerelease"

var pythonExePath = Context.Tools.Resolve("python.exe");

var exitCode = StartProcess(pythonExePath, "--version");
Information("Exit code: {0}", exitCode);
Using dotnet tool 1.0.0-rc0002, I get the correct tools executed:
dotnet cake tools1.cake --verbosity=Diagnostic
Executing: "C:/augustoproiete/cake-tool-1-0-0--rc0002/tools/python.3.9.1/tools/Lib/venv/scripts/nt/python.exe" --version
dotnet cake tools2.cake --verbosity=Diagnostic
Executing: "C:/augustoproiete/cake-tool-1-0-0--rc0002/tools/python.3.10.0-a4/tools/Lib/venv/scripts/nt/python.exe" --version
Nils Andresen
@nils-a
@augustoproiete could you test that with 3.8. and 3.9. - I think 3.10 could come up lexicographically before 3.9...
C. Augusto Proiete
@augustoproiete
I ran tools1 and tools2 multiple times, and in different orders.
@nils-a Sure. Will do
tools3.cake
#tool "nuget:?package=python&version=3.8.7&prerelease"

var pythonExePath = Context.Tools.Resolve("python.exe");

var exitCode = StartProcess(pythonExePath, "--version");
Information("Exit code: {0}", exitCode);
dotnet cake tools3.cake --verbosity=Diagnostic
Executing: "C:/augustoproiete/cake-tool-1-0-0--rc0002/tools/python.3.8.7/tools/Lib/venv/scripts/nt/python.exe" --version
No pyvenv.cfg file
Works as expected...
image.png
All 3 packages are there on the tools folder:
I can run any 3 cake scripts in any other, and always get the .exe of the correct version
Nils Andresen
@nils-a
@augustoproiete thanks for testing that. In my head I was thinking we're searching for the tool (hence the lexicographic idea). But @devlead had commented on that earlier: We're registering the the contents of the installed package when the #tool directive is used. That registry is queried first.
C. Augusto Proiete
@augustoproiete
@nils-a Right. That's what I had in mind too. Assuming there was a bug, I was expecting the tool to always resolving to 3.10 assuming it was doing a simple string order by in the paths, but that's not the case. Let's see if @aeos can come up with a repro
Darrell
@DTTerastar
I tested my stuff on 1.0rc0001 and rc0002 and the lack of Arguments.GetArgument is a big blocker: Error: System.AggregateException: One or more errors occurred. (Method not found: 'System.String Cake.Core.ICakeArguments.GetArgument(System.String)'.)
---> System.MissingMethodException: Method not found: 'System.String Cake.Core.ICakeArguments.GetArgument(System.String)'.
at Cake.Utils.Prompt.PromptAliases.ArgumentT
at Submission#0.ArgumentT
The fact 0.38 and 0.37 don't have a GetArguments also means I can't use start using that or else my addon will fail on that version.
Would a PR with a GetArgument being a call to GetArguments().SingleOrDefault() be met w/ happiness or disdain? It can be Obsolete from the start.
Darrell
@DTTerastar
nm, moved to github discussion
C. Augusto Proiete
@augustoproiete
Tanner Watson
@tannerwatson
@augustoproiete thank you! (regarding a pip module) and sorry for the late reply. I'll give it a shot over the weekend
norgie
@norgie
bilde.png
Hi.
Has anyone come across this? If so, how did you solve it? If not, any suggestions as to how I can resolve it?
Nils Andresen
@nils-a
@norgie have you seen cake-build/cake#1904 ?
also, are you aware that we're currently moving away from gitter and into https://github.com/cake-build/cake/discussions/ ? ;-)
norgie
@norgie
@nils-a cake#1904 is interesting given that this project is the only one that fails while the other projects who are also using Cake work as expected.
As for moving to cake\discussions on github. Thx for the heads-up.
We've also been using Cake since early days and never encountered this error before.
norgie
@norgie
Adding [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12did indeed solve the issue. Strange that we haven't encountered this before.
Marek Pavlu
@ipavlu
Hi, Cake Modules, I created one, installed it simple way, also through private nuget feed.z