cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.92k stars 729 forks source link

A Newbie to using cake build. #851

Closed nsingh03 closed 8 years ago

nsingh03 commented 8 years ago

Hi there, first of all not really sure if posting the issue in the correct forum or not, so apology in advance., but this is the only place I can find on the whole internet to get my clarifications addressed regarding cake-build

thanks in advance for help.

devlead commented 8 years ago

Hi @nsingh03,

No worries, happy to assist.

You find our documentation on http://cakebuild.net The Getting Started is a good place to start. Under the DSL documentation many of the aliases has sample code on how they're just. If you find any issues with Cake or it's documentation, raising an issue here is correct way to go. We also have a Gitter chat room at https://gitter.im/cake-build/cake where you can get help from the Cake community .

If anything specific still is unclear ping us here in the issue, or close it if you found what you needed.

nsingh03 commented 8 years ago

Thanks for your patience. I would need tons of help really before can re-create/migrate our entire wise based installer to cake build. So anytime I am really stuck is this the correct forum I can paste the query or somewhere else ? , it might not be an actual issue but the learning curve while working on cake build

Secondly "https://gitter.im/cake-build/cake " is not opening. Is this the correct URL for chat ?

Also right now we are creating .MSI packages for our deployments using wise. The same deployment script can be created using cakebuild I assume ?

Also there is a visual studio integration ofr cakebuild ? Is it stable enough to create deployment scripts ?

devlead commented 8 years ago

Gitter link should work but you could also try this button Join the chat at https://gitter.im/cake-build/cake

@gep13 recently did a presentation, slides and sample code are at https://github.com/gep13/CakeDemos

Me and @gep13 also recently was on the MSDevShow Podcast, where we go thru some features and limitations of Cake, you can find that episode here: http://msdevshow.com/2016/04/cakebuild-with-mattias-karlsson-and-gary-ewan-park/

For creating installation we have som WiX aliases: http://cakebuild.net/dsl/wix See that those aren't very well documented, but basically if you're using WiX for your installs today it wraps those tools.

If you're using NSIS for your installers those aliases are documented here: http://cakebuild.net/dsl/nsis

Don't have any public sample project of those perhaps @patriksvensson or @vktr has that authored those aliases.

I personally use Sublime (with C# highlighting .cake files) or VSCode (there's an extension avail here that gives you syntax highlighting) to author my scripts, there's no extension for Visual Studio available yet.

vktr commented 8 years ago

I don't have any sample Cake+WiX projects, but here's the relevant bits from my script,

WiXCandle("./installer/CoolProject.wxs", new CandleSettings
{
    Architecture = arch,
    Defines = new Dictionary<string, string>
    {
        { "Configuration", configuration },
        { "Platform", platform },
        { "Version", Version }
    },
    OutputDirectory = BuildDirectory
});

WiXLight(BuildDirectory + File("CoolProject.wixobj"), new LightSettings
{
    OutputFile = BuildDirectory + File(Installer)
});

You'll need a dependency on the WiX.Toolset package for this to work.

devlead commented 8 years ago

Thanks @vktr :+1:

jrgcubano commented 7 years ago

Take me a bit to find some good example to use cake with wix. Finally I find my self looking this issue and the tests files...

For my use case, I converted my project from "build.proj" to "cake"

Thanks @vktr @nsingh03 @devlead

build.proj

 <!-- Installer -->
  <Target Name="Installer" DependsOnTargets="InstallerTransform">
    <!--MSI-->
    <Exec Command="&quot;$(WixPath)\heat.exe&quot; dir &quot;$(DirOut)\Files&quot; -dr WinhotelProgramDir -ke -srd -cg ProductComponents -var var.publishDir var.Version var.SemVersion -gg -out ..\Installer\PMS_UI.Installer\$(WixContentCode) -sreg -scom"
          ContinueOnError="false"
          WorkingDirectory="." />

    <Exec Command="&quot;$(WixPath)\candle.exe&quot; -dpublishDir=&quot;$(DirOut)\Files&quot; -dVersion=&quot;$(Version)&quot; -dSemVersion=&quot;$(SemVersion)&quot; -dWinhotelResourceDir=. @(WixCode, &apos; &apos;)"
          ContinueOnError="false"
          WorkingDirectory="..\Installer\PMS_UI.Installer" />

    <!--<Exec Command="&quot;$(WixPath)\light.exe&quot; -ext WixUIExtension -cultures:$(Culture) -out $(MsiOut) @(WixObject, &apos; &apos;)"-->
    <Exec Command="&quot;$(WixPath)\light.exe&quot; -ext WixUIExtension -cultures:$(Cultures) -loc .\Product_$(Cultures).wxl -out $(MsiOut) @(WixObject, &apos; &apos;)"
        ContinueOnError="false"
        WorkingDirectory="..\Installer\PMS_UI.Installer" />

    <!--<Delete Files="@(WixObject)" />-->
    <Message Text="Installer has been created." />
  </Target>
  <!--End Installer-->

build.cake

#addin "Cake.FileHelpers"
#tool "nuget:?package=WiX.Toolset"

var target = Argument<string>("target", "Default");
var configuration = Argument<string>("Configuration", "Debug");
var targetEnvName = Argument<string>("targetEnvName", "Dev");
var semVersion = Argument<string>("targetVersion", "1.3.4");
var version = semVersion + "." + (EnvironmentVariable("TEAMCITY_BUILD_NUMBER") ?? "0");
var publishDir = "./output/" + targetEnvName;
var publishFilesDir = publishDir + "/Files";
var msiPath = publishDir + "/pms-setup-" + semVersion + ".msi";
var zipPath = publishDir + "/pms-" + semVersion + ".zip";
...

Task("Installer")
    .IsDependentOn("Publish")
    .Does(() =>
    {
        var installerPath = "../Installer/PMS_UI.Installer";

        var contentWxs = installerPath + "/ProjectContent.wxs";
        WiXHeat(publishFilesDir, contentWxs, WiXHarvestType.Dir, new HeatSettings
        {
            DirectoryReferenceId  = "WinhotelProgramDir",
            KeepEmptyDirectories = true,
            SuppressRootDirectory = true,
            ComponentGroupName = "ProductComponents",
            GenerateGuid = true,
            SuppressRegistry = true,
            SuppressCom = true,
            ArgumentCustomization = args=>args.Append("-var var.publishDir var.Version var.SemVersion")
        });

        var wxsFiles = GetFiles(installerPath + "/*.wxs");
        WiXCandle(wxsFiles, new CandleSettings
        {
            // Architecture = arch,
            WorkingDirectory = installerPath,
            Defines = new Dictionary<string, string>
            {
                { "publishDir", publishFilesDir },
                //{ "Configuration", configuration },
                //{ "Platform", platform },
                { "Version", version },
                { "SemVersion", semVersion },
                { "WinhotelResourceDir", "." }
            },
        });

        var wobjFiles = GetFiles(installerPath + "/*.wixobj");
        var culture = "en-us";
        var prodCulturePath = installerPath + "/Product_" + culture + ".wxl";
        WiXLight(wobjFiles, new LightSettings
        {
            Extensions = new[] { "WixUIExtension" },
            RawArguments = "-cultures:" + culture + " -loc " + prodCulturePath,
            OutputFile = msiPath
        });

    });