Search code examples
.netpowershellwebformscakebuild

Configuring Environment Variables to resolve version mismatch while running cake script


I am new to the cake script. I am trying to run an existing cake script that is already developed. It is throwing following an error.

Cake.exe : Error: The assembly 'MagicChunks.Cake, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 
At line:1 char:1
+ & "Y:\Source\Repos\CI\tools\Cake\Cake.exe" "build.cake" -target="Defa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Error: The asse...KeyToken=null' :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

is referencing an older version of Cake.Core (0.23.0). 
This assembly must reference at least Cake.Core version 0.26.0. 
Another option is to downgrade Cake to an earlier version. 
It's not recommended, but you can explicitly opt out of assembly verification 
by configuring the Skip Verification setting to true
(i.e. command line parameter "--settings_skipverification=true", 
environment variable "CAKE_SETTINGS_SKIPVERIFICATION=true", 
read more about configuration at https://cakebuild.net/docs/fundamentals/configuration)

can anyone tell me where should I have to configure the environment variables to avoid above mentioned error?


Solution

  • NOTE: Corrected based on comments from @PascalBerger.

    MagicChunks.Cake is reaching back for a specific version of an assembly, but finding an newer version. You'd like to disregard the version check by leveraging the guidance:

    It's not recommended, but you can explicitly opt out of assembly verification by configuring the Skip Verification setting to true (i.e. command line parameter "--settings_skipverification=true", environment variable "CAKE_SETTINGS_SKIPVERIFICATION=true"

    You can set an environment variable a few different ways...

    ## Powershell
    [System.Environment]::SetEnvironmentVariable('CAKE_SETTINGS_SKIPVERIFICATION', 'true',[System.EnvironmentVariableTarget]::Machine)
    

    Using the Windows UI,

    1. Right-click the Windows menu (lower left of the screen).
    2. Select System from the context menu.
    3. Click the System Info link.
    4. Click the Advanced Settings link.
    5. On the Advanced tab, click Environment Variables...
    6. Add your environment variable.