Cake: Use new Setup defintion

Created on 25 May 2016  路  15Comments  路  Source: cake-build/cake

To remove this warning:

image

Build

Most helpful comment

@mholo65 I can verify on OS X.

All 15 comments

@gep13 this requires v0.12.0 which has the needed bits in Mono code generation too.

@devlead sorry, not sure I follow?!?

Only the obsoleted method is avail on mono, the new method wasn't avail on mono. It's sorted in the newly released version just have to make sure we run it.

Perhaps we should introduce some logic in bootstrapper to ensure all's updated, as we use package.config for Cake it wont update if package is already installed.

@devlead ah, I see what you mean. I have updated the packages.config file to install 0.12.0, however, you are right, if it is already in the tools folder, then the latest version won't be installed.

however, you are right, if it is already in the tools folder, then the latest version won't be installed.

@gep13 that's why you should alter your bootstrapper to check for md5sum on packages.config...

here's what I'm using:

$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"

...

# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent)
{
    # Restore packages from NuGet.
    Push-Location
    Set-Location $TOOLS_DIR

    # Check for changes in packages.config
    if(Test-Path $PACKAGES_CONFIG_MD5)
    {
        if((Get-FileHash -Path $PACKAGES_CONFIG -Algorithm MD5).Hash -ne (Get-Content $PACKAGES_CONFIG_MD5))
        {
            Write-Verbose -Message "MD5 Sum changed. Removing nuget packages."
            Remove-Item * -Recurse -Exclude packages.config,nuget.exe
        }
    }
    else
    {
        Write-Verbose -Message "MD5 Sum not present. Removing nuget packages."
        Remove-Item * -Recurse -Exclude packages.config,nuget.exe
    }

    Write-Verbose -Message "Restoring tools from NuGet..."
    $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
    Write-Verbose -Message ($NuGetOutput | out-string)

    (Get-FileHash -Path $PACKAGES_CONFIG -Algorithm MD5).Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"

    Pop-Location
    if ($LASTEXITCODE -ne 0)
    {
        exit $LASTEXITCODE
    }
}

@mholo65 interesting.

@devlead @patriksvensson what are your thoughts on the above? Should we add this also to the default bootstrapper file?

@mholo65 @devlead @gep13 Yes, I think this would make an excellent addition to the bootstrapper.

@mholo65 so, now the next question...

Have you got a sample of doing the same thing within the build.sh file?

@gep13 nope, but it shouldn't be too hard. I can implement both ps1 and sh and test on Windows + Linux if someone else can verify on Mac..

@mholo65 I can verify on OS X.

One _crazy_ idea that would be xplat and not require hash files, would be to use a Cake script and use it's exit code if _"purge"_ should be done or not.

Such a script could look something like this

FilePath packagesConfig = File("./tools/packages.config");
if (!FileExists(packagesConfig))
{
    throw new FileNotFoundException("Package config was not found at ./tools/package.config");
}

var packageVersion = new Version(XmlPeek(packagesConfig, "/packages/package[@id='Cake']/@version") + ".0");

Information("Package: {0}", packageVersion);

var version = Context.GetType().Assembly.GetName().Version;
Information("Assembly: {0}", version);

var compare = version.CompareTo(packageVersion);

Information("Compare: {0}", compare);

if (compare!=0)
{
    throw new Exception("Version mismatch");
}
else
{
    Information("Versions match!");
}

On success it would output something like

> .\tools\Cake\Cake.exe .\validatepackageconfig.cake
Package: 0.12.0.0
Assembly: 0.12.0.0
Compare: 0
Versions match!

> $LASTEXITCODE
0

On version mismatch

> .\tools\Cake\Cake.exe .\validatepackageconfig.cake
Package: 0.12.1.0
Assembly: 0.12.0.0
Compare: -1
Error: Version mismatch
> $LASTEXITCODE
1

@devlead @gep13 @mholo65 Or we can just do like I've done in the Nancy project: https://github.com/patriksvensson/Nancy/blob/7299ce5be4d5e2839a64ba693a1d396322f06308/cake-build.ps1#L20

@devlead @gep13 @mholo65 But I think that @mholo65's solution would be a great contribution to the cake-build/resources repository :)

@devlead @gep13 @mholo65 Or we can just do like I've done in the Nancy project: https://github.com/patriksvensson/Nancy/blob/7299ce5be4d5e2839a64ba693a1d396322f06308/cake-build.ps1#L20

@patriksvensson but that would imply skipping package.config, which personally I wouldn't mind ;)

Drawback would be that you'll endup with loads of Cake versions after a while.

Was this page helpful?
0 / 5 - 0 ratings