cake-build / cake

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

DotNetCoreBuild .Net Core 2.0 not working with .Net Standard assemblies #2076

Open josephbaggett opened 6 years ago

josephbaggett commented 6 years ago

What You Are Seeing?

Here is my build.cake script:

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

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

var buildSettings = new DotNetCoreBuildSettings
     {
         Framework = "netcoreapp2.0",
         Configuration = "Release",
         OutputDirectory = "..\\.temp"
     };

///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////

Setup(ctx =>
{
    // Executed BEFORE the first task.
    Information("Running tasks...");
});

Teardown(ctx =>
{
    // Executed AFTER the last task.
    Information("Finished running tasks.");
});

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

Task("Default")
.Does(() => {
    Information("Hello Cake!");
});

Task("Restore")
    .Does(() => {
        Information("Restore!!!!");
        //DotNetCoreRestore();
        DotNetCoreRestore("..\\Neudesic.Neuledgebase.sln");
    });

Task("Build")
    .IsDependentOn("Restore")
    .Does(() => {
     Information("Build!!!!");
     DotNetCoreBuild("..\\Neudesic.Neuledgebase.sln", buildSettings);

});

RunTarget(target);

I'm seeing this error specifically for assemblies that are .Net Standard. I can run the dotnet build Neudesic.Neuledgebase.sln command manually, and I have no issues. Is there an issue with Cake not being compatible with .Net Core 2.0 yet? Why are there issues with .Net Standard assemblies?

What is Expected?

I'm expecting my solution to build.

What version of Cake are you using?

0.2.0.0 extension for Visual Studio version="0.26.1" for what got pulled down, which should be the latest

Are you running on a 32 or 64 bit system?

64 Bit system

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

This issue is happening on my local computer, I am going to be running on VSTS in the future.

How Did You Get This To Happen? (Steps to Reproduce)

I'm calling my bootstrapper and calling the Build task .\build.ps1 -Target "Build"

Output Log

PS J:\Neuledgebase\Neudesic.Neuledgebase.Build> .\build.ps1 -Target "Build"
Preparing to run build script...
Running build script...

----------------------------------------
Setup
----------------------------------------
Running tasks...

========================================
Restore
========================================
Restore!!!!
  Restore completed in 97.06 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Domain\Neudesic.Neuledgebase.Domain.csproj.
  Restore completed in 75.67 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Services\Neudesic.Neuledgebase.Services.csproj.
  Restore completed in 77.71 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Migrations\Neudesic.Neuledgebase.Migrations.csproj.
  Restore completed in 79.11 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj.
  Restore completed in 80.24 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Domain\Neudesic.Neuledgebase.Domain.csproj.
  Restore completed in 161.2 ms for J:\Neuledgebase\Neudesic.Neuledgebase.WebApi\Neudesic.Neuledgebase.WebApi.csproj.
  Restore completed in 91.67 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Web\Neudesic.Neuledgebase.Web.csproj.
  Restore completed in 156.7 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Web\Neudesic.Neuledgebase.Web.csproj.
  Restore completed in 187.13 ms for J:\Neuledgebase\Neudesic.Neuledgebase.WebApi\Neudesic.Neuledgebase.WebApi.csproj.

========================================
Build
========================================
Build!!!!
Microsoft (R) Build Engine version 15.4.8.50001 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Domain\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Domain\Neudesic.Neuledgebase.Domain.csproj]
C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Services\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Services\Neudesic.Neuledgebase.Services.csproj]
  Neudesic.Neuledgebase.Build -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Build.dll
C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj]
  Neudesic.Neuledgebase.Domain -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Domain.dll
  Neudesic.Neuledgebase.Web -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Web.dll
  Neudesic.Neuledgebase.Repositories -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Repositories.dll
  Neudesic.Neuledgebase.Migrations -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Migrations.dll
  Neudesic.Neuledgebase.Services -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.Services.dll
  Neudesic.Neuledgebase.WebApi -> J:\Neuledgebase\.temp\Neudesic.Neuledgebase.WebApi.dll

Build FAILED.

C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Domain\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Domain\Neudesic.Neuledgebase.Domain.csproj]
C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Services\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Services\Neudesic.Neuledgebase.Services.csproj]
C:\Program Files\dotnet\sdk\2.0.2\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(165,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj]
    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:17.57
[ERROR] Cake.exe : An error occurred when executing task 'Build'.
[ERROR] At J:\Neuledgebase\Neudesic.Neuledgebase.Build\build.ps1:234 char:1
[ERROR] + &$CAKE_EXE $cakeArguments
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR]     + CategoryInfo          : NotSpecified: (An error occurr...g task 'Build'.:String) [], RemoteException
[ERROR]     + FullyQualifiedErrorId : NativeCommandError
[ERROR]  

----------------------------------------
Teardown
----------------------------------------
Finished running tasks.
[ERROR] Error: 
[ERROR] One or more errors occurred.
[ERROR] 
[ERROR] 
[ERROR]     
[ERROR] .NET Core CLI: Process returned an error (exit code 1).
[ERROR] 
[ERROR] 

GIST LINK - Please create a gist and link to that gist here

OR

PLACE LOG CONTENT HERE
josephbaggett commented 6 years ago

I'm curious if I just have a misunderstanding with the command itself. I was hoping to call "dotnet build SolutionFile.sln" through cake. The issue is, when I point to the solution file doing the DotNetCoreBuild command like so, DotNetCoreBuild("SolutionFile.sln", settings), it errors on trying to build .Net Standard assemblies when I tried to call the solution.

I had to manually call specifically my .Net Core projects to build like so:

DotNetCoreBuild("..\Neudesic.Neuledgebase.Web\Neudesic.Neuledgebase.Web.csproj", buildSettings); DotNetCoreBuild("..\Neudesic.Neuledgebase.Migrations\Neudesic.Neuledgebase.Migrations.csproj", buildSettings); DotNetCoreBuild("..\Neudesic.Neuledgebase.WebApi\Neudesic.Neuledgebase.WebApi.csproj", buildSettings);

Am I thinking about this in the wrong way? Shouldn't I be able to point to the solution file and call a build command?

josephbaggett commented 6 years ago

Can I somehow call a one liner command like "dotnet build SolutionFile.sln" from a Cake task?

devlead commented 6 years ago

@josephbaggett Cake itself is a .NET standard/core 2.0 solution so it's certainly possible to build either solution or project.

I've created an example .NET Core project here: https://github.com/devlead/TestCakeDocker/tree/master/src

josephbaggett commented 6 years ago

Thanks for sharing, but I'm evaluating the differences as I'm still getting errors implementing it the same way, calling the solution directly. I am getting the errors from above. I have the latest .Net Core installed.

devlead commented 6 years ago

Your log above indicates SDK 2.0.2, 2.1.4 is the latest though.

https://github.com/dotnet/core/releases

josephbaggett commented 6 years ago

Gotcha... will recreate some of my assemblies with the latest again and test, will let you know.

josephbaggett commented 6 years ago

@devlead I went and uninstalled any old sdks, and reinstalled the latest, and re-created a new solution from scratch, and added .Net Core assemblies specifically to the solution. I was able to call the DotNetCoreBuild command and point to my solution. The problem occurred once I added a single .Net Standard assembly to the solution as well, then I was getting errors when DotNetCoreBuild was being called, which is my Neudesic.Neuledgebase.Repositories assembly. Why is this happening? What should I be doing? I installed 2.1.101 sdk from scratch with no other sdks on my system.

PS J:\Neuledgebase\Neudesic.Neuledgebase.Build> .\build.ps1 -Target "Package" Preparing to run build script... Running build script...


Setup

Running tasks...

======================================== Restore

Restore! Restore completed in 26.89 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj. Restore completed in 29.62 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Build\Neudesic.Neuledgebase.Build.csproj. Restore completed in 39.22 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. Restore completed in 77.08 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj.

======================================== Build

Build! Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 46.75 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Build\Neudesic.Neuledgebase.Build.csproj. Restore completed in 43.99 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj. Restore completed in 57.36 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. Restore completed in 88.55 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj] Neudesic.Neuledgebase.Build -> J:\Neuledgebase.build.temp\Neudesic.Neuledgebase.Build.dll Neudesic.Neuledgebase.UnitTests -> J:\Neuledgebase.build.temp\Neudesic.Neuledgebase.UnitTests.dll

Build FAILED.

C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj] 0 Warning(s) 1 Error(s)

Time Elapsed 00:00:04.59 [ERROR] Cake.exe : An error occurred when executing task 'Build'. [ERROR] At J:\Neuledgebase\Neudesic.Neuledgebase.Build\build.ps1:234 char:1 [ERROR] + &$CAKE_EXE $cakeArguments [ERROR] + ~~~~~ [ERROR] + CategoryInfo : NotSpecified: (An error occurr...g task 'Build'.:String) [], RemoteException [ERROR] + FullyQualifiedErrorId : NativeCommandError [ERROR]


Teardown

Finished running tasks. [ERROR] Error: [ERROR] One or more errors occurred. [ERROR] [ERROR] [ERROR]
[ERROR] .NET Core CLI: Process returned an error (exit code 1). [ERROR] [ERROR]

josephbaggett commented 6 years ago

dotnetbuild without cake Attached is a picture of me calling dotnet build directly with no issues on the same solution

josephbaggett commented 6 years ago

Here is the logs with diagnostics on:

PS J:\Neuledgebase\Neudesic.Neuledgebase.Build> .\build.ps1 -Target "Package" -Verbosity "Diagnostic" Preparing to run build script... Running build script... Module directory does not exist. NuGet.config not found. Analyzing build script... Analyzing J:/Neuledgebase/Neudesic.Neuledgebase.Build/build.cake... Processing build script... Installing tools... GET https://api.nuget.org/v3/registration3-gz-semver2/xunit.runner.console/index.json OK https://api.nuget.org/v3/registration3-gz-semver2/xunit.runner.console/index.json 147ms Found package 'xunit.runner.console 2.3.1' in 'J:/Neuledgebase/Neudesic.Neuledgebase.Build/tools'. Package xunit.runner.console.2.3.1 has already been installed. Successfully installed 'xunit.runner.console 2.3.1' to J:/Neuledgebase/Neudesic.Neuledgebase.Build/tools Executing nuget actions took 33.65 ms Adding assembly reference to mscorlib.dll... Adding assembly reference to System.Core.dll... Adding assembly reference to Cake.Core.dll... Adding assembly reference to Cake.Common.dll... Adding assembly reference to Cake.exe... Adding assembly reference to System.dll... Adding assembly reference to System.Xml.dll... Adding assembly reference to System.Xml.Linq.dll... Adding assembly reference to System.Data.dll... Adding assembly reference to System.Runtime.dll... Adding assembly reference to System.Collections.dll... Adding assembly reference to netstandard.dll... Importing namespace Cake.Common... Importing namespace Cake.Common.Build... Importing namespace Cake.Common.Build.AppVeyor... Importing namespace Cake.Common.Build.AppVeyor.Data... Importing namespace Cake.Common.Build.Bamboo... Importing namespace Cake.Common.Build.Bamboo.Data... Importing namespace Cake.Common.Build.BitbucketPipelines... Importing namespace Cake.Common.Build.BitbucketPipelines.Data... Importing namespace Cake.Common.Build.Bitrise... Importing namespace Cake.Common.Build.Bitrise.Data... Importing namespace Cake.Common.Build.ContinuaCI... Importing namespace Cake.Common.Build.ContinuaCI.Data... Importing namespace Cake.Common.Build.GitLabCI... Importing namespace Cake.Common.Build.GitLabCI.Data... Importing namespace Cake.Common.Build.GoCD... Importing namespace Cake.Common.Build.GoCD.Data... Importing namespace Cake.Common.Build.Jenkins... Importing namespace Cake.Common.Build.Jenkins.Data... Importing namespace Cake.Common.Build.MyGet... Importing namespace Cake.Common.Build.TeamCity... Importing namespace Cake.Common.Build.TFBuild... Importing namespace Cake.Common.Build.TFBuild.Data... Importing namespace Cake.Common.Build.TravisCI... Importing namespace Cake.Common.Build.TravisCI.Data... Importing namespace Cake.Common.Diagnostics... Importing namespace Cake.Common.IO... Importing namespace Cake.Common.IO.Paths... Importing namespace Cake.Common.Net... Importing namespace Cake.Common.Security... Importing namespace Cake.Common.Solution... Importing namespace Cake.Common.Solution.Project... Importing namespace Cake.Common.Solution.Project.Properties... Importing namespace Cake.Common.Solution.Project.XmlDoc... Importing namespace Cake.Common.Text... Importing namespace Cake.Common.Tools... Importing namespace Cake.Common.Tools.Cake... Importing namespace Cake.Common.Tools.Chocolatey... Importing namespace Cake.Common.Tools.Chocolatey.ApiKey... Importing namespace Cake.Common.Tools.Chocolatey.Config... Importing namespace Cake.Common.Tools.Chocolatey.Download... Importing namespace Cake.Common.Tools.Chocolatey.Features... Importing namespace Cake.Common.Tools.Chocolatey.Install... Importing namespace Cake.Common.Tools.Chocolatey.New... Importing namespace Cake.Common.Tools.Chocolatey.Pack... Importing namespace Cake.Common.Tools.Chocolatey.Pin... Importing namespace Cake.Common.Tools.Chocolatey.Push... Importing namespace Cake.Common.Tools.Chocolatey.Sources... Importing namespace Cake.Common.Tools.Chocolatey.Uninstall... Importing namespace Cake.Common.Tools.Chocolatey.Upgrade... Importing namespace Cake.Common.Tools.DotCover... Importing namespace Cake.Common.Tools.DotCover.Analyse... Importing namespace Cake.Common.Tools.DotCover.Cover... Importing namespace Cake.Common.Tools.DotCover.Merge... Importing namespace Cake.Common.Tools.DotCover.Report... Importing namespace Cake.Common.Tools.DotNetCore... Importing namespace Cake.Common.Tools.DotNetCore.Build... Importing namespace Cake.Common.Tools.DotNetCore.Clean... Importing namespace Cake.Common.Tools.DotNetCore.Execute... Importing namespace Cake.Common.Tools.DotNetCore.MSBuild... Importing namespace Cake.Common.Tools.DotNetCore.NuGet.Delete... Importing namespace Cake.Common.Tools.DotNetCore.NuGet.Push... Importing namespace Cake.Common.Tools.DotNetCore.Pack... Importing namespace Cake.Common.Tools.DotNetCore.Publish... Importing namespace Cake.Common.Tools.DotNetCore.Restore... Importing namespace Cake.Common.Tools.DotNetCore.Run... Importing namespace Cake.Common.Tools.DotNetCore.Test... Importing namespace Cake.Common.Tools.DotNetCore.Tool... Importing namespace Cake.Common.Tools.DotNetCore.VSTest... Importing namespace Cake.Common.Tools.DupFinder... Importing namespace Cake.Common.Tools.Fixie... Importing namespace Cake.Common.Tools.GitLink... Importing namespace Cake.Common.Tools.GitReleaseManager... Importing namespace Cake.Common.Tools.GitReleaseManager.AddAssets... Importing namespace Cake.Common.Tools.GitReleaseManager.Close... Importing namespace Cake.Common.Tools.GitReleaseManager.Create... Importing namespace Cake.Common.Tools.GitReleaseManager.Export... Importing namespace Cake.Common.Tools.GitReleaseManager.Publish... Importing namespace Cake.Common.Tools.GitReleaseNotes... Importing namespace Cake.Common.Tools.GitVersion... Importing namespace Cake.Common.Tools.ILMerge... Importing namespace Cake.Common.Tools.ILRepack... Importing namespace Cake.Common.Tools.InnoSetup... Importing namespace Cake.Common.Tools.InspectCode... Importing namespace Cake.Common.Tools.MSBuild... Importing namespace Cake.Common.Tools.MSpec... Importing namespace Cake.Common.Tools.MSTest... Importing namespace Cake.Common.Tools.NSIS... Importing namespace Cake.Common.Tools.NuGet... Importing namespace Cake.Common.Tools.NuGet.Add... Importing namespace Cake.Common.Tools.NuGet.Init... Importing namespace Cake.Common.Tools.NuGet.Install... Importing namespace Cake.Common.Tools.NuGet.List... Importing namespace Cake.Common.Tools.NuGet.Pack... Importing namespace Cake.Common.Tools.NuGet.Push... Importing namespace Cake.Common.Tools.NuGet.Restore... Importing namespace Cake.Common.Tools.NuGet.SetApiKey... Importing namespace Cake.Common.Tools.NuGet.SetProxy... Importing namespace Cake.Common.Tools.NuGet.Sources... Importing namespace Cake.Common.Tools.NuGet.Update... Importing namespace Cake.Common.Tools.NUnit... Importing namespace Cake.Common.Tools.OctopusDeploy... Importing namespace Cake.Common.Tools.OpenCover... Importing namespace Cake.Common.Tools.ReportGenerator... Importing namespace Cake.Common.Tools.ReportUnit... Importing namespace Cake.Common.Tools.Roundhouse... Importing namespace Cake.Common.Tools.SignTool... Importing namespace Cake.Common.Tools.SpecFlow... Importing namespace Cake.Common.Tools.SpecFlow.StepDefinitionReport... Importing namespace Cake.Common.Tools.SpecFlow.TestExecutionReport... Importing namespace Cake.Common.Tools.TextTransform... Importing namespace Cake.Common.Tools.VSTest... Importing namespace Cake.Common.Tools.VSWhere... Importing namespace Cake.Common.Tools.VSWhere.All... Importing namespace Cake.Common.Tools.VSWhere.Latest... Importing namespace Cake.Common.Tools.VSWhere.Legacy... Importing namespace Cake.Common.Tools.VSWhere.Product... Importing namespace Cake.Common.Tools.WiX... Importing namespace Cake.Common.Tools.WiX.Heat... Importing namespace Cake.Common.Tools.XBuild... Importing namespace Cake.Common.Tools.XUnit... Importing namespace Cake.Common.Xml... Importing namespace Cake.Core... Importing namespace Cake.Core.Diagnostics... Importing namespace Cake.Core.IO... Importing namespace Cake.Core.Scripting... Importing namespace System... Importing namespace System.Collections.Generic... Importing namespace System.IO... Importing namespace System.Linq... Importing namespace System.Text... Importing namespace System.Threading.Tasks... Compiling build script...


Setup

Executing custom setup action... Running tasks...

======================================== Restore

Executing task: Restore Restore! Executing: "C:/Program Files/dotnet/dotnet.exe" restore "..\Neudesic.Neuledgebase.sln" Restore completed in 29.39 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj. Restore completed in 32.6 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Build\Neudesic.Neuledgebase.Build.csproj. Restore completed in 43.59 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. Restore completed in 86.29 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. Finished executing task: Restore

======================================== Build

Executing task: Build Build! Executing: "C:/Program Files/dotnet/dotnet.exe" build "..\Neudesic.Neuledgebase.sln" --output "J:/Neuledgebase/.build/.temp" --framework netcoreapp2.0 --configuration Release Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 30.26 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj. Restore completed in 33.45 ms for J:\Neuledgebase\Neudesic.Neuledgebase.Build\Neudesic.Neuledgebase.Build.csproj. Restore completed in 42.65 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. Restore completed in 73.51 ms for J:\Neuledgebase\Neudesic.Neuledgebase.UnitTests\Neudesic.Neuledgebase.UnitTests.csproj. C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj] Neudesic.Neuledgebase.UnitTests -> J:\Neuledgebase.build.temp\Neudesic.Neuledgebase.UnitTests.dll Neudesic.Neuledgebase.Build -> J:\Neuledgebase.build.temp\Neudesic.Neuledgebase.Build.dll

Build FAILED.

C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets(167,5): error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. [J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\Neudesic.Neuledgebase.Repositories.csproj] 0 Warning(s) 1 Error(s)

Time Elapsed 00:00:03.58 [ERROR] Cake.exe : An error occurred when executing task 'Build'. [ERROR] At J:\Neuledgebase\Neudesic.Neuledgebase.Build\build.ps1:234 char:1 [ERROR] + &$CAKE_EXE $cakeArguments [ERROR] + ~~~~~ [ERROR] + CategoryInfo : NotSpecified: (An error occurr...g task 'Build'.:String) [], RemoteException [ERROR] + FullyQualifiedErrorId : NativeCommandError [ERROR]


Teardown

Executing custom teardown action... Finished running tasks. [ERROR] Error: [ERROR] System.AggregateException: One or more errors occurred. ---> Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit [ERROR] code 1). [ERROR] at Cake.Core.Tooling.Tool1.ProcessExitCode(Int32 exitCode) [ERROR] at Cake.Core.Tooling.Tool1.Run(TSettings sett [ERROR] ings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action1 postAction) [ERROR] at Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuilder.Build(String project, DotNetCoreBuildSettings settings) [ERROR] at Submission#0.DotNetCoreBuild(String project, DotNetCoreBuildSettings settings) [ERROR] at Submission#0.<<Initialize>>b__0_4() [ERROR] at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass8_0.<Does>b__0(ICakeContext x) [ERROR] at Cake.Core.ActionTask.<Execute>d__14.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.DefaultExecutionStrategy.<ExecuteAsync>d__4.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__29.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.CakeEngine.<RunTargetAsync>d__18.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.Scripting.ScriptHost.RunTarget(String target) [ERROR] at Submission#0.<<Initialize>>d__0.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__91.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runti [ERROR] me.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Microsoft.CodeAnalysis.Scripting.Script1.<RunSubmissionsAsync>d__21.MoveNext() [ERROR] --- End of inner exception stack trace --- [ERROR] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) [ERROR] at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) [ERROR] at Cake.Scripting.Roslyn.RoslynScriptSession.Execute(Script script) [ERROR] at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary2 arguments) [ERROR] at Cake.Commands.BuildCommand.Execute(CakeOptions options) [ERROR] at Cake.CakeApplication.Run(CakeOptions options) [ERROR] at Cake.Program.Main() [ERROR] ---> (Inner Exception #0) Cake.Core.CakeException: .NET Core CLI: Process returned an error (exit code 1). [ERROR] at Cake.Core.Tooling.Tool1.ProcessExitCode(Int32 exitCode) [ERROR] at Cake.Core.Tooling.Tool1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action1 [ERROR] postAction) [ERROR] at Cake.Common.Tools.DotNetCore.Build.DotNetCoreBuilder.Build(String project, DotNetCoreBuildSettings settings) [ERROR] at Submission#0.DotNetCoreBuild(String project, DotNetCoreBuildSettings settings) [ERROR] at Submission#0.<<Initialize>>b__0_4() [ERROR] at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass8_0.<Does>b__0(ICakeContext x) [ERROR] at Cake.Core.ActionTask.<Execute>d__14.MoveNext() [ERROR] --- End of stack trace [ERROR] from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.DefaultExecu [ERROR] tionStrategy.<ExecuteAsync>d__4.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.CakeEngine.<ExecuteTaskAsync>d__29.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at S [ERROR] ystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.CakeEngine.<RunTargetAsync>d__18.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Scripting.BuildScriptHost.<RunTargetAsync>d__3.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Cake.Core.Scripting.ScriptHost.RunTa [ERROR] rget(String target) [ERROR] at Submission#0.<<Initialize>>d__0.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.<RunSubmissionsAsync>d__91.MoveNext() [ERROR] --- End of stack trace from previous location where exception was thrown --- [ERROR] at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR] at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [ERROR] at Microsoft.CodeAnalysis.Scripting.Script`1.d__21.MoveNext()<--- [ERROR] [ERROR] [ERROR]

JonCubed commented 6 years ago

This is the error you are receiving

error : Assets file 'J:\Neuledgebase\Neudesic.Neuledgebase.Repositories\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0'. Ensure that restore has run and that you have included 'netcoreapp2.0' in the TargetFrameworks for your project. 

if Neudesic.Neuledgebase.Repositories.csproj is a .NET standard library then your build is targeting the wrong TargetFramework it should be netstandard2.0 if it is an app then make sure TargetFramework or TargetFrameworks includes netcoreapp2.0

The reason you are seeing a difference in behaviour is when you manually run it you are using dotnet build Neudesic.Neuledgebase.sln however when cake is running it is using "C:/Program Files/dotnet/dotnet.exe" build "..\Neudesic.Neuledgebase.sln" --output "J:/Neuledgebase/.build/.temp" --framework netcoreapp2.0 --configuration Release notice the extra flags and framework is netcoreapp2.0

on a side note, in 2.0+ of sdk you don't need to run restore separately if you don't want to it is run implicitly with other commands like build. if you do want to run it seperately you can use the --no-restore flag with build so it doesn't do restore twice.

gitfool commented 6 years ago

@devlead Could you please provide the Dockerfile you used to build cakebuild/cake:2.1-sdk referred to in TestCakeDocker/blob/master/run.cmd? (There's no source link on Docker Hub.)

I did find bitbucket-pipelines-dotnet/blob/master/Dockerfile as the most likely candidate, but it raises some questions since it installs all its dependencies manually, including the .NET SDK and Mono. For example, if you were making a builder image just for .NET Core 2.1.x+ apps and libraries, what would you do differently? (Would you just FROM microsoft/dotnet:2.1-sdk directly?)

devlead commented 6 years ago

Docker files for the cake images are found at

https://github.com/cake-build/docker