0

So when I build my solution in VS2017, everything works great. I'm getting started with Cake Build and I'm running into issues.

When running .\build.ps1 I end up with the error

Program.cs(19,30): error CS0246: The type or namespace name 'Accounts' could not be found (are you missing a using directive or an assembly reference?)

It's as if project references are not resolving. Does anyone have any suggestions? Below is my cake.build file

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");

//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////

// Define directories.
var solutions = GetFiles("./**/*.sln");

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

Task("Clean")
    .Does(() =>
{
    var solutionPaths = solutions.Select(solution => solution.GetDirectory());
    foreach(var path in solutionPaths)
    {
        Information("Cleaning {0}", path);
        CleanDirectories(path + "/**/bin");
        CleanDirectories(path + "/**/obj");
    }
});

Task("Restore")
    .IsDependentOn("Clean")
    .Does(() =>
    {
        foreach(var solution in solutions)
        {
            Information("Restoring {0}...", solution);
            NuGetRestore(solution);
        }
    });

Task("Build")
    .IsDependentOn("Restore")
    .Does(() =>
    {
        foreach(var solution in solutions)
        {
            Information("Building {0}...", solution);
            if(IsRunningOnWindows()) // Use MSBuild
                MSBuild(solution, new MSBuildSettings {
                    Configuration = configuration,
                    Verbosity = Verbosity.Minimal
                });
            else // Use XBuild
                XBuild(solution, settings => settings.SetConfiguration(configuration));
        }
    });

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////

Task("Default")
    .IsDependentOn("Build");

//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////

RunTarget(target);
Gonkers
  • 1,971
  • 2
  • 10
  • 9
  • I have confirmed that when I remove one of the project references I have and reference it as a nuget package Cake builds just fine. I'm still a little perplexed as to why that is though. – Gonkers Aug 24 '17 at 19:22
  • 1
    When you are building in VIsual Studio, are you building with Release Configuration? Your Cake Script is defaulting to Release Configuration, which might explain why you are seeing a difference in behaviour. – Gary Ewan Park Aug 25 '17 at 08:11
  • Maybe take a look at flubu which is a nice alternative to cake. Flubu is A C# library for building projects and executing deployment scripts using C# code. More at: https://github.com/flubu-core/flubu.core/wiki – Stan88 Sep 28 '17 at 08:45

0 Answers0