Coder Social home page Coder Social logo

cake-contrib / cake.dotnettool.module Goto Github PK

View Code? Open in Web Editor NEW
3.0 6.0 3.0 120 KB

Cake.DotNetTool.Module is a Module for Cake, which extends it with a new IPackageInstaller for installing tools using the dotnet CLI.

License: MIT License

C# 97.61% PowerShell 1.24% Shell 0.65% CoffeeScript 0.50%
cake dotnet-tool dotnet cake-contrib cake-build cake-module

cake.dotnettool.module's Introduction

Cake.DotNetTool.Module

The Cake.DotNetTool.Module started out as an experiment to see how it would be possible to install .NET Tools using the Cake pre-processor directive. This experiment turned out to be a success, and as a result, this module has now been integrated into the main Cake repository.

Starting with Cake v1.1.0 this module will be released as part of the Cake release, as an official NuGet package under the same ID: Cake.DotNetTool.Module.

Moving forward issues about this module will be tracked on the main Cake repo.

As such, it will no longer be necessary to include the following:

#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0

In your cake scripts, as this will be done automatically. If you do still have this in your cake script, Cake will ignore it, and emit a warning, indicating that you should remove it going forward.

cake.dotnettool.module's People

Contributors

augustoproiete avatar gep13 avatar gitfool avatar jericho avatar jokay avatar prochnowc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cake.dotnettool.module's Issues

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • The nuget package for your addin should use the cake-contrib icon. Specifically, your addin's .csproj should have a line like this: <PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</PackageIconUrl>.

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.

This issue was created by a tool: Cake.AddinDiscoverer version 3.12.1

Initial Version

This should include the ability to install DotNet Tools, using the tool pre-processor.

Default installation location should be the Cake Tools folder, with the ability to override this with a global flag. It should also support the ability to specify the version number of the tool to install, as well as a source to get the tool from.

If version is specified it should check version and uninstall if differs

Currently if I change
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=4.0.1-beta1-53"
to
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=4.0.1-beta1-58"

It won't use the new version, and that's not what's expected when pinning a version.

Directory structure is

tools\.store\gitversion.tool\{version}

So if differs one should be able to run
dotnet tool uninstall --tool-path .\tools\ GitVersion.Tool and then install.

dotnet tool uninstall --tool-path .\tools\ GitVersion.Tool 
+ Tool 'gitversion.tool' (version '4.0.1-beta1-53') was successfully uninstalled.

dotnet tool install --tool-path .\tools\ --version="4.0.1-beta1-58" GitVersion.Tool
+ You can invoke the tool using the following command: dotnet-gitversion
+ Tool 'gitversion.tool' (version '4.0.1-beta1-58') was successfully installed.

Code for reference:

if(installedToolNames.Contains(package.Package.ToLowerInvariant()))
{
_log.Information("Tool {0} is already installed, so nothing to do here.", package.Package);
}

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • The nuget package for your addin should use the cake-contrib icon. Specifically, your addin's .csproj should have a line like this: <PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</PackageIconUrl>.

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.

This issue was created by a tool: Cake.AddinDiscoverer version 3.12.1

Could not find an installer for the 'dotnet' scheme.

Hi,

I've tried to reproduce step mentioned in blog

My cake file is:

#addin "nuget:?package=Cake.Npm&version=0.16.0"
#addin "nuget:?package=Cake.DependenciesAnalyser&version=2.0.0"
#addin "nuget:?package=Cake.Incubator&version=3.1.0"
#addin "nuget:?package=Cake.DotNetTool.Module&version=0.1.0"
#tool "dotnet:?package=Octopus.DotNet.Cli&version=4.41.0"

..

But when I try to run I get this error:

PS C:\projekte\cobino> .\build.ps1 --bootstrap
Preparing to run build script...
Running build script...

PS C:\projekte\cobino> .\build.ps1
Preparing to run build script...
Running build script...
Error: Could not find an installer for the 'dotnet' scheme.

Have I missed something?

Thx and best regards

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • The nuget package for your addin should use the cake-contrib icon. Specifically, your addin's .csproj should have a line like this: <PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</PackageIconUrl>.

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.

This issue was created by a tool: Cake.AddinDiscoverer version 3.12.1

Recommended changes resulting from automated audit

We performed an automated audit of your Cake addin and found that it does not follow all the best practices.

We encourage you to make the following modifications:

  • The nuget package for your addin should use the cake-contrib icon. Specifically, your addin's .csproj should have a line like this: <PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</PackageIconUrl>.

Apologies if this is already being worked on, or if there are existing open issues, this issue was created based on what is currently published for this package on NuGet.

This issue was created by a tool: Cake.AddinDiscoverer version 3.12.1

Add support for `--ignore-failed-sources` argument

When using private NuGet feeds dotnet tool install will fail because it cannot authenticate. It would be very nice to have the ability to simply ignore failed sources with the argument --ignore-failed-sources.

DotNetTool Module: Not using the same version of dotnet as Cake DotNetCoreTool

I'm running into an issue where the Cake DotNetCoreTool is not able to find the tool installed with this module. It looks like the underlying issue is due to Cake and this module using different versions of the dotnet cli tool.

Expected Behavior

The module and Cake use same dotnet cli version so I'm able to use the tool installed with this module.

Current Behavior

Log from my CAKE script:

Installing tools...
Configured Tools Folder: Z:/Teamcity/Work/3aedfc86eaf25d80/scripts/tools
Executing: "dotnet" tool list --global
Package Id               Version      Commands     
---------------------------------------------------
amazon.lambda.tools      4.0.0        dotnet-lambda
Adding tool amazon.lambda.tools
There are 1 dotnet tools installed
Checking for tool: amazon.lambda.tools
Tool Amazon.Lambda.Tools is already installed, with required version.
Tool Folder: C:/Windows/system32/config/systemprofile/.dotnet/tools/.store/amazon.lambda.tools
Found 10 files in tool folder
Executing: "C:/Program Files/dotnet/dotnet.exe" lambda package
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET Core program, but dotnet-lambda does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
Executing custom task teardown action (PackageLambda)...
An error occurred when executing task 'PackageLambda'.
Error: System.AggregateException: One or more errors occurred. ---> Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
   at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode)
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
   at Cake.Common.Tools.DotNetCore.Tool.DotNetCoreToolRunner.Execute(FilePath projectPath, String command, ProcessArgumentBuilder arguments, DotNetCoreToolSettings settings)
   at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreTool(ICakeContext context, FilePath projectPath, String command, ProcessArgumentBuilder arguments)
   at Submission#0.DotNetCoreTool(FilePath projectPath, String command, ProcessArgumentBuilder arguments) in :line 1058
   at Submission#0.<<Initialize>>b__0_0() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\Package.cake:line 92
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.<Does>b__0(ICakeContext x)
   at Cake.Core.CakeTask.<Execute>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.CakeEngine.<RunTask>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<RunTargetAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
   at Submission#0.<<Initialize>>d__0.MoveNext() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\build.cake:line 109
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()
---> (Inner Exception #0) Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1).
   at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode)
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
   at Cake.Common.Tools.DotNetCore.Tool.DotNetCoreToolRunner.Execute(FilePath projectPath, String command, ProcessArgumentBuilder arguments, DotNetCoreToolSettings settings)
   at Cake.Common.Tools.DotNetCore.DotNetCoreAliases.DotNetCoreTool(ICakeContext context, FilePath projectPath, String command, ProcessArgumentBuilder arguments)
   at Submission#0.DotNetCoreTool(FilePath projectPath, String command, ProcessArgumentBuilder arguments) in :line 1058
   at Submission#0.<<Initialize>>b__0_0() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\Package.cake:line 92
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass32_0.<Does>b__0(ICakeContext x)
   at Cake.Core.CakeTask.<Execute>d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.CakeEngine.<RunTask>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Cake.Core.CakeEngine.<RunTargetAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Cake.Core.Scripting.ScriptHost.RunTarget(String target)
   at Submission#0.<<Initialize>>d__0.MoveNext() in Z:\Teamcity\Work\3aedfc86eaf25d80\scripts\build.cake:line 109
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.CodeAnalysis.Scripting.Script`1.<RunSubmissionsAsync>d__21.MoveNext()<---

Steps to Reproduce (for bugs)

#module "nuget:?package=Cake.DotNetTool.Module&version=0.4.0"
#tool dotnet:?package=Amazon.Lambda.Tools&version=4.0.0&global

DotNetCoreTool(projectPath: projectPath, command: "lambda", arguments: "package");

Context

I'm unable to use this module to manage my global tools on our build server

Your Environment

	<package id="Cake" version="0.37.0" />

Installed executable not used

While trying to use a specific version of GitVersion on GitHub Actions, I noticed that it was installing but then using a different version.

NuGet.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <disabledPackageSources>
    <clear />
  </disabledPackageSources>
  <packageSources>
    <clear />
    <add key="gitversion" value="https://ci.appveyor.com/nuget/gitversion-8nigugxjftrw" />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  </packageSources>
</configuration>

bootstrap.cake:

#tool dotnet:?package=GitVersion.Tool&version=5.2.0-gh2139-1.352

Raw log from GitHub Actions job on Windows runner:

2020-03-01T20:21:22.8319656Z There are 0 dotnet tools installed
2020-03-01T20:21:22.8319989Z Checking for tool: gitversion.tool
2020-03-01T20:21:22.8324954Z Running dotnet tool with operation Install: GitVersion.Tool...
2020-03-01T20:21:22.8336066Z Executing: "dotnet" tool install "GitVersion.Tool" --tool-path "D:/a/build-cake/build-cake/tools" --version 5.2.0-gh2139-1.352 --verbosity diagnostic
2020-03-01T20:22:44.7671916Z Tool Folder: D:/a/build-cake/build-cake/tools/.store/gitversion.tool
2020-03-01T20:22:44.7807028Z Found 78 files in tool folder
...
2020-03-01T20:22:49.4737352Z Compiling build script...
2020-03-01T20:22:54.6783565Z Executing: "C:/ProgramData/Chocolatey/bin/GitVersion.exe" -output json -verbosity Debug

i.e. the specific version is installed into the Cake tools subdirectory but the version installed by Chocolatey in the Windows virtual environment is used instead. This does not happen in the Ubuntu or Mac virtual environments since GitVersion is not pre-installed there.

Relevant env vars:

ChocolateyInstall=C:\ProgramData\chocolatey
Path=C:\hostedtoolcache\windows\dncs\3.1.101\x64;C:/hostedtoolcache/windows\Python\3.6.8\x64;C:/hostedtoolcache/windows\Python\3.6.8\x64\Scripts;C:\Program Files\Mercurial\;C:\ProgramData\kind;C:\vcpkg;C:\cf-cli;C:\Program Files (x86)\NSIS\;C:\Program Files\Mercurial\;C:\hostedtoolcache\windows\Boost\1.72.0;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64\bin;C:\SeleniumWebDrivers\GeckoDriver;C:\Program Files (x86)\sbt\bin;C:\Rust\.cargo\bin;C:\hostedtoolcache\windows\Ruby\2.5.7\x64\bin;C:\Go1.12.7\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\hostedtoolcache\windows\Python\3.7.6\x64\Scripts;C:\hostedtoolcache\windows\Python\3.7.6\x64;C:\npm\prefix;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Docker;C:\Program Files\PowerShell\6\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;c:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\Subversion\bin;C:\SeleniumWebDrivers\ChromeDriver\;C:\SeleniumWebDrivers\EdgeDriver\;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.3\bin;C:\Program Files\CMake\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\OpenSSL\bin;C:\Users\runneradmin\.dotnet\tools;C:\Pro
USERPROFILE=C:\Users\runneradmin

Not sure but I would expect the tool path to explicitly use the Cake tools subdirectory.

DotNetTool Module: Add support for dotnet local tools

Note: I'm not sure this is a good idea and I'm currently stuck determining what the implementation looks like given local tools seem to be managed by the dotnet CLI.

I'll create a work-in-progress PR with how far I've got, including fixes for some minor bugs I found.

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.