Search code examples
c#.netcakebuild

I got an error when I'm trying to build my project using Cake


When I try to build I getting the follow error. Why Cake doesn't build my project?

What should I do? Does anyone know what need to do?

The 'addin' directive is attempting to install the 'Cake.Powershell' package 
without specifying a package version number.  
More information on this can be found at https://cakebuild.net/docs/tutorials/pinning-cake-version 
It's not recommended, but you can explicitly override this warning 
by configuring the Skip Package Version Check setting to true 
(i.e. command line parameter "--settings_skippackageversioncheck=true", 
environment variable "CAKE_SETTINGS_SKIPPACKAGEVERSIONCHECK=true", 
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)
Error: One or more errors occurred.
    Object reference not set to an instance of an object.
Process terminated with code 1.

Cake: https://cakebuild.net/


Solution

  • You should check which version of the package is the latest on NuGet https://www.nuget.org/packages/Cake.Powershell

    When writing this it's 0.4.8

    Then in your addin directive you should adjust so it includes version i.e. if you now have

    #addin nuget:?package=Cake.Powershell
    

    or

    #addin "Cake.Powershell"
    

    You should change that to

    #addin nuget:?package=Cake.Powershell&version=0.4.8
    

    Pinning version ensures reproducible builds as you know you'll be using same version of dependencies each build.

    If you go to the url in the error messsage ( https://cakebuild.net/docs/tutorials/pinning-cake-version ) you'll find more info about this.

    The Object reference not set to an instance of an object. is hard to know the exact cause of, but running Cake with diagnostic verbosity would provide more detail. You achieve this by adding the verbosity parameter.

    --verbosity=Diagnostic
    

    If it's addin releated you could deleting the tools folder, by default it's located next the script your executing.