Can the load directive in CAKE be used on an additional file?

In the cake script, when using the load directive (#load), can this be optional? If the referenced file does not exist, I do not want the CAKE script to return an exception.

The documentation refers to the use of '?' to try to download, but even with this I get exceptions if the file does not exist.

#load "local:?path=properties.cake"; 

But in the output, I get an error:

 Analyzing build script... Error: Could not find script 'C:/projects/my-project/properties.cake'. 

The CAKE script is common to many projects, only some of which will have an additional file, hence the question.

thanks

+7
source share
2 answers

There is currently no way to further download the script, but feel free to create a problem for this at https://github.com/cake-build/cake .

? doesn’t indicate a download attempt, it’s just a query string delimiter The #load preprocessor #load is a URI with an optional #load for backward compatibility with older versions of Cake.

+5
source

You can solve this problem by providing an empty /default.cake in the build.ps1 script like this.

 if (!(Test-Path "properties.cake")) { Write-Host "First run! Generating properties.cake..." Copy-Item "properties.cake.default" -Destination ".\properties.cake" } # Build Cake arguments $cakeArguments = @("$Script"); (...) 

Then you need to commit the properties.cake.default file in your script!

0
source

Source: https://habr.com/ru/post/1270492/


All Articles