Search code examples
powershellcakebuild

Can't load cake module - Preprocessor directive expected


I'm trying to run a cake build script that loads a module for long file path but it only returns error CS1024: Preprocessor directive expected

In the cake file I have added #module nuget:?package=Cake.LongPath.Module&version=0.5.0 and this is the line where I get the error at (1,2)

In the docs It states that this is the format and that I should run the script with --bootstrap before actually running the script. Running Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" --bootstrap" causes a the error and then I also get it on the line after when running it without the --bootstrap flag.

What I need is to make sure that Cake.LongPath module is installed and loaded in CI. Any thoughts on other solutions would also be helpful


Solution

  • The --bootstrap command was only added in Version 0.24.0 of Cake. You can see the release notes here:

    https://github.com/cake-build/cake/releases/tag/v0.24.0

    And the issue that it was worked on here:

    https://github.com/cake-build/cake/issues/1950

    I am fairly sure that this issue will be solved by upgrading to a newer version of Cake. This can be done by changing the version number in the packages.config file, and by clearing out the tools folder. NOTE: Depending on what version of the bootstrapper you are using, the clearing out of the tools folder may be done for you automatically.