Build Net Framework web application referencing net-standard library with Cake build

553 views Asked by At

I have two projects: NET Standard class library and regular NET Framework web application. Web application references class library.

I use Visual Studio 2017 Preview.

When I try to build the solution with Cake using MSBuild command I get the unsupported project message:

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.

If I try to use DotNetCoreBuild I get:

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 <Import> declaration is correct, and that the file exists on disk.

But the solution is built successfully by Visual Studio.

1

There are 1 answers

2
Michael On BEST ANSWER

Latest MSBuild version has the targets to build NET Standard libraries. The problem is in Visual Studio Preview installation path: Cake can't find the latest MSBuild.

It will also fail if you will try to specify VS2017 in MSBuildToolVersion.

You have to specify the MSBuild executable manually to make it work with VS Preview.

string msBuildPath = @"c:\Program Files (x86)\Microsoft Visual Studio\Preview\Professional\MSBuild\15.0\Bin\MSBuild.exe";

MSBuild("../NetStdExample.sln", new MSBuildSettings {
    Verbosity = Verbosity.Minimal,
    ToolPath = msBuildPath
});

Update by @Gary Ewan Park: there is a tool for determining latest VS install.