1

I have two projects: StdLib which is NETStandard 2.0 class library and Console.Framework which is .NET Framework 4.6.1 project. Console application references the class library.

I try to build the solution using Cake build. I use DotNetBuild method (link) and I get this output:

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. Build started 9/12/2017 2:35:55 PM. Project "C:\Projects\NetStdExample\NetStdExample.sln" on node 1 (Build target(s)). ValidateSolutionConfiguration: Building solution configuration "Debug|Any CPU". Project "C:\Projects\NetStdExample\NetStdExample.sln" (1) is building "C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj" (2) on node 1 (default targets). C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj(1,1): error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MS Build 2003 format. Done Building Project "C:\Projects\NetStdExample\NetStdExample.StdLib\NetStdExample.StdLib.csproj" (default targets) -- FAILED.

Is there a way how to build this kind of project using Cake?

Michael
  • 1,027
  • 10
  • 22

1 Answers1

2

The DotNetBuild alias is an older alias, which makes an informed decision about whether to build:

the specified solution using MSBuild or XBuild.

i.e. it will look at what type of machine the build is currently running on, and either run MSBuild or XBuild.

From the sounds of your question, this doesn't sound like what you want. Instead, I think you are after the DotNetCore Aliases:

https://www.cakebuild.net/api/Cake.Common.Tools.DotNetCore/DotNetCoreAliases/

i.e. you can do something like:

DotNetCoreBuild(BuildParameters.SolutionFilePath.FullPath);

To build the specified solution using the dotnet cli.

It is likely that the DotNetBuild alias will be obsoleted at some point.

Gary Ewan Park
  • 17,610
  • 5
  • 42
  • 60
  • That helps with the example Console application. When I try to build the ASP.NET project with `DotNetCoreBuild` I get: `IntegrationProxy.csproj(303,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.0.2-vspre-006949\Microsoft\VisualStu dio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.` Do you know how to resolve this kind of issue? – Michael Sep 12 '17 at 14:04
  • If you run Cake with Diagnostic Verbosity, as shown here: https://stackoverflow.com/questions/38658660/how-to-enable-diagnostic-verbosity-for-cake it will show you the exact dotnet cli command that is being executed. If you can take that same command and run it manually at the command line, this will allow us to see if the issue lies with Cake, or with something else in your environment. – Gary Ewan Park Sep 12 '17 at 14:24
  • It seems like the issue is not with ```Cake``` but with the project references. `dotnet build` can't build the regular .net framework project. But Visual Studio manages to build somehow. I'm interested how to recreate VS behavior with `Cake`. I will investigate further. Thank you! – Michael Sep 12 '17 at 14:27
  • 1
    check the solution for web application: [link](https://stackoverflow.com/questions/46179678/build-net-framework-web-application-referencing-net-standard-library-with-cake-b/46179679#46179679) – Michael Sep 12 '17 at 14:57